void processors_io_out_thread(void *data, void *userdata) { g_debug("%s data %p userdata %p", __PRETTY_FUNCTION__, data, userdata); struct connection *con = data; struct processor_data *pd = userdata; g_mutex_lock(&pd->mutex); refcount_dec(&pd->queued); recurse_io_process(pd, con, bistream_out); g_mutex_unlock(&pd->mutex); connection_unref(con); }
/** Sur destruction de la connexion. * @param nfct Structure de la connexion (dans netfilter) **/ static void hooks_conn_destroy(struct nf_conn* nfct) { struct hooks_conn* hc = (struct hooks_conn*) __nf_ct_ext_find(nfct, HOOKS_GET_CTEXTID); struct connection* connection; // Connexion associée if (unlikely(!hc)) // Non trouvé return; connection = hc->connection; if (!connection) // Sans connexion associée return; connection_ref(connection); /// REF scheduler_interface_onconnterminate(connection); connection_unref(connection); /// UNREF }
static void session_free(struct session *session) { g_free(session->url); if( session->laddr ) g_free(session->laddr); switch( session->type ) { case session_type_download: if( session->action.download.file ) { tempfile_unlink(session->action.download.file); tempfile_free(session->action.download.file); session->action.download.file = NULL; if( session->action.download.ctxcon != NULL ) connection_unref(session->action.download.ctxcon); } break; case session_type_upload: curl_formfree(session->action.upload.formpost); curl_slist_free_all(session->action.upload.headers); if( session->action.upload.username != NULL ) g_free(session->action.upload.username); if( session->action.upload.password != NULL ) g_free(session->action.upload.password); if( session->action.upload.callback != NULL ) g_free(session->action.upload.callback); if( session->action.upload.userdata != NULL ) g_free(session->action.upload.userdata); if( session->action.upload.file != NULL ) tempfile_free(session->action.upload.file); break; } g_free(session); }
static void connection_unlink(connection *c) { pa_assert(c); if (!c->protocol) return; if (c->options) { pa_simple_options_unref(c->options); c->options = NULL; } if (c->sink_input) { pa_sink_input_unlink(c->sink_input); pa_sink_input_unref(c->sink_input); c->sink_input = NULL; } if (c->source_output) { pa_source_output_unlink(c->source_output); pa_source_output_unref(c->source_output); c->source_output = NULL; } if (c->client) { pa_client_free(c->client); c->client = NULL; } if (c->io) { pa_iochannel_free(c->io); c->io = NULL; } pa_idxset_remove_by_data(c->protocol->connections, c, NULL); c->protocol = NULL; connection_unref(c); }
void emulate_ctx_free(void *data) { struct emu_emulate_ctx *ctx = data; GHashTableIter iter; gpointer key, value; g_hash_table_iter_init (&iter, ctx->files); while( g_hash_table_iter_next (&iter, &key, &value) ) { g_debug("file key %p %i value %p \n", key, *(int *)key, value); struct tempfile *tf = value; if( tf->fh == NULL ) { /* file was closed by shellcode */ struct incident *i = incident_new("dionaea.download.complete"); incident_value_string_set(i, "path", g_string_new(tf->path)); if( ctx->ctxcon ) incident_value_con_set(i, "con", ctx->ctxcon); incident_value_string_set(i, "url", g_string_new("emulate://")); incident_report(i); incident_free(i); }else tempfile_close(tf); tempfile_unlink(tf); tempfile_free(tf); } g_hash_table_destroy(ctx->files); g_hash_table_iter_init (&iter, ctx->processes); while( g_hash_table_iter_next (&iter, &key, &value) ) { g_debug("process key %p %i value %p \n", key, *(int *)key, value); } g_hash_table_destroy(ctx->processes); g_hash_table_iter_init (&iter, ctx->sockets); while( g_hash_table_iter_next (&iter, &key, &value) ) { struct connection *con = value; g_debug("connection key %p %i value %p type %s state %s socket %i\n", key, *(int *)key, value, connection_type_to_string(con->type), connection_state_to_string(con->state), con->socket); if( con->socket != -1 ) {/* avoid callbacks from connection_close() */ close(con->socket); con->socket = -1; } g_free(key); con->protocol.ctx = NULL; con->events.free.repeat = .5; connection_free(con); } g_hash_table_destroy(ctx->sockets); if( ctx->time != NULL ) g_timer_destroy(ctx->time); emu_free(ctx->emu); emu_env_free(ctx->env); g_mutex_clear(&ctx->mutex); if( ctx->ctxcon != NULL ) connection_unref(ctx->ctxcon); g_free(ctx); }