From 84c2364ba3f62b218a1e96ec8d07e4e45ea2335b Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Tue, 14 Apr 2015 00:36:15 -0700 Subject: [PATCH] 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. --- src/ssl/certificate_db.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ssl/certificate_db.cc b/src/ssl/certificate_db.cc index 5d4e6cffd2..05e67b5526 100644 --- a/src/ssl/certificate_db.cc +++ b/src/ssl/certificate_db.cc @@ -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; } -- 2.47.2