summaryrefslogtreecommitdiff
path: root/src/fdevent.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2021-02-08 13:15:16 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2023-05-03 23:11:34 -0400
commit24c5bc8869288fad7d016f966be269fb31364f09 (patch)
tree31e981db5dd9590b5a86ec1c4601ea8afa8b4342 /src/fdevent.c
parent21eee1fad6554160daab6858591004af46bd83bb (diff)
downloadlighttpd-git-24c5bc8869288fad7d016f966be269fb31364f09.tar.gz
[core] _WIN32 implementation of socketpair()
Diffstat (limited to 'src/fdevent.c')
-rw-r--r--src/fdevent.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/fdevent.c b/src/fdevent.c
index 2100dbc2..c18fac57 100644
--- a/src/fdevent.c
+++ b/src/fdevent.c
@@ -135,6 +135,47 @@ int fdevent_socket_nb_cloexec(int domain, int type, int protocol) {
return fd;
}
+#ifndef _WIN32
+#if 0 /* not used */
+
+int fdevent_socketpair_cloexec (int domain, int typ, int protocol, int sv[2])
+{
+ sv[0] = sv[1] = -1;
+ #if defined(SOCK_CLOEXEC)
+ return socketpair(domain, typ | SOCK_CLOEXEC, protocol, sv);
+ #else
+ if (0 == socketpair(domain, typ, protocol, sv)) {
+ fdevent_setfd_cloexec(sv[0]);
+ fdevent_setfd_cloexec(sv[1]);
+ return 0;
+ }
+ return -1;
+ #endif
+}
+
+int fdevent_socketpair_nb_cloexec (int domain, int typ, int protocol, int sv[2])
+{
+ sv[0] = sv[1] = -1;
+ #if defined(SOCK_CLOEXEC) && defined(SOCK_NONBLOCK)
+ return socketpair(domain, typ | SOCK_NONBLOCK | SOCK_CLOEXEC, protocol, sv);
+ #else
+ if (0 == socketpair(domain, typ, protocol, sv)) {
+ if (0 == fdevent_fcntl_set_nb_cloexec(sv[0])
+ && 0 == fdevent_fcntl_set_nb_cloexec(sv[1]))
+ return 0;
+
+ close(sv[0]);
+ close(sv[1]);
+ sv[0] = sv[1] = -1;
+ }
+ return -1;
+ #endif
+}
+
+#endif /* not used */
+
+#endif /* !_WIN32 */
+
int fdevent_dup_cloexec (int fd) {
#ifdef F_DUPFD_CLOEXEC
return fcntl(fd, F_DUPFD_CLOEXEC, 3);