In device_handle_read() we need to reset the read event on error or
authorTodd C. Miller <Todd.Miller@sudo.ws>
Thu, 22 Feb 2018 21:27:37 +0000 (14:27 -0700)
committerTodd C. Miller <Todd.Miller@sudo.ws>
Thu, 22 Feb 2018 21:27:37 +0000 (14:27 -0700)
it will keep firing.  This is easy to reproduce by suspending the
machine while tinc is running.

src/mingw/device.c

index 2cce1f2..54e0994 100644 (file)
@@ -76,6 +76,12 @@ static void device_handle_read(void *data, int flags) {
        if(!GetOverlappedResult(device_handle, &device_read_overlapped, &len, FALSE)) {
                logger(DEBUG_ALWAYS, LOG_ERR, "Error getting read result from %s %s: %s", device_info,
                       device, strerror(errno));
+
+               if(GetLastError() != ERROR_IO_INCOMPLETE) {
+                       /* Must reset event or it will keep firing. */
+                       ResetEvent(device_read_overlapped.hEvent);
+               }
+
                return;
        }