Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
ed2165ba
Commit
ed2165ba
authored
Feb 10, 2016
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use explicit functions for creating and destroying local sockets.
parent
dcd1dba6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
6 deletions
+31
-6
babeld.c
babeld.c
+5
-6
local.c
local.c
+24
-0
local.h
local.h
+2
-0
No files found.
babeld.c
View file @
ed2165ba
...
...
@@ -681,13 +681,11 @@ main(int argc, char **argv)
rc
=
local_read
(
&
local_sockets
[
i
]);
if
(
rc
<=
0
)
{
if
(
rc
<
0
)
{
if
(
errno
==
EINTR
)
if
(
errno
==
EINTR
||
errno
==
EAGAIN
)
continue
;
perror
(
"read(local_socket)"
);
}
close
(
local_sockets
[
i
].
fd
);
local_sockets
[
i
]
=
local_sockets
[
--
num_local_sockets
];
continue
;
local_socket_destroy
(
i
);
}
}
i
++
;
...
...
@@ -881,6 +879,7 @@ static int
accept_local_connections
(
fd_set
*
readfds
)
{
int
rc
,
s
;
struct
local_socket
*
ls
;
if
(
local_server_socket
<
0
||
!
FD_ISSET
(
local_server_socket
,
readfds
))
return
0
;
...
...
@@ -917,8 +916,8 @@ accept_local_connections(fd_set *readfds)
return
-
1
;
}
l
ocal_sockets
[
num_local_sockets
++
].
fd
=
s
;
local_notify_all_1
(
&
local_sockets
[
num_local_sockets
-
1
]
);
l
s
=
local_socket_create
(
s
)
;
local_notify_all_1
(
ls
);
return
1
;
}
...
...
local.c
View file @
ed2165ba
...
...
@@ -321,4 +321,28 @@ local_notify_all_1(struct local_socket *s)
return
;
}
struct
local_socket
*
local_socket_create
(
int
fd
)
{
if
(
num_local_sockets
>=
MAX_LOCAL_SOCKETS
)
return
NULL
;
local_sockets
[
num_local_sockets
].
fd
=
fd
;
num_local_sockets
++
;
return
&
local_sockets
[
num_local_sockets
-
1
];
}
void
local_socket_destroy
(
int
i
)
{
if
(
i
<
0
||
i
>=
num_local_sockets
)
{
fprintf
(
stderr
,
"Internal error: closing unknown local socket.
\n
"
);
return
;
}
close
(
local_sockets
[
i
].
fd
);
local_sockets
[
i
]
=
local_sockets
[
--
num_local_sockets
];
}
#endif
local.h
View file @
ed2165ba
...
...
@@ -48,6 +48,8 @@ void local_notify_neighbour(struct neighbour *neigh, int kind);
void
local_notify_xroute
(
struct
xroute
*
xroute
,
int
kind
);
void
local_notify_route
(
struct
babel_route
*
route
,
int
kind
);
void
local_notify_all_1
(
struct
local_socket
*
s
);
struct
local_socket
*
local_socket_create
(
int
fd
);
void
local_socket_destroy
(
int
i
);
#else
...
...
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