add safeguard against infinite loop with EINTR, even if that case is very unlikely
authorGerd von Egidy <gerd.von.egidy@intra2net.com>
Wed, 16 Dec 2015 14:33:09 +0000 (15:33 +0100)
committerGerd von Egidy <gerd.von.egidy@intra2net.com>
Wed, 16 Dec 2015 14:33:09 +0000 (15:33 +0100)
src/filefunc.cpp

index 6f07011..3a7f7c1 100644 (file)
@@ -968,8 +968,10 @@ long long get_free_diskspace(const std::string& path)
 {
     struct statvfs sf;
 
+    int looplimit=10000;
     int ret;
-    while ( ((ret=statvfs(path.c_str(),&sf)) == -1) && (errno==EINTR) );
+    while ( ((ret=statvfs(path.c_str(),&sf)) == -1) && (errno==EINTR) && looplimit > 0)
+        looplimit--;
 
     if (ret==-1)
     {