{
int status;
+ /* listen_loop is set to non-zero in the shutdown callback, which is
+ * guaranteed to be called *after* all the write threads have been shut
+ * down. */
+ assert (listen_loop == 0);
+
if (!check_send_okay (vl))
{
#if COLLECT_DEBUG
{
llentry_t *le;
- stop_read_threads ();
-
destroy_all_callbacks (&list_init);
+ stop_read_threads ();
+
pthread_mutex_lock (&read_lock);
llist_destroy (read_list);
read_list = NULL;
destroy_read_heap ();
+ /* blocks until all write threads have shut down. */
+ stop_write_threads ();
+
+ /* ask all plugins to write out the state they kept. */
plugin_flush (/* plugin = */ NULL,
/* timeout = */ 0,
/* identifier = */ NULL);
plugin_set_ctx (old_ctx);
}
- stop_write_threads ();
-
/* Write plugins which use the `user_data' pointer usually need the
* same data available to the flush callback. If this is the case, set
* the free_function to NULL when registering the flush callback and to