]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 4212: ssl_crtd crashes with corrupt database
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 14 Apr 2015 07:36:15 +0000 (00:36 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 14 Apr 2015 07:36:15 +0000 (00:36 -0700)
The fix for Bug 3664 "ssl_crtd fails to build on OpenSolaris/OpenIndiana/Solaris 11"
introduced a regression on BSD and Linux where lockf() implementations appear not to
lock the entire file correctly or as reliably as flock().

Reverting the flock/lockf change for non-Solaris OS.

src/ssl/certificate_db.cc

index 5d4e6cffd275190098fd4c57f4d0be6f95b3f177..05e67b5526e40284c3238dc18a24cdf090846006 100644 (file)
@@ -54,8 +54,10 @@ void Ssl::Lock::lock()
 
 #if _SQUID_WINDOWS_
     if (!LockFile(hFile, 0, 0, 1, 0))
-#else
+#elif _SQUID_SOLARIS_
     if (lockf(fd, F_LOCK, 0) != 0)
+#else
+    if (flock(fd, LOCK_EX) != 0)
 #endif
         throw std::runtime_error("Failed to get a lock of " + filename);
 }
@@ -70,7 +72,11 @@ void Ssl::Lock::unlock()
     }
 #else
     if (fd != -1) {
+#if _SQUID_SOLARIS_
         lockf(fd, F_ULOCK, 0);
+#else
+        flock(fd, LOCK_UN);
+#endif
         close(fd);
         fd = -1;
     }