X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_update.c;h=62c8c3b4c50a91c776f10a2e676d76a8db2a5ca2;hb=4d7e379201b4cf3dbdad103d691ca7d2724ade2f;hp=9d3e85466b00271daf4f34a3badb4d9cda5f2b9b;hpb=a12627275ff8487174cbb907a066f62a00b6ae44;p=rrdtool.git diff --git a/src/rrd_update.c b/src/rrd_update.c index 9d3e854..62c8c3b 100644 --- a/src/rrd_update.c +++ b/src/rrd_update.c @@ -450,13 +450,9 @@ int rrd_update( rc = rrdc_update (argv[optind], /* file */ argc - optind - 1, /* values_num */ (void *) (argv + optind + 1)); /* values */ - if (rc != 0) - { + if (rc > 0) rrd_set_error("Failed sending the values to rrdcached: %s", - (rc < 0) - ? "Internal error" - : rrd_strerror (rc)); - } + rrd_strerror (rc)); } out: @@ -523,6 +519,7 @@ int _rrd_update( goto err_out; } + rrd_init(&rrd); if ((rrd_file = rrd_open(filename, &rrd, RRD_READWRITE)) == NULL) { goto err_free; } @@ -621,41 +618,6 @@ int _rrd_update( } /* - * get exclusive lock to whole file. - * lock gets removed when we close the file - * - * returns 0 on success - */ -int rrd_lock( - rrd_file_t *file) -{ - int rcstat; - - { -#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) - struct _stat st; - - if (_fstat(file->fd, &st) == 0) { - rcstat = _locking(file->fd, _LK_NBLCK, st.st_size); - } else { - rcstat = -1; - } -#else - struct flock lock; - - lock.l_type = F_WRLCK; /* exclusive write lock */ - lock.l_len = 0; /* whole file */ - lock.l_start = 0; /* start of file */ - lock.l_whence = SEEK_SET; /* end of file */ - - rcstat = fcntl(file->fd, F_SETLK, &lock); -#endif - } - - return (rcstat); -} - -/* * Allocate some important arrays used, and initialize the template. * * When it returns, either all of the structures are allocated