Skip to content

Commit 0a7d9fa

Browse files
authored
Urgent inactive connection timeout removal
The recent commit removing the slow "connected but non-visible host item checking" broke inactive timeout disconnect functionality, causing every connection to time out even if it was still responsive. libVNCClient has a `readTimeout` value but it doesn't appear to do anything (useful). All inactive host detection is disabled for now, so unless something drastic happens, inactive hosts will just stay connected, no matter what the 'Auto-disconnect if inactive' is set to. I will have to find some other way to detect inactivity later.
1 parent 380e29e commit 0a7d9fa

File tree

4 files changed

+48
-30
lines changed

4 files changed

+48
-30
lines changed

src/app.cxx

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -794,29 +794,35 @@ void svConnectionWatcher (void *)
794794
}
795795
}
796796

797-
// do an inactive connection check
798-
nSize = app->hostList->size();
799-
800-
// iterate through hostlist items
801-
for (uint16_t i = 0; i <= nSize; i ++)
802-
{
803-
itm = static_cast<HostItem *>(app->hostList->data(i));
804-
805-
if (itm == NULL)
806-
continue;
807-
808-
vnc = itm->vnc;
809-
810-
if (vnc == NULL || itm->isConnected == false)
811-
continue;
812-
813-
// check if connection has been inactive, unless this itm is ignoring
814-
if (vnc->inactiveSeconds >= app->nDeadTimeout && itm->ignoreInactive == false)
815-
// remote host hasn't responded in time allotted, disconnect
816-
VncObject::endAndDeleteViewer(&vnc);
817-
else
818-
vnc->inactiveSeconds ++;
819-
}
797+
// #### the code below is commented out until further notice. ####
798+
// #### with removal of checking connected but non-visible ####
799+
// #### hosts, the ability to check for unresponsive ####
800+
// #### hosts is now disabled until some other method is found. ####
801+
// #### will leave 'plumbing' in place in case I find a way later ####
802+
803+
//// do an inactive connection check
804+
//nSize = app->hostList->size();
805+
806+
//// iterate through hostlist items
807+
//for (uint16_t i = 0; i <= nSize; i ++)
808+
//{
809+
//itm = static_cast<HostItem *>(app->hostList->data(i));
810+
811+
//if (itm == NULL)
812+
//continue;
813+
814+
//vnc = itm->vnc;
815+
816+
//if (vnc == NULL || itm->isConnected == false)
817+
//continue;
818+
819+
//// check if connection has been inactive, unless this itm is ignoring
820+
//if (vnc->inactiveSeconds >= app->nDeadTimeout && itm->ignoreInactive == false)
821+
//// remote host hasn't responded in time allotted, disconnect
822+
//VncObject::endAndDeleteViewer(&vnc);
823+
//else
824+
//vnc->inactiveSeconds ++;
825+
//}
820826

821827
// set timer to call this function again in 1 second
822828
// (do NOT change this interval as connection timeout

src/consts_enums.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#define CONSTS_H
3737

3838
/* constants */
39-
#define SV_APP_VERSION "0.5.1" //"0.4.16"
39+
#define SV_APP_VERSION "0.5.2" //"0.4.16"
4040

4141
#define SV_CURRENT_YEAR "2023"
4242

src/vnc.cxx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ void VncObject::createVNCObject (HostItem * itm)
133133
vnc->vncClient->GotCursorShape = VncObject::handleCursorShapeChange;
134134
}
135135

136+
// inactive timeout !!!! #### readTimeout doesn't seem to work (sigh) ####
137+
if (itm->ignoreInactive == true)
138+
vnc->vncClient->readTimeout = 0;
139+
else
140+
vnc->vncClient->readTimeout = app->nDeadTimeout;
141+
136142
// set up vnc compression and quality levels
137143
vnc->vncClient->appData.compressLevel = itm->compressLevel;
138144
vnc->vncClient->appData.qualityLevel = itm->qualityLevel;
@@ -445,14 +451,20 @@ void VncObject::handleCursorShapeChange (rfbClient * cl, int xHot, int yHot, int
445451

446452

447453
/* (static method) */
448-
void VncObject::handleFrameBufferUpdate (rfbClient * cl) //, int x, int y, int w, int h)
454+
void VncObject::handleFrameBufferUpdate (rfbClient * cl)
449455
{
456+
if (cl == NULL)
457+
return;
458+
450459
VncObject * vnc = static_cast<VncObject *>(rfbClientGetClientData(cl, app->libVncVncPointer));
451460

452-
if (vnc == NULL || vnc->allowDrawing == false)
461+
if (vnc == NULL)
453462
return;
454463

455-
app->vncViewer->redraw();
464+
//vnc->inactiveSeconds = 0;
465+
466+
if (vnc->allowDrawing == true)
467+
app->vncViewer->redraw();
456468
}
457469

458470

@@ -894,7 +906,7 @@ void VncObject::checkVNCMessages (VncObject * vnc)
894906
if (nMsg)
895907
{
896908
// reset inactive seconds so we don't automatically disconnect
897-
vnc->inactiveSeconds = 0;
909+
//vnc->inactiveSeconds = 0;
898910

899911
if (HandleRFBServerMessage(vnc->vncClient) == FALSE)
900912
{

src/vnc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class VncObject
5959
imgCursor(NULL),
6060
nCursorXHot(0),
6161
nCursorYHot(0),
62-
inactiveSeconds(0),
62+
//inactiveSeconds(0),
6363
nLastScrollX(0),
6464
nLastScrollY(0),
6565
centeredX(0),
@@ -92,7 +92,7 @@ class VncObject
9292
Fl_RGB_Image * imgCursor;
9393
int nCursorXHot;
9494
int nCursorYHot;
95-
uint16_t inactiveSeconds;
95+
//uint16_t inactiveSeconds;
9696
int nLastScrollX;
9797
int nLastScrollY;
9898
int centeredX;

0 commit comments

Comments
 (0)