X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Flibrrdc.c;h=1a21260c6b052bf48de29d1f6b010d025e4d00fd;hb=1bbaed0ca88432568a6ae9f9d643aa3a27bf9a01;hp=25d0afab0c92165acecdfde5743a9295bedb0b4d;hpb=beb7e531b4a534959296d113341672b39755a867;p=rrdd.git diff --git a/src/librrdc.c b/src/librrdc.c index 25d0afa..1a21260 100644 --- a/src/librrdc.c +++ b/src/librrdc.c @@ -22,8 +22,6 @@ #include "rrdd.h" #include "rrdc.h" -#define SOCK_TEMPLATE "/tmp/rrdc.sock.XXXXXX" - static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; static int sd; static FILE *sh; @@ -155,14 +153,29 @@ int rrdd_update (const char *filename, int values_num, if (sh == NULL) { pthread_mutex_unlock (&lock); - return (-1); + return (ENOTCONN); } status = write (sd, buffer, sizeof (buffer) - buffer_size); + status = read (sd, buffer, sizeof (buffer)); + if (status < 0) + { + status = errno; + pthread_mutex_unlock (&lock); + return (status); + } + else if (status == 0) + { + pthread_mutex_unlock (&lock); + return (ENODATA); + } + + status = atoi (buffer); + pthread_mutex_unlock (&lock); - return (0); + return (status); } /* int rrd_update_daemon */ /*