From 1a20f374f1665dd0e71ef6349a2d95ac8c15b340 Mon Sep 17 00:00:00 2001 From: elvis Date: Thu, 5 May 2022 21:13:32 +0200 Subject: [PATCH] fixed lockfile trying to lock already locked file --- lib/api/api.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/api/api.c b/lib/api/api.c index dc619f2..7a35d69 100644 --- a/lib/api/api.c +++ b/lib/api/api.c @@ -837,16 +837,16 @@ int lockFile(const char* pathname) { return -1; } + if(isOpen(pathname, O_LOCK)){ // file is already locked + return 0; + } + int existing = 0; if(isOpen(pathname, 0)){ // file is already open existing = 1; goto _unlockFile; } - if(isOpen(pathname, O_LOCK)){ // file is already locked - return 0; - } - if (openFile(pathname, O_LOCK) == 0) // open the file with the lock return 0;