summaryrefslogtreecommitdiff
path: root/src/input/input_net.c
diff options
context:
space:
mode:
authorChris Rankin <rankincj@yahoo.com>2011-10-03 12:38:45 +0100
committerChris Rankin <rankincj@yahoo.com>2011-10-03 12:38:45 +0100
commita39a950269d165f18448cc7d6da691bf14b9e03b (patch)
tree2ff0626b06e3e87cb9f3d7678af4859b5d65b594 /src/input/input_net.c
parentcba782a23ee5c9c668e02f9c6d95acba70464d18 (diff)
downloadxine-lib-a39a950269d165f18448cc7d6da691bf14b9e03b.tar.gz
xine-lib-a39a950269d165f18448cc7d6da691bf14b9e03b.tar.bz2
Prefix open_cloexec() and create_cloexec() with xine_, and add new xine_socket_cloexec() function.
Diffstat (limited to 'src/input/input_net.c')
-rw-r--r--src/input/input_net.c32
1 files changed, 3 insertions, 29 deletions
diff --git a/src/input/input_net.c b/src/input/input_net.c
index f44db8301..edbe73b08 100644
--- a/src/input/input_net.c
+++ b/src/input/input_net.c
@@ -115,25 +115,13 @@ static int host_connect_attempt_ipv4(struct in_addr ia, int port, xine_t *xine)
int s;
struct sockaddr_in sin;
- s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ s = xine_socket_cloexec(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (s==-1) {
xine_log(xine, XINE_LOG_MSG,
_("input_net: socket(): %s\n"), strerror(errno));
return -1;
}
-#ifndef WIN32
- if (fcntl(s, F_SETFD, FD_CLOEXEC) < 0) {
- xine_log(xine, XINE_LOG_MSG,
- _("input_net: Failed to make socket uninheritable (%s)\n"),
- strerror(errno));
- }
-#else
- if (!SetHandleInformation((HANDLE)s, HANDLE_FLAG_INHERIT, 0)) {
- xine_log(xine, XINE_LOG_MSG, "Failed to make socket uninheritable\n");
- }
-#endif
-
sin.sin_family = AF_INET;
sin.sin_addr = ia;
sin.sin_port = htons(port);
@@ -155,28 +143,14 @@ static int host_connect_attempt_ipv4(struct in_addr ia, int port, xine_t *xine)
#else
static int host_connect_attempt(int family, struct sockaddr* sin, int addrlen, xine_t *xine) {
- int s;
-
- s = socket(family, SOCK_STREAM, IPPROTO_TCP);
- if (s==-1) {
+ int s = xine_socket_cloexec(family, SOCK_STREAM, IPPROTO_TCP);
+ if (s == -1) {
xine_log(xine, XINE_LOG_MSG,
_("input_net: socket(): %s\n"), strerror(errno));
return -1;
}
#ifndef WIN32
- if (fcntl(s, F_SETFD, FD_CLOEXEC) < 0) {
- xine_log(xine, XINE_LOG_MSG,
- _("input_net: Failed to make socket uninheritable (%s)\n"),
- strerror(errno));
- }
-#else
- if (!SetHandleInformation((HANDLE)s, HANDLE_FLAG_INHERIT, 0)) {
- xine_log(xine, XINE_LOG_MSG, "Failed to make socket uninheritable\n");
- }
-#endif
-
-#ifndef WIN32
if (connect(s, sin, addrlen)==-1 && errno != EINPROGRESS)
#else
if (connect(s, sin, addrlen)==-1 && WSAGetLastError() != WSAEINPROGRESS)