summaryrefslogtreecommitdiff
path: root/src/xine-engine
diff options
context:
space:
mode:
authorChris Rankin <rankincj@yahoo.com>2011-10-03 12:11:56 +0100
committerChris Rankin <rankincj@yahoo.com>2011-10-03 12:11:56 +0100
commit5db268a002e7a102855e84a3ff5e1c27ca7cb927 (patch)
treeb97f50441023384ff052e4daa64a2086fc44b47d /src/xine-engine
parent5ec743f4ddf302d10b3547cfc18ae0ca8aed1edd (diff)
downloadxine-lib-5db268a002e7a102855e84a3ff5e1c27ca7cb927.tar.gz
xine-lib-5db268a002e7a102855e84a3ff5e1c27ca7cb927.tar.bz2
Prefix open_cloexec() and create_cloexec() with xine_, and add new xine_socket_cloexec() function.
Diffstat (limited to 'src/xine-engine')
-rw-r--r--src/xine-engine/io_helper.c24
1 files changed, 2 insertions, 22 deletions
diff --git a/src/xine-engine/io_helper.c b/src/xine-engine/io_helper.c
index 5bcd95c63..22f34ffc2 100644
--- a/src/xine-engine/io_helper.c
+++ b/src/xine-engine/io_helper.c
@@ -60,23 +60,13 @@ static int _x_io_tcp_connect_ipv4(xine_stream_t *stream, const char *host, int p
return -1;
}
- s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ s = xine_socket_cloexec(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (s == -1) {
_x_message(stream, XINE_MSG_CONNECTION_REFUSED, "failed to create socket", strerror(errno), NULL);
return -1;
}
#ifndef WIN32
- if (fcntl(s, F_SETFD, FD_CLOEXEC) < 0) {
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "Failed to make socket uninheritable (%s)\n", strerror(errno));
- }
-#else
- if (!SetHandleInformation((HANDLE)s, HANDLE_FLAG_INHERIT, 0)) {
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "Failed to make socket uninheritable\n");
- }
-#endif
-
-#ifndef WIN32
if (fcntl (s, F_SETFL, fcntl (s, F_GETFL) | O_NONBLOCK) == -1) {
_x_message(stream, XINE_MSG_CONNECTION_REFUSED, "can't put socket in non-blocking mode", strerror(errno), NULL);
return -1;
@@ -154,7 +144,7 @@ int _x_io_tcp_connect(xine_stream_t *stream, const char *host, int port) {
while (tmpaddr) {
- s = socket(tmpaddr->ai_family, SOCK_STREAM, IPPROTO_TCP);
+ s = xine_socket_cloexec(tmpaddr->ai_family, SOCK_STREAM, IPPROTO_TCP);
if (s == -1) {
_x_message(stream, XINE_MSG_CONNECTION_REFUSED,
"failed to create socket", strerror(errno), NULL);
@@ -162,16 +152,6 @@ int _x_io_tcp_connect(xine_stream_t *stream, const char *host, int port) {
continue;
}
-#ifndef WIN32
- if (fcntl(s, F_SETFD, FD_CLOEXEC) < 0) {
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "Failed to make socket uninheritable (%s)\n", strerror(errno));
- }
-#else
- if (!SetHandleInformation((HANDLE)s, HANDLE_FLAG_INHERIT, 0)) {
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "Failed to make socket uninheritable\n");
- }
-#endif
-
/*
* Enable the non-blocking features only when there's no other
* address, allowing to use other addresses if available.