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
8ebb3196
Commit
8ebb3196
authored
Jan 03, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
listen: use GLib instead of utils.h
parent
30f75f7f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
20 deletions
+21
-20
listen.c
src/listen.c
+21
-4
utils.c
src/utils.c
+0
-14
utils.h
src/utils.h
+0
-2
No files found.
src/listen.c
View file @
8ebb3196
...
...
@@ -26,6 +26,9 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#ifdef WIN32
#include <ws2tcpip.h>
...
...
@@ -89,8 +92,8 @@ static int establishListen(int pf, const struct sockaddr *addrp,
#endif
numberOfListenSockets
++
;
listenSockets
=
xrealloc
(
listenSockets
,
sizeof
(
int
)
*
numberOfListenSockets
);
listenSockets
=
g_realloc
(
listenSockets
,
sizeof
(
listenSockets
[
0
])
*
numberOfListenSockets
);
listenSockets
[
numberOfListenSockets
-
1
]
=
sock
;
...
...
@@ -102,6 +105,20 @@ static int establishListen(int pf, const struct sockaddr *addrp,
return
0
;
}
static
bool
ipv6Supported
(
void
)
{
#ifdef HAVE_IPV6
int
s
;
s
=
socket
(
AF_INET6
,
SOCK_STREAM
,
0
);
if
(
s
==
-
1
)
return
false
;
close
(
s
);
return
true
;
#else
return
false
;
#endif
}
static
void
parseListenConfigParam
(
G_GNUC_UNUSED
unsigned
int
port
,
ConfigParam
*
param
)
{
...
...
@@ -190,7 +207,7 @@ parseListenConfigParam(G_GNUC_UNUSED unsigned int port, ConfigParam * param)
hints
.
ai_socktype
=
SOCK_STREAM
;
hints
.
ai_protocol
=
IPPROTO_TCP
;
snprintf
(
service
,
sizeof
(
service
),
"%u"
,
port
);
g_
snprintf
(
service
,
sizeof
(
service
),
"%u"
,
port
);
ret
=
getaddrinfo
(
param
->
value
,
service
,
&
hints
,
&
ai
);
if
(
ret
!=
0
)
...
...
@@ -262,7 +279,7 @@ void closeAllListenSockets(void)
}
numberOfListenSockets
=
0
;
free
(
listenSockets
);
g_
free
(
listenSockets
);
listenSockets
=
NULL
;
}
...
...
src/utils.c
View file @
8ebb3196
...
...
@@ -61,20 +61,6 @@ void my_usleep(long usec)
#endif
}
int
ipv6Supported
(
void
)
{
#ifdef HAVE_IPV6
int
s
;
s
=
socket
(
AF_INET6
,
SOCK_STREAM
,
0
);
if
(
s
==
-
1
)
return
0
;
close
(
s
);
return
1
;
#else
return
0
;
#endif
}
G_GNUC_MALLOC
char
*
xstrdup
(
const
char
*
s
)
{
char
*
ret
=
strdup
(
s
);
...
...
src/utils.h
View file @
8ebb3196
...
...
@@ -40,8 +40,6 @@ void stripReturnChar(char *string);
void
my_usleep
(
long
usec
);
int
ipv6Supported
(
void
);
/* trivial functions, keep them inlined */
static
inline
void
xclose
(
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