void memcached_free(memcached_st *ptr) { if (!ptr) return; /* If we have anything open, lets close it now */ memcached_quit(ptr); server_list_free(ptr, ptr->hosts); memcached_result_free(&ptr->result); if (ptr->on_cleanup) ptr->on_cleanup(ptr); if (ptr->continuum) { if (ptr->call_free) ptr->call_free(ptr, ptr->continuum); else free(ptr->continuum); } if (ptr->is_allocated) { if (ptr->call_free) ptr->call_free(ptr, ptr); else free(ptr); } else memset(ptr, 0, sizeof(memcached_st)); }
void memcached_servers_reset(memcached_st *ptr) { server_list_free(ptr, memcached_server_list(ptr)); memcached_server_list_set(ptr, NULL); ptr->number_of_hosts= 0; ptr->last_disconnected_server= NULL; ptr->server_failure_limit= 0; }
void memcached_free(memcached_st *ptr) { /* If we have anything open, lets close it now */ memcached_quit(ptr); server_list_free(ptr, memcached_server_list(ptr)); memcached_result_free(&ptr->result); if (ptr->on_cleanup) ptr->on_cleanup(ptr); if (ptr->continuum) libmemcached_free(ptr, ptr->continuum); if (memcached_is_allocated(ptr)) { libmemcached_free(ptr, ptr); } }
void memcached_server_list_free(memcached_server_st *ptr) { server_list_free(NULL, ptr); }
static void collect_statistics (void) { GSList *servers; GSList *tmp; struct server *s; char **info; enum OS os; enum CPU cpu; int countthisserver; servers = all_servers (); /* Free at end of this function */ if (servers) { for (tmp = servers; tmp; tmp = tmp->next) { s = (struct server *) tmp->data; info = s->info; cpu = CPU_UNKNOWN; os = OS_UNKNOWN; countthisserver=0; servers_count++; srv_stats[s->type].servers++; srv_stats[s->type].players += s->curplayers; players_count += s->curplayers; if (s->ping < MAX_PING) { if (s->ping >= 0) { srv_stats[s->type].ok++; countthisserver=1; } else srv_stats[s->type].na++; } else { if (s->ping == MAX_PING) srv_stats[s->type].timeout++; else srv_stats[s->type].down++; } #ifdef USE_GEOIP if (s->country_id >= 0 && s->country_id < geoip_num_countries()) { if (++srv_countries[s->type].country[s->country_id].n == 1) { srv_countries[s->type].country[s->country_id].c = s->country_id; ++srv_countries[s->type].nonzero; } if (++srv_countries[GAMES_TOTAL].country[s->country_id].n == 1) { srv_countries[GAMES_TOTAL].country[s->country_id].c = s->country_id; ++srv_countries[GAMES_TOTAL].nonzero; } } #endif if (info && games[s->type].arch_identifier) { while (info[0]) { if (g_ascii_strcasecmp (info[0], games[s->type].arch_identifier) == 0) { if (!info[1]) break; if (games[s->type].identify_cpu) cpu = games[s->type].identify_cpu(s, info[1]); else cpu = CPU_UNKNOWN; if (games[s->type].identify_os) os = games[s->type].identify_os(s, info[1]); else os = OS_UNKNOWN; break; } info += 2; } if (countthisserver) { srv_archs[s->type].oscpu[os][cpu]++; srv_archs[s->type].count++; players[s->type].on_os[os] += s->curplayers; players[s->type].total += s->curplayers; } } } server_list_free (servers); } #ifdef USE_GEOIP { unsigned g; for (g = 0; g < GAMES_TOTAL+1; ++g) { qsort(srv_countries[g].country, geoip_num_countries(), sizeof(struct country_num), country_stat_compare_func); } } #endif }