From: Vadim Zeitlin Date: Wed, 3 Jul 2013 00:31:26 +0000 (+0000) Subject: Treat G_IO_HUP as read, not error, event because EOF is not exceptional. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/c36ddebf93ff3f967927d628dd0e569c75159c37 Treat G_IO_HUP as read, not error, event because EOF is not exceptional. When EOF is reached on a file descriptor, call the handler OnReadWaiting() because this is not really different from getting to the EOF while reading data in the same function. Only call OnExceptionWaiting() for the real errors. See #10258. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74348 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/evtloop.cpp b/src/gtk/evtloop.cpp index ea5b43b9d1..3bfdfdc799 100644 --- a/src/gtk/evtloop.cpp +++ b/src/gtk/evtloop.cpp @@ -124,14 +124,24 @@ static gboolean wx_on_channel_event(GIOChannel *channel, wxEventLoopSourceHandler * const handler = static_cast(data); - if (condition & G_IO_IN || condition & G_IO_PRI) + if ( (condition & G_IO_IN) || (condition & G_IO_PRI) || (condition & G_IO_HUP) ) handler->OnReadWaiting(); + if (condition & G_IO_OUT) handler->OnWriteWaiting(); - else if (condition & G_IO_ERR || condition & G_IO_NVAL) + + if ( (condition & G_IO_ERR) || (condition & G_IO_NVAL) ) handler->OnExceptionWaiting(); // we never want to remove source here, so always return true + // + // The source may have been removed by the handler, so it may be + // a good idea to return FALSE when the source has already been + // removed. However, that would involve somehow informing this function + // that the source was removed, which is not trivial to implement + // and handle all cases. It has been found through testing + // that if the source was removed by the handler, that even if we + // return TRUE here, the source/callback will not get called again. return TRUE; } }