Use nonblocking pipes

This commit is contained in:
Nils O. Selåsdal
2014-05-07 22:48:56 +02:00
parent 802462a5c0
commit a24aa93b73
+5
View File
@@ -3,6 +3,7 @@
#include <unistd.h> #include <unistd.h>
#include <assert.h> #include <assert.h>
#include "ucore/iomux_waker.h" #include "ucore/iomux_waker.h"
#include "ucore/fd_utils.h"
static void uc_waker_pipe_cb(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event) static void uc_waker_pipe_cb(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event)
{ {
@@ -64,6 +65,10 @@ int uc_iomux_waker_init(struct IOMux *mux, struct IOMuxWaker *wk, uc_waker_cb cb
wk->mux = mux; wk->mux = mux;
wk->wake_cb = cb; wk->wake_cb = cb;
wk->signaller.fd = pfds[1]; wk->signaller.fd = pfds[1];
rc = uc_set_nonblocking(pfds[0]);
assert(rc == 0);
rc = uc_set_nonblocking(pfds[1]);
assert(rc == 0);
if (uc_install_wake_handler(wk, pfds[0]) == 0) { if (uc_install_wake_handler(wk, pfds[0]) == 0) {
return 0; return 0;