From f83f764218b45fa99c2e753172be8e566c2d5e1b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 10 Apr 2008 06:53:16 +0000 Subject: [PATCH] * Cygwin compatibility (Cygwin can't upgrade read locks to write locks, it deadlocks when you try to do that). --- src/libstore/local-store.cc | 3 +-- src/libstore/upgrade-schema.cc | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 9d3cea7a0..ea1770fc5 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -49,8 +49,7 @@ LocalStore::LocalStore() checkStoreNotSymlink(); Path globalLockPath = nixDBPath + "/big-lock"; - globalLock = open(globalLockPath.c_str(), O_RDWR | O_CREAT, 0666); - if (globalLock == -1) throw SysError(format("opening file `%1%'") % globalLockPath); + globalLock = openLockFile(globalLockPath.c_str(), true); if (!lockFile(globalLock, ltRead, false)) { printMsg(lvlError, "waiting for the big Nix store lock..."); diff --git a/src/libstore/upgrade-schema.cc b/src/libstore/upgrade-schema.cc index d54e29bd9..450a7c8d0 100644 --- a/src/libstore/upgrade-schema.cc +++ b/src/libstore/upgrade-schema.cc @@ -22,6 +22,11 @@ void LocalStore::upgradeStore12() { #if OLD_DB_COMPAT +#ifdef __CYGWIN__ + /* Cygwin can't upgrade a read lock to a write lock... */ + lockFile(globalLock, ltNone, true); +#endif + if (!lockFile(globalLock, ltWrite, false)) { printMsg(lvlError, "waiting for exclusive access to the Nix store..."); lockFile(globalLock, ltWrite, true);