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
c476819c
Commit
c476819c
authored
Sep 19, 2011
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fd_util: add function close_socket()
Wrap close(), use closesocket() on WIN32/WinSock.
parent
77a56c7c
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
8 deletions
+26
-8
NEWS
NEWS
+1
-0
client_new.c
src/client_new.c
+3
-2
fd_util.c
src/fd_util.c
+10
-0
fd_util.h
src/fd_util.h
+6
-0
httpd_output_plugin.c
src/output/httpd_output_plugin.c
+2
-2
server_socket.c
src/server_socket.c
+1
-1
socket_util.c
src/socket_util.c
+3
-3
No files found.
NEWS
View file @
c476819c
...
...
@@ -9,6 +9,7 @@ ver 0.16.5 (2010/??/??)
* decoder:
- ffmpeg: higher precision timestamps
- ffmpeg: don't require key frame for seeking
* WIN32: close sockets properly
ver 0.16.4 (2011/09/01)
...
...
src/client_new.c
View file @
c476819c
...
...
@@ -19,6 +19,7 @@
#include "config.h"
#include "client_internal.h"
#include "fd_util.h"
#include "fifo_buffer.h"
#include "socket_util.h"
#include "permission.h"
...
...
@@ -67,7 +68,7 @@ void client_new(int fd, const struct sockaddr *sa, size_t sa_length, int uid)
progname
,
hostaddr
);
g_free
(
hostaddr
);
close
(
fd
);
close
_socket
(
fd
);
return
;
}
...
...
@@ -77,7 +78,7 @@ void client_new(int fd, const struct sockaddr *sa, size_t sa_length, int uid)
if
(
client_list_is_full
())
{
g_warning
(
"Max Connections Reached!"
);
close
(
fd
);
close
_socket
(
fd
);
return
;
}
...
...
src/fd_util.c
View file @
c476819c
...
...
@@ -304,3 +304,13 @@ inotify_init_cloexec(void)
}
#endif
int
close_socket
(
int
fd
)
{
#ifdef WIN32
return
closesocket
(
fd
);
#else
return
close
(
fd
);
#endif
}
src/fd_util.h
View file @
c476819c
...
...
@@ -133,4 +133,10 @@ inotify_init_cloexec(void);
#endif
/**
* Portable wrapper for close(); use closesocket() on WIN32/WinSock.
*/
int
close_socket
(
int
fd
);
#endif
src/output/httpd_output_plugin.c
View file @
c476819c
...
...
@@ -201,7 +201,7 @@ httpd_listen_in_event(int fd, const struct sockaddr *address,
g_warning
(
"libwrap refused connection (libwrap=%s) from %s"
,
progname
,
hostaddr
);
g_free
(
hostaddr
);
close
(
fd
);
close
_socket
(
fd
);
g_mutex_unlock
(
httpd
->
mutex
);
return
;
}
...
...
@@ -222,7 +222,7 @@ httpd_listen_in_event(int fd, const struct sockaddr *address,
httpd
->
clients_cnt
<
httpd
->
clients_max
))
httpd_client_add
(
httpd
,
fd
);
else
close
(
fd
);
close
_socket
(
fd
);
}
else
if
(
fd
<
0
&&
errno
!=
EINTR
)
{
g_warning
(
"accept() failed: %s"
,
g_strerror
(
errno
));
}
...
...
src/server_socket.c
View file @
c476819c
...
...
@@ -253,7 +253,7 @@ server_socket_close(struct server_socket *ss)
continue
;
g_source_remove
(
s
->
source_id
);
close
(
s
->
fd
);
close
_socket
(
s
->
fd
);
s
->
fd
=
-
1
;
}
}
...
...
src/socket_util.c
View file @
c476819c
...
...
@@ -122,7 +122,7 @@ socket_bind_listen(int domain, int type, int protocol,
if
(
ret
<
0
)
{
g_set_error
(
error
,
listen_quark
(),
errno
,
"setsockopt() failed: %s"
,
g_strerror
(
errno
));
close
(
fd
);
close
_socket
(
fd
);
return
-
1
;
}
...
...
@@ -130,7 +130,7 @@ socket_bind_listen(int domain, int type, int protocol,
if
(
ret
<
0
)
{
g_set_error
(
error
,
listen_quark
(),
errno
,
"%s"
,
g_strerror
(
errno
));
close
(
fd
);
close
_socket
(
fd
);
return
-
1
;
}
...
...
@@ -138,7 +138,7 @@ socket_bind_listen(int domain, int type, int protocol,
if
(
ret
<
0
)
{
g_set_error
(
error
,
listen_quark
(),
errno
,
"listen() failed: %s"
,
g_strerror
(
errno
));
close
(
fd
);
close
_socket
(
fd
);
return
-
1
;
}
...
...
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