From 37ccb325af5c7865eb16716780121a8a6dce8abd Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Wed, 4 Nov 2009 16:18:08 +0100 Subject: [PATCH] Don't enable device events when there is no valid filedescriptor. --- src/net_setup.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/net_setup.c b/src/net_setup.c index de2d0fe..c643449 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -349,12 +349,14 @@ bool setup_myself(void) { if(!setup_device()) return false; - event_set(&device_ev, device_fd, EV_READ|EV_PERSIST, handle_device_data, NULL); + if(device_fd >= 0) { + event_set(&device_ev, device_fd, EV_READ|EV_PERSIST, handle_device_data, NULL); - if (event_add(&device_ev, NULL) < 0) { - logger(LOG_ERR, "event_add failed: %s", strerror(errno)); - close_device(); - return false; + if (event_add(&device_ev, NULL) < 0) { + logger(LOG_ERR, "event_add failed: %s", strerror(errno)); + close_device(); + return false; + } } /* Run tinc-up script to further initialize the tap interface */ -- 2.25.1