diff options
author | Wayne Davison <wayned@samba.org> | 2007-09-18 14:11:25 +0000 |
---|---|---|
committer | Wayne Davison <wayned@samba.org> | 2007-09-18 14:11:25 +0000 |
commit | 236df01b15447f5c72b15c2d45496e2ec73cf951 (patch) | |
tree | e204f732d3c1ee7e2ee1a9e7319b5243b1ab29c5 /connection.c | |
parent | 21cafc50cc4d10b42f6e81963171ab0cdacec2f6 (diff) | |
download | rsync-236df01b15447f5c72b15c2d45496e2ec73cf951.tar.gz rsync-236df01b15447f5c72b15c2d45496e2ec73cf951.tar.bz2 rsync-236df01b15447f5c72b15c2d45496e2ec73cf951.zip |
One final tweak.
Diffstat (limited to 'connection.c')
-rw-r--r-- | connection.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/connection.c b/connection.c index beb1dec6..5e37fe24 100644 --- a/connection.c +++ b/connection.c @@ -26,19 +26,20 @@ int claim_connection(char *fname, int max_connections) { int fd, i; - if (max_connections > 0) { - if ((fd = open(fname, O_RDWR|O_CREAT, 0600)) < 0) - return 0; + if (max_connections <= 0) + return 1; - /* Find a free spot. */ - for (i = 0; i < max_connections; i++) { - if (lock_range(fd, i*4, 4)) - return 1; - } + if ((fd = open(fname, O_RDWR|O_CREAT, 0600)) < 0) + return 0; - close(fd); + /* Find a free spot. */ + for (i = 0; i < max_connections; i++) { + if (lock_range(fd, i*4, 4)) + return 1; } + close(fd); + /* A lock failure needs to return an errno of 0. */ errno = 0; return 0; |