From caa976c4e6e7737aba08e9daf878cd51d581f42c Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 6 Apr 2022 15:45:36 +0200 Subject: [PATCH] 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. --- vncviewer/CConn.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 ////////////////////// -- 2.39.5