static void connDealloc(struct conn *c) { if (c->protocol_data) c->client->protocol->freeProtocolData(c->protocol_data); if (c->app_private_data) c->app->freeAppData(c->app_private_data); arrayEach(c->cleanup, callbackCall); arrayDealloc(c->cleanup); freeList(c->send_queue); wfree(c); }
void freeMemcacheData(void *d) { struct memcacheProcData *data = d; if (data->command) wstrFree(data->command); if (data->key) wstrFree(data->key); if (data->keys) { arrayEach(data->keys, freeKey); arrayDealloc(data->keys); } if (data->vals) arrayDealloc(data->vals); wfree(d); }
// workerProcessCron is the cron of worker process, it must be called before // worker process initialized. // // `fake_func` is used by spawnFakeWorker and call it every cron. void workerProcessCron(void (*fake_func)(void *data), void *data) { static long long max_cron_interval = 0; struct timeval nowval; long long interval; int refresh_seconds; void (*worker_cron)(); refresh_seconds = Server.stat_refresh_seconds; worker_cron = WorkerProcess->worker->cron; while (WorkerProcess->alive) { arrayEach(WorkerProcess->apps, appCronRun); if (worker_cron) worker_cron(); if (fake_func) fake_func(data); processEvents(WorkerProcess->center, WHEATSERVER_CRON_MILLLISECONDS); if (WorkerProcess->ppid != getppid()) { wheatLog(WHEAT_NOTICE, "parent change, worker shutdown"); WorkerProcess->alive = 0; } clientsCron(); if (Server.cron_time.tv_sec - WorkerProcess->refresh_time > refresh_seconds) { sendStatPacket(WorkerProcess); WorkerProcess->refresh_time = Server.cron_time.tv_sec; } // Get the max worker cron interval for statistic info gettimeofday(&nowval, NULL); interval = getMicroseconds(nowval) - getMicroseconds(Server.cron_time); if (interval > max_cron_interval) { max_cron_interval = interval; getStatValByName("Max worker cron interval") = interval; } Server.cron_time = nowval; } // Stop accept new client deleteEvent(WorkerProcess->center, Server.ipfd, EVENT_READABLE|EVENT_WRITABLE); WorkerProcess->refresh_time = Server.cron_time.tv_sec; while (Server.cron_time.tv_sec - WorkerProcess->refresh_time < Server.graceful_timeout) { processEvents(WorkerProcess->center, WHEATSERVER_CRON_MILLLISECONDS); gettimeofday(&Server.cron_time, NULL); } }
void freeRamcloudData(void *data) { struct ramcloudData *d = data; if (d->retrievals) { arrayEach(d->retrievals, freeValue); arrayDealloc(d->retrievals); } if (d->retrievals_keys) arrayDealloc(d->retrievals_keys); if (d->retrievals_vals) arrayDealloc(d->retrievals_vals); if (d->retrievals_flags) arrayDealloc(d->retrievals_flags); if (d->retrievals_versions) arrayDealloc(d->retrievals_versions); if (d->retrieval_response) wstrFree(d->retrieval_response); wfree(d); }