diff --git a/src/zm_stream.cpp b/src/zm_stream.cpp index 4e9a4da10..f50671338 100644 --- a/src/zm_stream.cpp +++ b/src/zm_stream.cpp @@ -18,6 +18,10 @@ // #include +#include +#include +#include +#include #include "zm.h" #include "zm_mpeg.h" @@ -290,7 +294,7 @@ 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_SH|LOCK_NB) != 0) + if (lock_fd <= 0 || flock(lock_fd, LOCK_EX) != 0) { Error("Unable to lock sock lock file %s: %s", sock_path_lock, strerror(errno) ); @@ -299,7 +303,7 @@ void StreamBase::openComms() } else { - Debug( 1, "We have obtained a read lock on %s fd: %d", sock_path_lock, lock_fd); + Debug( 1, "We have obtained a lock on %s fd: %d", sock_path_lock, lock_fd); }