#! /bin/sh /usr/share/dpatch/dpatch-run
## debian/patches/bts619123_fix_unresolvable_symlink.dpatch
##
## DP: collectd is hanging in an endless loop (consuming CPU time) if
## DP: /var/lib/collectd/rrd is a symlink, pointing to a mountpoint that's
## DP: not available.
## DP:
## DP: Fixes bugreport by Michael Prokop, patch by Jonathan Nieder
## DP: taken from Debian's bugreport for testing in Sipwise's setup.
## DP: See <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=619123>
## DP: for details.

@DPATCH@

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
