[vlc-commits] Use vlc_socketpair()

Rémi Denis-Courmont git at videolan.org
Sun Jan 10 19:49:58 CET 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jan 10 20:47:42 2016 +0200| [321c1d51b308396fce7a8e37fe54212ec27cf3eb] | committer: Rémi Denis-Courmont

Use vlc_socketpair()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=321c1d51b308396fce7a8e37fe54212ec27cf3eb
---

 modules/access/http/h1conn_test.c |    5 +----
 modules/access/http/h2conn_test.c |    5 +----
 src/os2/filesystem.c              |    4 +---
 test/modules/misc/tls.c           |   10 +---------
 4 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/modules/access/http/h1conn_test.c b/modules/access/http/h1conn_test.c
index 773d64a..1fd6d56 100644
--- a/modules/access/http/h1conn_test.c
+++ b/modules/access/http/h1conn_test.c
@@ -30,9 +30,6 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <sys/socket.h>
-#ifndef SOCK_CLOEXEC
-# define SOCK_CLOEXEC 0
-#endif
 
 #include <vlc_common.h>
 #include <vlc_block.h>
@@ -47,7 +44,7 @@ static void conn_create(void)
 {
     int fds[2];
 
-    if (socketpair(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC, 0, fds))
+    if (vlc_socketpair(PF_LOCAL, SOCK_STREAM, 0, fds, false))
         assert(!"socketpair");
 
     struct vlc_tls *tls = vlc_tls_DummyCreate(NULL, fds[1]);
diff --git a/modules/access/http/h2conn_test.c b/modules/access/http/h2conn_test.c
index 4cce51c..a531495 100644
--- a/modules/access/http/h2conn_test.c
+++ b/modules/access/http/h2conn_test.c
@@ -30,9 +30,6 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <sys/socket.h>
-#ifndef SOCK_CLOEXEC
-# define SOCK_CLOEXEC 0
-#endif
 
 #include <vlc_common.h>
 #include <vlc_block.h>
@@ -93,7 +90,7 @@ static void conn_create(void)
     int fds[2];
     char hello[24];
 
-    if (socketpair(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC, 0, fds))
+    if (vlc_socketpair(PF_LOCAL, SOCK_STREAM, 0, fds, false))
         assert(!"socketpair");
 
     struct vlc_tls *tls = vlc_tls_DummyCreate(NULL, fds[1]);
diff --git a/src/os2/filesystem.c b/src/os2/filesystem.c
index 8ee29d3..256b9cc 100644
--- a/src/os2/filesystem.c
+++ b/src/os2/filesystem.c
@@ -258,7 +258,7 @@ int vlc_dup (int oldfd)
 
 int vlc_pipe (int fds[2])
 {
-    if (socketpair (AF_LOCAL, SOCK_STREAM, 0, fds))
+    if (vlc_socketpair (AF_LOCAL, SOCK_STREAM, 0, fds, false))
         return -1;
 
     shutdown (fds[0], SHUT_WR);
@@ -267,8 +267,6 @@ int vlc_pipe (int fds[2])
     setmode (fds[0], O_BINARY);
     setmode (fds[1], O_BINARY);
 
-    fcntl (fds[0], F_SETFD, FD_CLOEXEC);
-    fcntl (fds[1], F_SETFD, FD_CLOEXEC);
     return 0;
 }
 
diff --git a/test/modules/misc/tls.c b/test/modules/misc/tls.c
index 0145536..5a2c7da 100644
--- a/test/modules/misc/tls.c
+++ b/test/modules/misc/tls.c
@@ -30,9 +30,6 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
-#ifndef SOCK_CLOEXEC
-# define SOCK_CLOEXEC 0
-#endif
 #include <poll.h>
 #include <fcntl.h>
 #include <unistd.h>
@@ -47,12 +44,7 @@
 
 static int tlspair(int fds[2])
 {
-    if (socketpair(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC, 0, fds))
-        return -1;
-
-    fcntl(fds[0], F_SETFL, O_NONBLOCK | fcntl(fds[0], F_GETFL));
-    fcntl(fds[1], F_SETFL, O_NONBLOCK | fcntl(fds[1], F_GETFL));
-    return 0;
+    return vlc_socketpair(PF_LOCAL, SOCK_STREAM, 0, fds, true);
 }
 
 static int question_callback(vlc_object_t *obj, const char *varname,



More information about the vlc-commits mailing list