found 619123 collectd/4.10.1-2.1
quit

Hi Mika,

Michael Prokop wrote:

> collectd is hanging in an endless loop (consuming CPU time) if
> /var/lib/collectd/rrd is a symlink, pointing to a mountpoint that's
> not available:
>
> # strace -f -p $PID_OF_COLLECTD
> [...]
> [pid  1033] mkdir("/var/lib/collectd/rrd", 0755) = -1 EEXIST (File exists)
> [pid  1033] stat("/var/lib/collectd/rrd", 0x7f7f08f28440) = -1 ENOENT (No 
> such file or directory)
> [pid  1033] mkdir("/var/lib/collectd/rrd", 0755) = -1 EEXIST (File exists)
[...]

Yes, I can reproduce this.

The cause is in src/common.c:

                while (42) {
                        if (stat (dir, &statbuf) == -1)
                        {
                                if (errno == ENOENT)
                                {
                                        if (mkdir (dir, 0755) == 0)
                                                break;

                                        /* this might happen, if a different 
thread created
                                         * the directory in the meantime
                                         * => call stat() again to check for 
S_ISDIR() */
                                        if (EEXIST == errno)
                                                continue;

As you say, errno can be EEXIST because the directory entry is a symlink,
rather than the directory already having been made, which would let this loop
forever.

Minimal patch (untested):

 src/common.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/common.c b/src/common.c
index 2598036d..d88b97e7 100644
--- a/src/common.c
+++ b/src/common.c
@@ -542,7 +542,7 @@ int check_create_dir (const char *file_orig)
                }
 
                while (42) {
-                       if (stat (dir, &statbuf) == -1)
+                       if (stat (dir, &statbuf) == -1 && lstat (dir, &statbuf) 
== -1)
                        {
                                if (errno == ENOENT)
                                {
-- 
1.7.8.2




-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to