From 14c24e2bcc05578e37dfd64b6efe73774a288c90 Mon Sep 17 00:00:00 2001 From: Christian Beier Date: Sun, 6 Jan 2019 19:30:16 +0100 Subject: [PATCH] Fix comment style and be a bit more verbose ... explaining cedae6e6f97b14f5df3ea7c5f7efd59f2bc9ad82. --- libvncserver/main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libvncserver/main.c b/libvncserver/main.c index 17bef7e..d3cd9b1 100644 --- a/libvncserver/main.c +++ b/libvncserver/main.c @@ -566,7 +566,7 @@ clientInput(void *data) if (FD_ISSET(cl->pipe_notify_client_thread[0], &rfds)) { - // Reset the pipe + /* Reset the pipe */ char buf; while (read(cl->pipe_notify_client_thread[0], &buf, sizeof(buf)) == sizeof(buf)); } @@ -1112,8 +1112,13 @@ void rfbShutdownServer(rfbScreenInfoPtr screen,rfbBool disconnectClients) { } #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD - // Notify the thread and join it + /* + Notify the thread. This simply writes a NULL byte to the notify pipe in order to get past the select() + in clientInput(), the loop in there will then break because the rfbCloseClient() above has set + currentCl->sock to -1. + */ write(currentCl->pipe_notify_client_thread[1], "\x00", 1); + /* And wait for it to finish. */ pthread_join(currentCl->client_thread, NULL); #else rfbClientConnectionGone(currentCl);