summaryrefslogtreecommitdiffstats
path: root/src/async.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-04-29 16:17:58 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-04-29 16:17:58 +0200
commit9a86ce6ea990ac72337bffb78f663f8a904a408f (patch)
treeb532fb296850eab0598d89452373170c9b4c1c1a /src/async.c
parent639ebc2ff93adca5eb9e12d70a2e9e19731c84ba (diff)
downloadfastd-9a86ce6ea990ac72337bffb78f663f8a904a408f.tar
fastd-9a86ce6ea990ac72337bffb78f663f8a904a408f.zip
Fold fastd_open_pipe into fastd_async_init, simpify fastd_setfl and fastd_setfd and move to fastd.h
Diffstat (limited to 'src/async.c')
-rw-r--r--src/async.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/async.c b/src/async.c
index ed8370f..2343cbb 100644
--- a/src/async.c
+++ b/src/async.c
@@ -27,8 +27,6 @@
#include "async.h"
#include "fastd.h"
-#include <fcntl.h>
-
typedef struct fastd_async_hdr {
fastd_async_type_t type;
@@ -37,8 +35,18 @@ typedef struct fastd_async_hdr {
void fastd_async_init(void) {
- fastd_open_pipe(&ctx.async_rfd, &ctx.async_wfd);
- fastd_setfl(ctx.async_wfd, O_NONBLOCK, 0);
+ int fds[2];
+
+ /* use socketpair with SOCK_DGRAM instead of pipe2 with O_DIRECT to keep this portable */
+ if (socketpair(AF_UNIX, SOCK_DGRAM, 0, fds))
+ exit_errno("socketpair");
+
+ fastd_setfd(fds[0], FD_CLOEXEC);
+ fastd_setfd(fds[1], FD_CLOEXEC);
+ fastd_setfl(fds[1], O_NONBLOCK);
+
+ ctx.async_rfd = fds[0];
+ ctx.async_wfd = fds[1];
}
static void handle_resolve_return(const fastd_async_resolve_return_t *resolve_return) {