diff options
author | Andrew Tridgell <tridge@samba.org> | 1998-05-13 09:38:54 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1998-05-13 09:38:54 +0000 |
commit | 31593dd6106cfef78fc88cbe9c831a51f00a4aa6 (patch) | |
tree | e40c378e089542410c7a1eddda71c6587df3f5a9 /util.c | |
parent | 91eee5946ad6d033303abfe184085c87a283da29 (diff) | |
download | rsync-31593dd6106cfef78fc88cbe9c831a51f00a4aa6.tar.gz rsync-31593dd6106cfef78fc88cbe9c831a51f00a4aa6.tar.bz2 rsync-31593dd6106cfef78fc88cbe9c831a51f00a4aa6.zip |
improved max connections code. Now use fcntl instead of flock.
also started on authentication code (I'm doing a challenge response
system initially)
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -491,12 +491,16 @@ int process_exists(int pid) return(kill(pid,0) == 0 || errno != ESRCH); } -int lock_file(int fd) +/* lock a byte range in a open file */ +int lock_range(int fd, int offset, int len) { - return flock(fd, LOCK_EX) == 0; -} + struct flock lock; -int unlock_file(int fd) -{ - return flock(fd, LOCK_UN) == 0; + lock.l_type = F_WRLCK; + lock.l_whence = SEEK_SET; + lock.l_start = offset; + lock.l_len = len; + lock.l_pid = 0; + + return fcntl(fd,F_SETLK,&lock) == 0; } |