Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liblongpath-rsync
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liblongpath
liblongpath-rsync
Commits
21cafc50
Commit
21cafc50
authored
Sep 18, 2007
by
Wayne Davison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some minor improvements in claim_connection().
parent
de80679b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
17 deletions
+14
-17
connection.c
connection.c
+14
-17
No files found.
connection.c
View file @
21cafc50
...
@@ -19,30 +19,27 @@
...
@@ -19,30 +19,27 @@
#include "rsync.h"
#include "rsync.h"
/*
***************************************************************************
/*
A simple routine to do connection counting. This returns 1 on success
simple routine to do connection counting
* and 0 on failure, with errno also being set if the open() failed (errno
***************************************************************************
*/
* will be 0 if the lock request failed).
*/
int
claim_connection
(
char
*
fname
,
int
max_connections
)
int
claim_connection
(
char
*
fname
,
int
max_connections
)
{
{
int
fd
,
i
;
int
fd
,
i
;
if
(
max_connections
<=
0
)
if
(
max_connections
>
0
)
{
return
1
;
if
((
fd
=
open
(
fname
,
O_RDWR
|
O_CREAT
,
0600
))
<
0
)
return
0
;
fd
=
open
(
fname
,
O_RDWR
|
O_CREAT
,
0600
);
/* Find a free spot. */
for
(
i
=
0
;
i
<
max_connections
;
i
++
)
{
if
(
lock_range
(
fd
,
i
*
4
,
4
))
return
1
;
}
if
(
fd
==
-
1
)
{
close
(
fd
);
return
0
;
}
}
/* find a free spot */
/* A lock failure needs to return an errno of 0. */
for
(
i
=
0
;
i
<
max_connections
;
i
++
)
{
if
(
lock_range
(
fd
,
i
*
4
,
4
))
return
1
;
}
/* only interested in open failures */
errno
=
0
;
errno
=
0
;
close
(
fd
);
return
0
;
return
0
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment