X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Funixsock.c;h=45ed9c699b783fa9e9e10a4dfd482a594e59d1a4;hb=4fb5d4b471e3f6a24d7cd36272e48e57bcb2c68f;hp=f8dcc5ba6b5e6c864572101a861cf465ecb8f211;hpb=583b04d5826669eb182cb6ea538cf68266721ccb;p=collectd.git diff --git a/src/unixsock.c b/src/unixsock.c index f8dcc5ba..45ed9c69 100644 --- a/src/unixsock.c +++ b/src/unixsock.c @@ -1,6 +1,6 @@ /** * collectd - src/unixsock.c - * Copyright (C) 2007 Florian octo Forster + * Copyright (C) 2007,2008 Florian octo Forster * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -23,7 +23,9 @@ #include "common.h" #include "plugin.h" #include "configfile.h" + #include "utils_cmd_putval.h" +#include "utils_cmd_putnotif.h" /* Folks without pthread will need to disable this plugin. */ #include @@ -81,7 +83,7 @@ static pthread_t listen_thread = (pthread_t) 0; /* Linked list and auxilliary variables for saving values */ static value_cache_t *cache_head = NULL; static pthread_mutex_t cache_lock = PTHREAD_MUTEX_INITIALIZER; -static unsigned int cache_oldest = UINT_MAX; +static time_t cache_oldest = -1; /* * Functions @@ -188,7 +190,7 @@ static int cache_insert (const data_set_t *ds, const value_list_t *vl) cache_head = vc; vc->time = vl->time; - if (vc->time < cache_oldest) + if ((vc->time < cache_oldest) || (-1 == cache_oldest)) cache_oldest = vc->time; pthread_mutex_unlock (&cache_lock); @@ -275,7 +277,7 @@ static int cache_update (const data_set_t *ds, const value_list_t *vl) vc->ds = ds; vc->time = vl->time; - if (vc->time < cache_oldest) + if ((vc->time < cache_oldest) || (-1 == cache_oldest)) cache_oldest = vc->time; pthread_mutex_unlock (&cache_lock); @@ -611,6 +613,10 @@ static void *us_handle_client (void *arg) { us_handle_listval (fhout, fields, fields_num); } + else if (strcasecmp (fields[0], "putnotif") == 0) + { + handle_putnotif (fhout, fields, fields_num); + } else { fprintf (fhout, "-1 Unknown command: %s\n", fields[0]); @@ -623,6 +629,7 @@ static void *us_handle_client (void *arg) fclose (fhout); pthread_exit ((void *) 0); + return ((void *) 0); } /* void *us_handle_client */ static void *us_server_thread (void *arg) @@ -752,7 +759,6 @@ static int us_shutdown (void) } plugin_unregister_init ("unixsock"); - plugin_unregister_write ("unixsock"); plugin_unregister_shutdown ("unixsock"); return (0);