static void yp_client_add (ice_config_t *config) { if (config->num_yp_directories == 0 || active_yps || global.running != ICE_RUNNING) return; INFO0 ("Starting Directory client for YP processing"); ypclient.ops = &directory_client_ops; ypclient.counter = 0; ypclient.schedule_ms = 0; ypclient.connection.error = 0; ypclient.flags = CLIENT_ACTIVE|CLIENT_SKIP_ACCESSLOG; client_add_worker (&ypclient); }
static int relay_install (relay_server *relay) { client_t *client = calloc (1, sizeof (client_t)); connection_init (&client->connection, SOCK_ERROR, NULL); global_lock(); client_register (client); global_unlock(); client->shared_data = relay; client->ops = &relay_init_ops; client->flags |= CLIENT_ACTIVE; DEBUG1 ("adding relay client for %s", relay->localmount); client_add_worker (client); return 0; }
void client_destroy(client_t *client) { if (client == NULL) return; if (client->worker) { WARN0 ("client still on worker thread"); return; } /* release the buffer now, as the buffer could be on the source queue * and may of disappeared after auth completes */ if (client->refbuf) { refbuf_release (client->refbuf); client->refbuf = NULL; } if (client->flags & CLIENT_AUTHENTICATED) DEBUG1 ("client still in auth \"%s\"", httpp_getvar (client->parser, HTTPP_VAR_URI)); /* write log entry if ip is set (some things don't set it, like outgoing * slave requests */ if (client->respcode > 0 && client->parser) logging_access(client); if (client->flags & CLIENT_IP_BAN_LIFT) { INFO1 ("lifting IP ban on client at %s", client->connection.ip); connection_release_banned_ip (client->connection.ip); client->flags &= ~CLIENT_IP_BAN_LIFT; } if (client->parser) httpp_destroy (client->parser); /* we need to free client specific format data (if any) */ if (client->free_client_data) client->free_client_data (client); free(client->username); free(client->password); client->username = NULL; client->password = NULL; client->parser = NULL; client->respcode = 0; client->free_client_data = NULL; global_lock (); if (global.running != ICE_RUNNING || client->connection.error || (client->flags & CLIENT_KEEPALIVE) == 0 || client_connected (client) == 0) { global.clients--; stats_event_args (NULL, "clients", "%d", global.clients); config_clear_listener (client->server_conn); global_unlock (); connection_close (&client->connection); free(client); return; } global_unlock (); DEBUG0 ("keepalive detected, placing back onto worker"); client->counter = client->schedule_ms = timing_get_time(); client->connection.con_time = client->schedule_ms/1000; client->connection.discon.time = client->connection.con_time + 7; client->ops = &http_request_ops; client->flags = CLIENT_ACTIVE; client->shared_data = NULL; client->refbuf = NULL; client->pos = 0; client->intro_offset = client->connection.sent_bytes = 0; client_add_worker (client); }