diff options
author | ambrop7 <ambrop7@1a93d707-3861-5ebc-ad3b-9740d49b5140> | 2011-03-14 21:57:34 +0300 |
---|---|---|
committer | ambrop7 <ambrop7@1a93d707-3861-5ebc-ad3b-9740d49b5140> | 2011-03-14 21:57:34 +0300 |
commit | 9213aa8373308251d0a954c40e5b52906d7715de (patch) | |
tree | bacd342b5fc864e1e7141d48df58cbf5858efea4 /threadwork | |
parent | 3de2af71ebf3ce1918c4fbe17fc0d328366af9cb (diff) |
BThreadWork: make pipe read end non-blocking
Diffstat (limited to 'threadwork')
-rw-r--r-- | threadwork/BThreadWork.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/threadwork/BThreadWork.c b/threadwork/BThreadWork.c index 133ea9c..088df5c 100644 --- a/threadwork/BThreadWork.c +++ b/threadwork/BThreadWork.c @@ -25,6 +25,7 @@ #ifdef BADVPN_THREADWORK_USE_PTHREAD #include <unistd.h> #include <errno.h> + #include <fcntl.h> #endif #include <misc/offset.h> @@ -168,6 +169,12 @@ int BThreadWorkDispatcher_Init (BThreadWorkDispatcher *o, BReactor *reactor, int goto fail2; } + // set read end non-blocking + if (fcntl(o->pipe[0], F_SETFL, O_NONBLOCK) < 0) { + BLog(BLOG_ERROR, "pipe failed"); + goto fail3; + } + // init BFileDescriptor BFileDescriptor_Init(&o->bfd, o->pipe[0], (BFileDescriptor_handler)pipe_fd_handler, o); if (!BReactor_AddFileDescriptor(o->reactor, &o->bfd)) { |