void li_connection_free(liConnection *con) { LI_FORCE_ASSERT(NULL == con->con_sock.data); LI_FORCE_ASSERT(LI_CON_STATE_DEAD == con->state); con->response_headers_sent = FALSE; con->expect_100_cont = FALSE; con->out_has_all_data = FALSE; li_server_socket_release(con->srv_sock); con->srv_sock = NULL; g_string_free(con->info.remote_addr_str, TRUE); li_sockaddr_clear(&con->info.remote_addr); g_string_free(con->info.local_addr_str, TRUE); li_sockaddr_clear(&con->info.local_addr); li_vrequest_free(con->mainvr); li_http_request_parser_clear(&con->req_parser_ctx); con->info.keep_alive = TRUE; if (con->keep_alive_data.link && con->wrk) { g_queue_delete_link(&con->wrk->keep_alive_queue, con->keep_alive_data.link); con->keep_alive_data.link = NULL; } con->keep_alive_data.timeout = 0; con->keep_alive_data.max_idle = 0; li_event_clear(&con->keep_alive_data.watcher); /* remove from timeout queue */ li_waitqueue_remove(&con->wrk->io_timeout_queue, &con->io_timeout_elem); li_job_clear(&con->job_reset); g_slice_free(liConnection, con); }
static void close_cb(liGnuTLSFilter *f, gpointer data) { mod_connection_ctx *conctx = data; liConnection *con = conctx->con; LI_FORCE_ASSERT(conctx->tls_filter == f); conctx->tls_filter = NULL; li_gnutls_filter_free(f); gnutls_deinit(conctx->session); if (NULL != conctx->ctx) { mod_gnutls_context_release(conctx->ctx); conctx->ctx = NULL; } if (NULL != conctx->con) { liStream *raw_out = con->con_sock.raw_out, *raw_in = con->con_sock.raw_in; LI_FORCE_ASSERT(con->con_sock.data == conctx); conctx->con = NULL; con->con_sock.data = NULL; con->con_sock.callbacks = NULL; li_stream_acquire(raw_in); li_stream_reset(raw_out); li_stream_reset(raw_in); li_stream_release(raw_in); } #ifdef USE_SNI if (NULL != conctx->sni_db_wait) { li_fetch_cancel(&conctx->sni_db_wait); } if (NULL != conctx->sni_entry) { li_fetch_entry_release(conctx->sni_entry); conctx->sni_entry = NULL; } #endif if (NULL != conctx->client_hello_stream) { li_ssl_client_hello_stream_ready(conctx->client_hello_stream); li_stream_release(conctx->client_hello_stream); conctx->client_hello_stream = NULL; } #ifdef USE_SNI if (NULL != conctx->sni_jobref) { li_job_ref_release(conctx->sni_jobref); conctx->sni_jobref = NULL; } li_job_clear(&conctx->sni_job); if (NULL != conctx->sni_server_name) { g_string_free(conctx->sni_server_name, TRUE); conctx->sni_server_name = NULL; } #endif LI_FORCE_ASSERT(NULL != conctx->sock_stream); li_iostream_safe_release(&conctx->sock_stream); }