Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
d60cf67d
Commit
d60cf67d
authored
Jan 10, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
listen: added struct listen_socket
Make the listen socket an object, allowing us to add more fields later. Convert listenSockets into a simple linked list.
parent
a673d6be
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
16 deletions
+19
-16
listen.c
src/listen.c
+19
-16
No files found.
src/listen.c
View file @
d60cf67d
...
...
@@ -54,8 +54,13 @@
port, strerror(errno)); \
} while (0);
static
int
*
listenSockets
;
static
int
numberOfListenSockets
;
struct
listen_socket
{
struct
listen_socket
*
next
;
int
fd
;
};
static
struct
listen_socket
*
listen_sockets
;
int
boundPort
;
static
gboolean
...
...
@@ -69,6 +74,7 @@ static int establishListen(int pf, const struct sockaddr *addrp,
#ifdef HAVE_STRUCT_UCRED
int
passcred
=
1
;
#endif
struct
listen_socket
*
ls
;
GIOChannel
*
channel
;
if
((
sock
=
socket
(
pf
,
SOCK_STREAM
,
0
))
<
0
)
...
...
@@ -91,17 +97,17 @@ static int establishListen(int pf, const struct sockaddr *addrp,
setsockopt
(
sock
,
SOL_SOCKET
,
SO_PASSCRED
,
&
passcred
,
sizeof
(
passcred
));
#endif
numberOfListenSockets
++
;
listenSockets
=
g_realloc
(
listenSockets
,
sizeof
(
listenSockets
[
0
])
*
numberOfListenSockets
);
listenSockets
[
numberOfListenSockets
-
1
]
=
sock
;
ls
=
g_new
(
struct
listen_socket
,
1
);
ls
->
fd
=
sock
;
channel
=
g_io_channel_unix_new
(
sock
);
g_io_add_watch
(
channel
,
G_IO_IN
,
listen_in_event
,
GINT_TO_POINTER
(
sock
));
g_io_channel_unref
(
channel
);
ls
->
next
=
listen_sockets
;
listen_sockets
=
ls
;
return
0
;
}
...
...
@@ -269,18 +275,15 @@ void listenOnPort(void)
void
closeAllListenSockets
(
void
)
{
int
i
;
g_debug
(
"closeAllListenSockets called"
);
for
(
i
=
0
;
i
<
numberOfListenSockets
;
i
++
)
{
g_debug
(
"closing listen socket %i"
,
i
);
while
(
close
(
listenSockets
[
i
])
<
0
&&
errno
==
EINTR
)
;
}
while
(
listen_sockets
!=
NULL
)
{
struct
listen_socket
*
ls
=
listen_sockets
;
listen_sockets
=
ls
->
next
;
numberOfListenSockets
=
0
;
g_free
(
listenSocket
s
);
listenSockets
=
NULL
;
close
(
ls
->
fd
)
;
g_free
(
l
s
);
}
}
static
int
get_remote_uid
(
int
fd
)
...
...
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