From c28b30b86e9b71911cc5c10d40661725cdf25ee9 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Wed, 23 May 2012 22:57:36 +0200 Subject: [PATCH] added comments in lockfile handling section --- BasicsC/files.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/BasicsC/files.c b/BasicsC/files.c index 91ee0ae707..806f0e34bf 100644 --- a/BasicsC/files.c +++ b/BasicsC/files.c @@ -672,6 +672,7 @@ int TRI_CreateLockFile (char const* filename) { pid = TRI_CurrentProcessId(); buf = TRI_StringUInt32(pid); + // TODO: buf might be NULL rv = TRI_WRITE(fd, buf, strlen(buf)); @@ -690,6 +691,8 @@ int TRI_CreateLockFile (char const* filename) { TRI_CLOSE(fd); fd = TRI_OPEN(filename, O_RDONLY); + // TODO: return value of fd is not checked + rv = flock(fd, LOCK_EX); if (rv == -1) { // file may be locked already @@ -701,9 +704,10 @@ int TRI_CreateLockFile (char const* filename) { return TRI_errno(); } - // close(fd); file descriptor has to be valid for file locking + // TODO: fd is never closed from here on, resource is lost fn = TRI_DuplicateString(filename); + // TODO: fn might be NULL TRI_WriteLockReadWriteLock(&LockFileNames); TRI_PushBackVectorString(&FileNames, fn);