X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fevent.c;h=858e1d9d96d7d0fc497a845ee98203f939b0c747;hp=59b96e37dc3f7d3c7fa80ed96d27be1326a915c9;hb=1672dbd66b619f84cb86950298ad89df93e1dcba;hpb=979acc48aded5bb04f1574128d174d56550be302 diff --git a/src/event.c b/src/event.c index 59b96e37..858e1d9d 100644 --- a/src/event.c +++ b/src/event.c @@ -357,10 +357,13 @@ bool event_loop(void) { WSANETWORKEVENTS network_events; if (WSAEnumNetworkEvents(io->fd, io->event, &network_events) != 0) return false; - if (network_events.lNetworkEvents & WRITE_EVENTS) - io->cb(io->data, IO_WRITE); if (network_events.lNetworkEvents & READ_EVENTS) io->cb(io->data, IO_READ); + /* + The fd might be available for write too. However, if we already fired the read callback, that + callback might have deleted the io (e.g. through terminate_connection()), so we can't fire the + write callback here. Instead, we loop back and let the writable io loop above handle it. + */ } } #endif