|
@@ -25,6 +25,7 @@
|
|
|
#ifdef BADVPN_THREADWORK_USE_PTHREAD
|
|
#ifdef BADVPN_THREADWORK_USE_PTHREAD
|
|
|
#include <unistd.h>
|
|
#include <unistd.h>
|
|
|
#include <errno.h>
|
|
#include <errno.h>
|
|
|
|
|
+ #include <fcntl.h>
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
#include <misc/offset.h>
|
|
#include <misc/offset.h>
|
|
@@ -168,6 +169,12 @@ int BThreadWorkDispatcher_Init (BThreadWorkDispatcher *o, BReactor *reactor, int
|
|
|
goto fail2;
|
|
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
|
|
// init BFileDescriptor
|
|
|
BFileDescriptor_Init(&o->bfd, o->pipe[0], (BFileDescriptor_handler)pipe_fd_handler, o);
|
|
BFileDescriptor_Init(&o->bfd, o->pipe[0], (BFileDescriptor_handler)pipe_fd_handler, o);
|
|
|
if (!BReactor_AddFileDescriptor(o->reactor, &o->bfd)) {
|
|
if (!BReactor_AddFileDescriptor(o->reactor, &o->bfd)) {
|