summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-05-13 09:38:54 +0000
committerAndrew Tridgell <tridge@samba.org>1998-05-13 09:38:54 +0000
commit31593dd6106cfef78fc88cbe9c831a51f00a4aa6 (patch)
treee40c378e089542410c7a1eddda71c6587df3f5a9 /util.c
parent91eee5946ad6d033303abfe184085c87a283da29 (diff)
downloadrsync-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.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/util.c b/util.c
index bcbd8c1b..7d15a8a6 100644
--- a/util.c
+++ b/util.c
@@ -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;
}