From: Amos Jeffries Date: Mon, 13 Apr 2015 06:06:15 +0000 (-0700) Subject: Bug 4212: ssl_crtd crashes with corrupt database X-Git-Tag: merge-candidate-3-v1~179 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5c56e0afe413c923167b3ea3e6465399df590aa;p=thirdparty%2Fsquid.git Bug 4212: ssl_crtd crashes with corrupt database 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. --- diff --git a/src/ssl/certificate_db.cc b/src/ssl/certificate_db.cc index 7be669f006..75e9e127ca 100644 --- a/src/ssl/certificate_db.cc +++ b/src/ssl/certificate_db.cc @@ -57,8 +57,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); } @@ -73,7 +75,11 @@ void Ssl::Lock::unlock() } #else if (fd != -1) { +#if _SQUID_SOLARIS_ lockf(fd, F_ULOCK, 0); +#else + flock(fd, ULOCK_UN); +#endif close(fd); fd = -1; }