In fileLock, take in account the case where the file cannot be opened

overity issue 23352
This commit is contained in:
Jean-Marc Lasgouttes 2015-09-12 23:49:32 +02:00
parent c71b4cc896
commit 1e4adc512e

View File

@ -1219,14 +1219,17 @@ int fileLock(const char * lock_file)
int fd = -1;
#if defined(HAVE_LOCKF)
fd = open(lock_file, O_CREAT|O_APPEND|O_SYNC|O_RDWR, 0666);
if (fd == -1)
return -1;
if (lockf(fd, F_LOCK, 0) != 0) {
close(fd);
return(-1);
return -1;
}
#endif
return(fd);
return fd;
}
void fileUnlock(int fd, const char * /* lock_file*/)
{
#if defined(HAVE_LOCKF)