From: Pierre Ossman Date: Wed, 6 Apr 2022 13:45:36 +0000 (+0200) Subject: Ignore socket whilst processing data X-Git-Tag: v1.12.90~40 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=caa976c4e6e7737aba08e9daf878cd51d581f42c;p=tigervnc.git Ignore socket whilst processing data FLTK has a lot of synchronous stuff (like dialogs), which mean that the main loop might be run recursively in some cases. If there is data available on our socket then CConn::socketEvent() will be called constantly in a busy loop. Avoid this by removing socket notifications whilst we are processing data. --- diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx index b1f97b98..011dd971 100644 --- a/vncviewer/CConn.cxx +++ b/vncviewer/CConn.cxx @@ -238,10 +238,10 @@ void CConn::socketEvent(FL_SOCKET fd, void *data) cc = (CConn*)data; // I don't think processMsg() is recursion safe, so add this check - if (recursing) - return; + assert(!recursing); recursing = true; + Fl::remove_fd(fd); try { // We might have been called to flush unwritten socket data @@ -287,6 +287,7 @@ void CConn::socketEvent(FL_SOCKET fd, void *data) Fl::add_fd(fd, when, socketEvent, data); recursing = false; + Fl::add_fd(fd, FL_READ | FL_EXCEPT, socketEvent, data); } ////////////////////// CConnection callback methods //////////////////////