X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_daemon.c;h=dfdd0e371eff1335e4b07a23a496bba8102145f3;hp=eb94e89544adfcf533b1bc79b12c637f173900f5;hb=c8ac254bb3539e089426392187e582462d07ebfe;hpb=05533cafa4222f3962a9ded2ec88f3469a1139a2 diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index eb94e89..dfdd0e3 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -909,6 +909,33 @@ static int handle_request_update (int fd, /* {{{ */ ci = g_tree_lookup (cache_tree, file); if (ci == NULL) /* {{{ */ { + struct stat statbuf; + + memset (&statbuf, 0, sizeof (statbuf)); + status = stat (file, &statbuf); + if (status != 0) + { + pthread_mutex_unlock (&cache_lock); + RRDD_LOG (LOG_ERR, "handle_request_update: stat (%s) failed.", file); + + status = errno; + if (status == ENOENT) + snprintf (answer, sizeof (answer), "-1 No such file: %s", file); + else + snprintf (answer, sizeof (answer), "-1 stat failed with error %i.\n", + status); + RRDD_UPDATE_SEND; + return (0); + } + if (!S_ISREG (statbuf.st_mode)) + { + pthread_mutex_unlock (&cache_lock); + + snprintf (answer, sizeof (answer), "-1 Not a regular file: %s", file); + RRDD_UPDATE_SEND; + return (0); + } + ci = (cache_item_t *) malloc (sizeof (cache_item_t)); if (ci == NULL) {