X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Funixsock.c;h=897ebfc5aef8df149a18e131d1b8b0d3b2b1587b;hb=6108316e4008edce45c6d861b49e339c1360181f;hp=8b2f33914eacc3307fbc7d1b28c9c5fe032b3c74;hpb=c1219a1c9db2e8400e2ee94b87f86ccd441485d5;p=collectd.git diff --git a/src/unixsock.c b/src/unixsock.c index 8b2f3391..897ebfc5 100644 --- a/src/unixsock.c +++ b/src/unixsock.c @@ -2,38 +2,40 @@ * collectd - src/unixsock.c * 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 - * Free Software Foundation; only version 2 of the License is applicable. + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. * - * Author: - * Florian octo Forster + * Authors: + * Florian octo Forster **/ #include "collectd.h" + #include "common.h" #include "plugin.h" -#include "configfile.h" #include "utils_cmd_flush.h" #include "utils_cmd_getval.h" +#include "utils_cmd_getthreshold.h" #include "utils_cmd_listval.h" #include "utils_cmd_putval.h" #include "utils_cmd_putnotif.h" -/* Folks without pthread will need to disable this plugin. */ -#include - -#include #include #include @@ -74,7 +76,7 @@ static pthread_t listen_thread = (pthread_t) 0; */ static int us_open_socket (void) { - struct sockaddr_un sa; + struct sockaddr_un sa = { 0 }; int status; sock_fd = socket (PF_UNIX, SOCK_STREAM, 0); @@ -86,7 +88,6 @@ static int us_open_socket (void) return (-1); } - memset (&sa, '\0', sizeof (sa)); sa.sun_family = AF_UNIX; sstrncpy (sa.sun_path, (sock_file != NULL) ? sock_file : US_DEFAULT_PATH, sizeof (sa.sun_path)); @@ -146,7 +147,7 @@ static int us_open_socket (void) do { - char *grpname; + const char *grpname; struct group *g; struct group sg; char grbuf[2048]; @@ -290,13 +291,17 @@ static void *us_handle_client (void *arg) { handle_getval (fhout, buffer); } + else if (strcasecmp (fields[0], "getthreshold") == 0) + { + handle_getthreshold (fhout, buffer); + } else if (strcasecmp (fields[0], "putval") == 0) { - handle_putval (fhout, buffer); + cmd_handle_putval (fhout, buffer); } else if (strcasecmp (fields[0], "listval") == 0) { - handle_listval (fhout, buffer); + cmd_handle_listval (fhout, buffer); } else if (strcasecmp (fields[0], "putnotif") == 0) { @@ -304,7 +309,7 @@ static void *us_handle_client (void *arg) } else if (strcasecmp (fields[0], "flush") == 0) { - handle_flush (fhout, buffer); + cmd_handle_flush (fhout, buffer); } else { @@ -359,7 +364,7 @@ static void *us_server_thread (void __attribute__((unused)) *arg) pthread_exit ((void *) 1); } - remote_fd = (int *) malloc (sizeof (int)); + remote_fd = malloc (sizeof (*remote_fd)); if (remote_fd == NULL) { char errbuf[1024];