if (tcc->tc != NULL)
tcc->tc (tcc->tc_cls, GNUNET_SYSERR);
if (GNUNET_YES == tcc->end)
- {
- GNUNET_SERVER_receive_done (tcc->client, GNUNET_SYSERR);
- }
+ GNUNET_SERVER_receive_done (tcc->client, GNUNET_SYSERR);
+ GNUNET_SERVER_client_drop (tcc->client);
GNUNET_free (tcc->msg);
GNUNET_free (tcc);
return 0;
"Response transmitted, more pending!\n");
#endif
}
+ GNUNET_SERVER_client_drop (tcc->client);
GNUNET_free (tcc->msg);
GNUNET_free (tcc);
return msize;
tcc->end = end;
if (NULL ==
(tcc->th = GNUNET_SERVER_notify_transmit_ready (client,
- ntohs(msg->size),
- GNUNET_TIME_UNIT_FOREVER_REL,
- &transmit_callback,
+ ntohs(msg->size),
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &transmit_callback,
tcc)))
{
GNUNET_break (0);
tc (tc_cls, GNUNET_SYSERR);
GNUNET_free (msg);
GNUNET_free (tcc);
+ return;
}
+ GNUNET_SERVER_client_keep (client);
GNUNET_CONTAINER_DLL_insert (tcc_head,
tcc_tail,
tcc);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
+ GNUNET_SERVER_client_keep (client);
msg = (const struct GetMessage*) message;
if ( (size == sizeof(struct GetMessage)) &&
(GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (filter,
"GET",
GNUNET_h2s (&msg->key));
#endif
- GNUNET_SERVER_client_keep (client);
transmit_item (client,
NULL, NULL, 0, NULL, 0, 0, 0,
GNUNET_TIME_UNIT_ZERO_ABS, 0);
return;
}
- GNUNET_SERVER_client_keep (client);
plugin->api->get (plugin->api->cls,
((size == sizeof(struct GetMessage)) ? &msg->key : NULL),
NULL,
}
+/**
+ * Final task run after shutdown. Unloads plugins and disconnects us from
+ * statistics.
+ */
+static void
+unload_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ unload_plugin (plugin);
+ plugin = NULL;
+ if (filter != NULL)
+ {
+ GNUNET_CONTAINER_bloomfilter_free (filter);
+ filter = NULL;
+ }
+ GNUNET_ARM_stop_services (cfg, tc->sched, "statistics", NULL);
+}
+
+
/**
* Last task run during shutdown. Disconnects us from
* the transport and core.
static void
cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ struct TransmitCallbackContext *tcc;
+
+ while (NULL != (tcc = tcc_head))
+ {
+ GNUNET_CONTAINER_DLL_remove (tcc_head,
+ tcc_tail,
+ tcc);
+ if (tcc->th != NULL)
+ GNUNET_CONNECTION_notify_transmit_ready_cancel (tcc->th);
+ if (NULL != tcc->tc)
+ tcc->tc (tcc->tc_cls, GNUNET_SYSERR);
+ GNUNET_free (tcc->msg);
+ GNUNET_free (tcc);
+ }
if (expired_kill_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (sched,
expired_kill_task);
expired_kill_task = GNUNET_SCHEDULER_NO_TASK;
}
- unload_plugin (plugin);
- plugin = NULL;
- if (filter != NULL)
- {
- GNUNET_CONTAINER_bloomfilter_free (filter);
- filter = NULL;
- }
- GNUNET_ARM_stop_services (cfg, tc->sched, "statistics", NULL);
+ GNUNET_SCHEDULER_add_continuation (sched,
+ &unload_task,
+ NULL,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
}
}
-/**
- * Function that removes all active reservations made
- * by the given client and releases the space for other
- * requests.
- *
- * @param cls closure
- * @param client identification of the client
- */
-static void
-cleanup_transmits (void *cls,
- struct GNUNET_SERVER_Client
- * client)
-{
- struct TransmitCallbackContext *tcc;
-
- while (NULL != (tcc = tcc_head))
- {
- GNUNET_CONTAINER_DLL_remove (tcc_head,
- tcc_tail,
- tcc);
- if (tcc->th != NULL)
- GNUNET_CONNECTION_notify_transmit_ready_cancel (tcc->th);
- GNUNET_free (tcc->msg);
- GNUNET_free (tcc);
- }
-
-}
-
-
-
/**
* Process datastore requests.
*
return;
}
GNUNET_SERVER_disconnect_notify (server, &cleanup_reservations, NULL);
- GNUNET_SERVER_disconnect_notify (server, &cleanup_transmits, NULL);
GNUNET_SERVER_add_handlers (server, handlers);
expired_kill_task
= GNUNET_SCHEDULER_add_with_priority (sched,