summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-07-24 14:12:59 +0300
committerTimo Teras <timo.teras@iki.fi>2009-07-24 14:12:59 +0300
commit195859b3fd35819b218336f0bdd87eaa55778d56 (patch)
tree6ed5a37b1db4696b4c873a36bfc6d20c83a1f949 /src
parent8e66768cd2bbc39c79875971dd82289fd7be7130 (diff)
downloadapk-tools-195859b3fd35819b218336f0bdd87eaa55778d56.tar.gz
apk-tools-195859b3fd35819b218336f0bdd87eaa55778d56.tar.bz2
apk-tools-195859b3fd35819b218336f0bdd87eaa55778d56.tar.xz
apk-tools-195859b3fd35819b218336f0bdd87eaa55778d56.zip
db: fix repository write locking
Diffstat (limited to 'src')
-rw-r--r--src/database.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/database.c b/src/database.c
index 57cae9d..720b7b0 100644
--- a/src/database.c
+++ b/src/database.c
@@ -872,6 +872,7 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags)
}
if (db->lock_fd < 0 ||
flock(db->lock_fd, LOCK_EX | LOCK_NB) < 0) {
+ msg = "Unable to lock database";
if (apk_wait) {
struct sigaction sa, old_sa;
@@ -882,14 +883,13 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags)
sigaction(SIGALRM, &sa, &old_sa);
alarm(apk_wait);
- if (flock(db->lock_fd, LOCK_EX) < 0) {
- msg = "Unable to lock database";
+ if (flock(db->lock_fd, LOCK_EX) < 0)
goto ret_errno;
- }
alarm(0);
sigaction(SIGALRM, &old_sa, NULL);
- }
+ } else
+ goto ret_errno;
}
}
}