浏览代码

NCDInterfaceMonitor: make netlink file descriptor non-blocking

ambrop7 15 年之前
父节点
当前提交
d2d1feefcb
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      ncd/NCDInterfaceMonitor.c

+ 7 - 0
ncd/NCDInterfaceMonitor.c

@@ -33,6 +33,7 @@
 #include <asm/types.h>
 #include <asm/types.h>
 
 
 #include <misc/debug.h>
 #include <misc/debug.h>
+#include <misc/nonblocking.h>
 
 
 #include <ncd/NCDInterfaceMonitor.h>
 #include <ncd/NCDInterfaceMonitor.h>
 
 
@@ -150,6 +151,12 @@ int NCDInterfaceMonitor_Init (NCDInterfaceMonitor *o, BReactor *reactor, NCDInte
         goto fail0;
         goto fail0;
     }
     }
     
     
+    // set fd non-blocking
+    if (!badvpn_set_nonblocking(o->netlink_fd)) {
+        DEBUG("badvpn_set_nonblocking failed");
+        goto fail1;
+    }
+    
     // bind netlink fd
     // bind netlink fd
     struct sockaddr_nl sa;
     struct sockaddr_nl sa;
     memset(&sa, 0, sizeof(sa));
     memset(&sa, 0, sizeof(sa));