Commit efa68b29 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

contrib: force close-on-exec flag on live555 sockets

parent a758e7f6
Copyright (C) 2011 Rémi Denis-Courmont.
Licensed under GNU General Public License version 2 or higher.
diff -ru live.orig/groupsock/GroupsockHelper.cpp live555/groupsock/GroupsockHelper.cpp
--- live.orig/groupsock/GroupsockHelper.cpp 2011-08-23 18:19:59.000000000 +0300
+++ live/groupsock/GroupsockHelper.cpp 2011-08-23 18:26:32.000000000 +0300
@@ -49,13 +49,33 @@
reuseFlag = 1;
}
+static int makeSocket(int type)
+{
+ int fd;
+
+#ifdef SOCK_CLOEXEC
+ fd = socket(AF_INET, type|SOCK_CLOEXEC, 0);
+ if (fd != -1 || errno != EINVAL)
+ return fd;
+#endif
+
+ fd = socket(AF_INET, type, 0);
+ if (fd == -1)
+ return -1;
+#ifdef FD_CLOEXEC
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
+#endif
+ return fd;
+}
+
+
int setupDatagramSocket(UsageEnvironment& env, Port port) {
if (!initializeWinsockIfNecessary()) {
socketErr(env, "Failed to initialize 'winsock': ");
return -1;
}
- int newSocket = socket(AF_INET, SOCK_DGRAM, 0);
+ int newSocket = makeSocket(SOCK_DGRAM);
if (newSocket < 0) {
socketErr(env, "unable to create datagram socket: ");
return newSocket;
@@ -161,7 +181,7 @@
return -1;
}
- int newSocket = socket(AF_INET, SOCK_STREAM, 0);
+ int newSocket = makeSocket(SOCK_STREAM);
if (newSocket < 0) {
socketErr(env, "unable to create stream socket: ");
return newSocket;
......@@ -23,6 +23,7 @@ ifndef HAVE_WINCE
patch -p0 < $(SRC)/live555/live-getaddrinfo.patch
endif
endif
patch -p0 < $(SRC)/live555/live-cloexec.patch
mv live $@
touch $@
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment