Skip to content
Permalink
Browse files

fix ioh EWOULDBLOCK on setting events

  • Loading branch information...
jacobgorm committed Feb 22, 2019
1 parent 4335c9c commit d9b136d3cd145b3b67a1aaa959ff4c023631c061
Showing with 6 additions and 7 deletions.
  1. +6 −7 ioh.c
13 ioh.c
@@ -6,14 +6,18 @@
#include <stdlib.h>
#include <string.h>
#include <error.h>
#include <err.h>
#include <errno.h>

#include "ioh.h"

static int event_fds[2];

int ioh_init(void) {
int r = pipe2(event_fds, O_DIRECT | O_NONBLOCK);
int r = pipe2(event_fds, O_DIRECT);
assert(!r);
int flags = fcntl(event_fds[0], F_GETFL, 0) | O_NONBLOCK;
r = fcntl(event_fds[0], F_SETFL, flags);
assert(!r);
return r;
}
@@ -28,12 +32,7 @@ void ioh_event_set(ioh_event *event) {
uintptr_t e = (uintptr_t) event;
int r = write(event_fds[1], &e, sizeof(e));
if (r != sizeof(e)) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
assert(0);
} else {
printf("%s:%d r %d %d:%s\n", __FUNCTION__, __LINE__, r, errno, strerror(errno));
assert(0);
}
err(1, "%s:%d r %d %d:%s\n", __FUNCTION__, __LINE__, r, errno, strerror(errno));
}
}
}

0 comments on commit d9b136d

Please sign in to comment.
You can’t perform that action at this time.