From a16c1746e52926a44be80552d5f7c89121853ae3 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 24 Mar 2016 10:00:02 -0400 Subject: [PATCH] separate a failure to open versus failure to lock. Quiets coverity because close can't handle a negative value --- src/zm_stream.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/zm_stream.cpp b/src/zm_stream.cpp index c66638759..77c94e68c 100644 --- a/src/zm_stream.cpp +++ b/src/zm_stream.cpp @@ -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) );