------------------------------------------------------------ revno: 13797 revision-id: squid3@treenet.co.nz-20150414072612-qlkr1vgfdst4m2tv parent: squid3@treenet.co.nz-20150414072032-qphq1wh0zyizb4ra fixes bug: http://bugs.squid-cache.org/show_bug.cgi?id=4212 committer: Amos Jeffries branch nick: 3.5 timestamp: Tue 2015-04-14 00:26:12 -0700 message: 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. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20150414072612-qlkr1vgfdst4m2tv # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # testament_sha1: 303ef25bb7866e36738129652edacc1184bdd12d # timestamp: 2015-04-14 07:35:41 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # base_revision_id: squid3@treenet.co.nz-20150414072032-\ # qphq1wh0zyizb4ra # # Begin patch === modified file 'src/ssl/certificate_db.cc' --- src/ssl/certificate_db.cc 2015-01-13 09:13:49 +0000 +++ src/ssl/certificate_db.cc 2015-04-14 07:26:12 +0000 @@ -57,8 +57,10 @@ #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 @@ } #else if (fd != -1) { +#if _SQUID_SOLARIS_ lockf(fd, F_ULOCK, 0); +#else + flock(fd, LOCK_UN); +#endif close(fd); fd = -1; }