summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/skalibs/nonposix.h2
-rw-r--r--src/libunixonacid/textclient_server_init_fromsocket.c3
-rw-r--r--src/libunixonacid/unixmessage_put.c22
-rw-r--r--src/libunixonacid/unixmessage_receive.c6
-rw-r--r--src/libunixonacid/unixmessage_sender_flush.c3
-rw-r--r--src/libunixonacid/unixmessage_sender_free.c4
-rw-r--r--src/sysdeps/tryancilautoclose.c12
-rw-r--r--src/sysdeps/trynbwaitall.c121
8 files changed, 1 insertions, 172 deletions
diff --git a/src/include/skalibs/nonposix.h b/src/include/skalibs/nonposix.h
index 25af4bd..4ce165c 100644
--- a/src/include/skalibs/nonposix.h
+++ b/src/include/skalibs/nonposix.h
@@ -61,7 +61,7 @@
because the BSDs are bloody snowflakes. See: setgroups(). */
#undef SKALIBS_BSD_SUCKS
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__) || defined(__DragonFly__)
# define SKALIBS_BSD_SUCKS
#endif
diff --git a/src/libunixonacid/textclient_server_init_fromsocket.c b/src/libunixonacid/textclient_server_init_fromsocket.c
index 5b71463..e58df2b 100644
--- a/src/libunixonacid/textclient_server_init_fromsocket.c
+++ b/src/libunixonacid/textclient_server_init_fromsocket.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <skalibs/sysdeps.h>
#include <skalibs/nonposix.h>
#include <sys/uio.h>
#include <errno.h>
@@ -60,9 +59,7 @@ static int sendit (void *p)
do r = sendmsg(fd[0], &hdr, MSG_NOSIGNAL) ;
while (r < 0 && errno == EINTR) ;
if (r <= 0) return 0 ;
-#ifndef SKALIBS_HASANCILAUTOCLOSE
fd_close(fd[1]) ;
-#endif
return 1 ;
}
diff --git a/src/libunixonacid/unixmessage_put.c b/src/libunixonacid/unixmessage_put.c
index 528c3b8..a8701ee 100644
--- a/src/libunixonacid/unixmessage_put.c
+++ b/src/libunixonacid/unixmessage_put.c
@@ -1,9 +1,5 @@
/* ISC license. */
-#include <skalibs/sysdeps.h>
-#ifdef SKALIBS_HASANCILAUTOCLOSE
-#include <unistd.h>
-#endif
#include <string.h>
#include <errno.h>
#include <skalibs/bitarray.h>
@@ -22,24 +18,6 @@ static inline int copyfds (char *s, int const *fds, unsigned int n, unsigned cha
int fd = fds[i] ;
if (fd < 0) return (errno = EINVAL, -1) ;
if (bitarray_peek(bits, i)) fd = - fd - 1 ;
-#ifdef SKALIBS_HASANCILAUTOCLOSE
- else
- {
- fd = dup(fd) ;
- if (fd < 0)
- {
- int e = errno ;
- while (i--)
- {
- s -= sizeof(int) ;
- memcpy((char *)fd, s, sizeof(int)) ;
- if (fd >= 0) (*closecb)(fd, closecbdata) ;
- }
- errno = e ;
- return 0 ;
- }
- }
-#endif
memcpy(s, (char const *)&fd, sizeof(int)) ;
s += sizeof(int) ;
}
diff --git a/src/libunixonacid/unixmessage_receive.c b/src/libunixonacid/unixmessage_receive.c
index ec12e09..15d08ae 100644
--- a/src/libunixonacid/unixmessage_receive.c
+++ b/src/libunixonacid/unixmessage_receive.c
@@ -27,12 +27,6 @@ static int const awesomeflags =
0
#endif
|
-#ifdef SKALIBS_HASNBWAITALL
- MSG_WAITALL
-#else
- 0
-#endif
- |
#ifdef SKALIBS_HASCMSGCLOEXEC
MSG_CMSG_CLOEXEC
#else
diff --git a/src/libunixonacid/unixmessage_sender_flush.c b/src/libunixonacid/unixmessage_sender_flush.c
index eb2645c..fa1438f 100644
--- a/src/libunixonacid/unixmessage_sender_flush.c
+++ b/src/libunixonacid/unixmessage_sender_flush.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <skalibs/sysdeps.h>
#include <skalibs/nonposix.h>
#include <sys/socket.h>
#include <sys/uio.h>
@@ -104,7 +103,6 @@ int unixmessage_sender_flush (unixmessage_sender_t *b)
do r = sendmsg(b->fd, &hdr, MSG_NOSIGNAL) ;
while (r < 0 && errno == EINTR) ;
if (r <= 0) return 0 ;
-#ifndef SKALIBS_HASANCILAUTOCLOSE
if (nfds)
{
size_t i = 0 ;
@@ -114,7 +112,6 @@ int unixmessage_sender_flush (unixmessage_sender_t *b)
if (fd < 0) (*b->closecb)(-(fd+1), b->closecbdata) ;
}
}
-#endif
if ((size_t)r < 6 + len)
{
b->shorty = 6 + len - r ;
diff --git a/src/libunixonacid/unixmessage_sender_free.c b/src/libunixonacid/unixmessage_sender_free.c
index da127c2..4c07952 100644
--- a/src/libunixonacid/unixmessage_sender_free.c
+++ b/src/libunixonacid/unixmessage_sender_free.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <skalibs/sysdeps.h>
#include <sys/types.h>
#include <skalibs/disize.h>
#include <skalibs/stralloc.h>
@@ -18,9 +17,6 @@ void unixmessage_sender_free (unixmessage_sender_t *b)
{
int fd = genalloc_s(int, &b->fds)[i] ;
if (fd < 0) (*b->closecb)(-(fd+1), b->closecbdata) ;
-#ifdef SKALIBS_HASANCILAUTOCLOSE
- else (*b->closecb)(fd, b->closecbdata) ;
-#endif
}
}
genalloc_free(disize, &b->offsets) ;
diff --git a/src/sysdeps/tryancilautoclose.c b/src/sysdeps/tryancilautoclose.c
deleted file mode 100644
index 4cb08b3..0000000
--- a/src/sysdeps/tryancilautoclose.c
+++ /dev/null
@@ -1,12 +0,0 @@
-/* ISC license. */
-
- /*
- * It's actually false everywhere.
- * Not removing the test for now because it would mean editing all the
- * places where the test happens. Will remove it later.
- */
-
-int main (void)
-{
- return 1 ;
-}
diff --git a/src/sysdeps/trynbwaitall.c b/src/sysdeps/trynbwaitall.c
deleted file mode 100644
index 48f6b89..0000000
--- a/src/sysdeps/trynbwaitall.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/* ISC license. */
-
-#undef _POSIX_C_SOURCE
-#undef _XOPEN_SOURCE
-
-#ifndef _XPG4_2
-#define _XPG4_2
-#endif
-
-#ifndef _BSD_SOURCE
-#define _BSD_SOURCE
-#endif
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <signal.h>
-#include <sys/socket.h>
-#include <sys/select.h>
-#include <sys/uio.h>
-
-#ifndef MSG_NOSIGNAL
-#define MSG_NOSIGNAL 0
-#endif
-
-#ifndef MSG_DONTWAIT
-#define MSG_DONTWAIT 0
-#endif
-
-
-static int ndelay_on (int fd)
-{
- int got = fcntl(fd, F_GETFL) ;
- return (got == -1) ? -1 : fcntl(fd, F_SETFL, got | O_NONBLOCK) ;
-}
-
-static int child (int p, int fd)
-{
- char buf[8] ;
- struct iovec v = { .iov_base = buf, .iov_len = 8 } ;
- struct msghdr msg =
- {
- .msg_name = 0,
- .msg_namelen = 0,
- .msg_iov = &v,
- .msg_iovlen = 1,
- .msg_control = 0,
- .msg_controllen = 0
- } ;
- fd_set rfds ;
- if (ndelay_on(fd) < 0) return 111 ;
- FD_ZERO(&rfds) ;
- FD_SET(fd, &rfds) ;
- if (write(p, "", 1) < 1) return 111 ; /* sync with the parent */
- if (select(fd+1, &rfds, 0, 0, 0) < 1) return 111 ;
-
- /* The following recvmsg may block, despite setting the fd
- non-blocking. That is what we're testing. */
-
- if (recvmsg(fd, &msg, MSG_WAITALL | MSG_DONTWAIT) < 1) return 111 ;
- if (write(p, "", 1) < 1) return 111 ;
- return 0 ;
-}
-
-static int parent (pid_t pid, int p, int fd)
-{
- char c ;
- struct iovec v = { .iov_base = &c, .iov_len = 1 } ;
- struct msghdr msg =
- {
- .msg_name = 0,
- .msg_namelen = 0,
- .msg_iov = &v,
- .msg_iovlen = 1,
- .msg_control = 0,
- .msg_controllen = 0
- } ;
- struct timeval tv = { .tv_sec = 2, .tv_usec = 0 } ;
- fd_set rfds ;
- unsigned int n = p > fd ? p : fd ;
- int r ;
- FD_ZERO(&rfds) ;
- FD_SET(p, &rfds) ;
- if (read(p, &c, 1) < 1) return 111 ;
- if (sendmsg(fd, &msg, MSG_NOSIGNAL) < 1) return 111 ;
- for (;;)
- {
- r = select(n+1, &rfds, 0, 0, &tv) ;
- if (r >= 0 || errno != EINTR) break ;
- }
- if (!r) /* child is still blocking on recvmsg() after 2 seconds */
- {
- kill(pid, SIGTERM) ;
- return 1 ;
- }
- if (read(p, &c, 1) < 1) return 111 ;
- return 0 ;
-}
-
-int main (void)
-{
- pid_t pid ;
- int fd[2] ;
- int p[2] ;
- if (pipe(p) < 0) return 111 ;
- if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) return 111 ;
- pid = fork() ;
- if (pid < 0) return 111 ;
- if (!pid)
- {
- close(p[0]) ;
- close(fd[0]) ;
- return child(p[1], fd[1]) ;
- }
- close(p[1]) ;
- close(fd[1]) ;
- return parent(pid, p[0], fd[0]) ;
-}