Skip to content

Commit

Permalink
Server: Log # of simultaneously connected viewers
Browse files Browse the repository at this point in the history
  • Loading branch information
dcommander committed Jul 1, 2024
1 parent f3f6edb commit dd87747
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
4 changes: 3 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ viewer successfully connects, and the viewer's ID is reported in the TurboVNC
session log along with the IP address from which the viewer connection
originated. This makes it easier to distinguish log entries related to a
specific viewer, especially when using SSH tunneling (which makes it appear as
if all viewer connections originate from the loopback IP address.)
if all viewer connections originate from the loopback IP address.) The
TurboVNC Server now also logs the total number of simultaneously connected
viewers.


3.0.3
Expand Down
1 change: 1 addition & 0 deletions unix/Xvnc/programs/Xserver/hw/vnc/rfb.h
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,7 @@ extern char *captureFile;
rfbLog(m" %d, %d %d x %d\n", (r).extents.x1, (r).extents.y1, \
(r).extents.x2 - (r).extents.x1, (r).extents.y2 - (r).extents.y1)

extern int rfbClientCount(void);
extern void rfbNewClientConnection(int sock);
extern rfbClientPtr rfbReverseConnection(char *host, int port, int id);
extern void rfbClientConnectionGone(rfbClientPtr cl);
Expand Down
15 changes: 15 additions & 0 deletions unix/Xvnc/programs/Xserver/hw/vnc/rfbserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ Bool rfbSendDesktopSize(rfbClientPtr cl);
Bool rfbSendExtDesktopSize(rfbClientPtr cl);


int rfbClientCount(void)
{
rfbClientPtr cl;
int count = 0;

for (cl = rfbClientHead; cl; cl = cl->next)
count++;
return count;
}


/*
* Session capture
*/
Expand Down Expand Up @@ -582,6 +593,8 @@ void rfbClientConnectionGone(rfbClientPtr cl)

free(cl);

rfbLog("Number of connected clients: %d\n", rfbClientCount());

if (rfbClientHead == NULL && rfbIdleTimeout > 0)
IdleTimerSet();
}
Expand Down Expand Up @@ -768,6 +781,8 @@ static void rfbProcessClientInitMessage(rfbClientPtr cl)
}
}
}

rfbLog("Number of connected clients: %d\n", rfbClientCount());
}


Expand Down
6 changes: 2 additions & 4 deletions unix/Xvnc/programs/Xserver/hw/vnc/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static void rfbSockNotify(int fd, int ready, void *data)
socklen_t addrlen = sizeof(struct sockaddr_storage);
char addrStr[INET6_ADDRSTRLEN];
const int one = 1;
int sock, numClientConnections = 0;
int sock;
rfbClientPtr cl, nextCl;

if (rfbListenSock != -1 && fd == rfbListenSock) {
Expand Down Expand Up @@ -186,9 +186,7 @@ static void rfbSockNotify(int fd, int ready, void *data)
}
#endif

for (cl = rfbClientHead; cl; cl = cl->next)
numClientConnections++;
if (numClientConnections >= rfbMaxClientConnections) {
if (rfbClientCount() >= rfbMaxClientConnections) {
rfbClientRec tempCl;
rfbProtocolVersionMsg pv;
const char *errMsg = "Connection limit reached";
Expand Down

0 comments on commit dd87747

Please sign in to comment.