From: Florian Forster Date: Fri, 5 Dec 2008 10:29:54 +0000 (+0100) Subject: unixsock plugin: Make sure the initialization function is run only once. X-Git-Tag: collectd-4.4.5~10 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=bc5877df666a8befe63ae4f56fcad849d9c5427a unixsock plugin: Make sure the initialization function is run only once. If called multiple times, the global `sock_fd' variable will be re-set, breaking the plugin. --- diff --git a/src/unixsock.c b/src/unixsock.c index d80091b1..3dac88a4 100644 --- a/src/unixsock.c +++ b/src/unixsock.c @@ -382,8 +382,15 @@ static int us_config (const char *key, const char *val) static int us_init (void) { + static int have_init = 0; + int status; + /* Initialize only once. */ + if (have_init != 0) + return (0); + have_init = 1; + loop = 1; status = pthread_create (&listen_thread, NULL, us_server_thread, NULL);