separate a failure to open versus failure to lock. Quiets coverity because close can't handle a negative value

This commit is contained in:
Isaac Connor 2016-03-24 10:00:02 -04:00
parent 1e52a8ad2c
commit a16c1746e5
1 changed files with 6 additions and 1 deletions

View File

@ -294,7 +294,12 @@ void StreamBase::openComms()
snprintf( sock_path_lock, sizeof(sock_path_lock), "%s/zms-%06d.lock", config.path_socks, connkey);
lock_fd = open(sock_path_lock, O_CREAT|O_WRONLY, S_IRUSR | S_IWUSR);
if (lock_fd <= 0 || flock(lock_fd, LOCK_EX) != 0)
if ( lock_fd <= 0 )
{
Error("Unable to open sock lock file %s: %s", sock_path_lock, strerror(errno) );
lock_fd = 0;
}
else if ( flock(lock_fd, LOCK_EX) != 0 )
{
Error("Unable to lock sock lock file %s: %s", sock_path_lock, strerror(errno) );