use exclusive lock, add includes
This commit is contained in:
parent
e637915823
commit
be36301779
|
@ -18,6 +18,10 @@
|
|||
//
|
||||
|
||||
#include <sys/un.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/file.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue