projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #613 from rubenk/master
[collectd.git]
/
src
/
unixsock.c
diff --git
a/src/unixsock.c
b/src/unixsock.c
index
337978d
..
7e7a1b1
100644
(file)
--- a/
src/unixsock.c
+++ b/
src/unixsock.c
@@
-26,6
+26,7
@@
#include "utils_cmd_flush.h"
#include "utils_cmd_getval.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"
#include "utils_cmd_listval.h"
#include "utils_cmd_putval.h"
#include "utils_cmd_putnotif.h"
@@
-205,6
+206,7
@@
static void *us_handle_client (void *arg)
close (fdin);
close (fdout);
pthread_exit ((void *) 1);
close (fdin);
close (fdout);
pthread_exit ((void *) 1);
+ return ((void *) 1);
}
fhout = fdopen (fdout, "w");
}
fhout = fdopen (fdout, "w");
@@
-216,6
+218,7
@@
static void *us_handle_client (void *arg)
fclose (fhin); /* this closes fdin as well */
close (fdout);
pthread_exit ((void *) 1);
fclose (fhin); /* this closes fdin as well */
close (fdout);
pthread_exit ((void *) 1);
+ return ((void *) 1);
}
/* change output buffer to line buffered mode */
}
/* change output buffer to line buffered mode */
@@
-227,6
+230,7
@@
static void *us_handle_client (void *arg)
fclose (fhin);
fclose (fhout);
pthread_exit ((void *) 1);
fclose (fhin);
fclose (fhout);
pthread_exit ((void *) 1);
+ return ((void *) 0);
}
while (42)
}
while (42)
@@
-240,6
+244,9
@@
static void *us_handle_client (void *arg)
errno = 0;
if (fgets (buffer, sizeof (buffer), fhin) == NULL)
{
errno = 0;
if (fgets (buffer, sizeof (buffer), fhin) == NULL)
{
+ if ((errno == EINTR) || (errno == EAGAIN))
+ continue;
+
if (errno != 0)
{
char errbuf[1024];
if (errno != 0)
{
char errbuf[1024];
@@
-268,12
+275,17
@@
static void *us_handle_client (void *arg)
fclose (fhin);
fclose (fhout);
pthread_exit ((void *) 1);
fclose (fhin);
fclose (fhout);
pthread_exit ((void *) 1);
+ return ((void *) 1);
}
if (strcasecmp (fields[0], "getval") == 0)
{
handle_getval (fhout, buffer);
}
}
if (strcasecmp (fields[0], "getval") == 0)
{
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);
else if (strcasecmp (fields[0], "putval") == 0)
{
handle_putval (fhout, buffer);
@@
-318,6
+330,9
@@
static void *us_server_thread (void __attribute__((unused)) *arg)
pthread_t th;
pthread_attr_t th_attr;
pthread_t th;
pthread_attr_t th_attr;
+ pthread_attr_init (&th_attr);
+ pthread_attr_setdetachstate (&th_attr, PTHREAD_CREATE_DETACHED);
+
if (us_open_socket () != 0)
pthread_exit ((void *) 1);
if (us_open_socket () != 0)
pthread_exit ((void *) 1);
@@
-336,6
+351,7
@@
static void *us_server_thread (void __attribute__((unused)) *arg)
sstrerror (errno, errbuf, sizeof (errbuf)));
close (sock_fd);
sock_fd = -1;
sstrerror (errno, errbuf, sizeof (errbuf)));
close (sock_fd);
sock_fd = -1;
+ pthread_attr_destroy (&th_attr);
pthread_exit ((void *) 1);
}
pthread_exit ((void *) 1);
}
@@
-352,9
+368,6
@@
static void *us_server_thread (void __attribute__((unused)) *arg)
DEBUG ("Spawning child to handle connection on fd #%i", *remote_fd);
DEBUG ("Spawning child to handle connection on fd #%i", *remote_fd);
- pthread_attr_init (&th_attr);
- pthread_attr_setdetachstate (&th_attr, PTHREAD_CREATE_DETACHED);
-
status = plugin_thread_create (&th, &th_attr,
us_handle_client, (void *) remote_fd);
if (status != 0)
status = plugin_thread_create (&th, &th_attr,
us_handle_client, (void *) remote_fd);
if (status != 0)
@@
-370,6
+383,7
@@
static void *us_server_thread (void __attribute__((unused)) *arg)
close (sock_fd);
sock_fd = -1;
close (sock_fd);
sock_fd = -1;
+ pthread_attr_destroy (&th_attr);
status = unlink ((sock_file != NULL) ? sock_file : US_DEFAULT_PATH);
if (status != 0)
status = unlink ((sock_file != NULL) ? sock_file : US_DEFAULT_PATH);
if (status != 0)