summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c017cac)
raw | patch | inline | side by side (parent: c017cac)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 22 Feb 2009 11:16:45 +0000 (12:16 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 22 Feb 2009 11:16:45 +0000 (12:16 +0100) |
This way the user_data may be cleaned up before the final cleanup
phase..
phase..
src/plugin.c | patch | blob | history |
diff --git a/src/plugin.c b/src/plugin.c
index 9bcea3cd7e4a5d401085b7d52e3bd2c8dcf01e28..bba8e54ffb6d2ff5bb1244b8eaf53ed3f2473bf5 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
return ((void *) 0);
} /* void *plugin_read_thread */
-static void start_threads (int num)
+static void start_read_threads (int num)
{
int i;
read_threads = (pthread_t *) calloc (num, sizeof (pthread_t));
if (read_threads == NULL)
{
- ERROR ("plugin: start_threads: calloc failed.");
+ ERROR ("plugin: start_read_threads: calloc failed.");
return;
}
}
else
{
- ERROR ("plugin: start_threads: pthread_create failed.");
+ ERROR ("plugin: start_read_threads: pthread_create failed.");
return;
}
} /* for (i) */
-} /* void start_threads */
+} /* void start_read_threads */
-static void stop_threads (void)
+static void stop_read_threads (void)
{
int i;
pthread_mutex_lock (&read_lock);
read_loop = 0;
- DEBUG ("plugin: stop_threads: Signalling `read_cond'");
+ DEBUG ("plugin: stop_read_threads: Signalling `read_cond'");
pthread_cond_broadcast (&read_cond);
pthread_mutex_unlock (&read_lock);
{
if (pthread_join (read_threads[i], NULL) != 0)
{
- ERROR ("plugin: stop_threads: pthread_join failed.");
+ ERROR ("plugin: stop_read_threads: pthread_join failed.");
}
read_threads[i] = (pthread_t) 0;
}
sfree (read_threads);
read_threads_num = 0;
-} /* void stop_threads */
+} /* void stop_read_threads */
+
+static int remove_read_functions (void)
+{
+ llentry_t *this;
+
+ if (list_read == NULL)
+ return (0);
+
+ this = llist_head (list_read);
+ while (this != NULL)
+ {
+ llentry_t *next;
+ read_func_t *rf;
+
+ next = this->next;
+ rf = (read_func_t *) this->value;
+
+ free (this->key);
+
+ plugin_user_data_destroy (&rf->udata);
+ free (rf);
+
+ this = next;
+ }
+
+ llist_destroy (list_read);
+ list_read = NULL;
+
+ return (0);
+} /* }}} int remove_read_functions */
/*
* Public functions
rt = global_option_get ("ReadThreads");
num = atoi (rt);
if (num != -1)
- start_threads ((num > 0) ? num : 5);
+ start_read_threads ((num > 0) ? num : 5);
}
} /* void plugin_init_all */
int (*callback) (void);
llentry_t *le;
- stop_threads ();
+ stop_read_threads ();
+ remove_read_functions ();
if (list_shutdown == NULL)
return;