X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=listati%2FMutexLocking.c;h=cee82da65e5d6ed73cdecf57a23cab7bfaa7436d;hp=1b453154f2a9f51026d8dbb0ab524bebac52a9a4;hb=5c892b68c1d6e6b949457c96442e6b41236a1913;hpb=06661f47754a536098afe2b30cb04469918f2fa3 diff --git a/listati/MutexLocking.c b/listati/MutexLocking.c index 1b45315..cee82da 100644 --- a/listati/MutexLocking.c +++ b/listati/MutexLocking.c @@ -11,24 +11,22 @@ int FindMutex(const char *path_name) /* Function LockMutex: lock mutex using file locking. */ int LockMutex(int fd) { - struct flock lock; /* file lock structure */ - /* set flock structure */ - lock.l_type = F_WRLCK; /* set type: read or write */ - lock.l_whence = SEEK_SET; /* start from the beginning of the file */ - lock.l_start = 0; /* set the start of the locked region */ - lock.l_len = 0; /* set the length of the locked region */ + struct flock lock; /* file lock structure */ + lock.l_type = F_WRLCK; /* set type: read or write */ + lock.l_whence = SEEK_SET; /* start from the beginning of the file */ + lock.l_start = 0; /* set the start of the locked region */ + lock.l_len = 0; /* set the length of the locked region */ /* do locking */ return fcntl(fd, F_SETLKW, &lock); } /* Function UnlockMutex: unlock a file. */ int UnlockMutex(int fd) { - struct flock lock; /* file lock structure */ - /* set flock structure */ - lock.l_type = F_UNLCK; /* set type: unlock */ - lock.l_whence = SEEK_SET; /* start from the beginning of the file */ - lock.l_start = 0; /* set the start of the locked region */ - lock.l_len = 0; /* set the length of the locked region */ + struct flock lock; /* file lock structure */ + lock.l_type = F_UNLCK; /* set type: unlock */ + lock.l_whence = SEEK_SET; /* start from the beginning of the file */ + lock.l_start = 0; /* set the start of the locked region */ + lock.l_len = 0; /* set the length of the locked region */ /* do locking */ return fcntl(fd, F_SETLK, &lock); } @@ -41,12 +39,11 @@ int RemoveMutex(const char *path_name) int ReadMutex(int fd) { int res; - struct flock lock; /* file lock structure */ - /* set flock structure */ - lock.l_type = F_WRLCK; /* set type: unlock */ - lock.l_whence = SEEK_SET; /* start from the beginning of the file */ - lock.l_start = 0; /* set the start of the locked region */ - lock.l_len = 0; /* set the length of the locked region */ + struct flock lock; /* file lock structure */ + lock.l_type = F_WRLCK; /* set type: unlock */ + lock.l_whence = SEEK_SET; /* start from the beginning of the file */ + lock.l_start = 0; /* set the start of the locked region */ + lock.l_len = 0; /* set the length of the locked region */ /* do locking */ if ( (res = fcntl(fd, F_GETLK, &lock)) ) { return res;