Skip to content

Commit 9b7b5ff

Browse files
committed
Revert "libvncserver: detach client thread before ending it"
This reverts commit 8560a5a. It caused several crashes when ending a server: client threads would sometimes linger around until after the server was stopped and its rfbScreen internals free()ed, with these client threads trying to access rfbScreen and friends: 💣. Reopens #570
1 parent d723655 commit 9b7b5ff

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/libvncserver/main.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -610,10 +610,6 @@ clientInput(void *data)
610610

611611
rfbClientConnectionGone(cl);
612612

613-
/* We can't reliably join this thread, so detach it here
614-
so the associated memory will be freed by the OS. */
615-
THREAD_DETACH(cl->client_thread);
616-
617613
return THREAD_ROUTINE_RETURN_VALUE;
618614
}
619615

@@ -1208,7 +1204,10 @@ void rfbShutdownServer(rfbScreenInfoPtr screen,rfbBool disconnectClients) {
12081204
}
12091205

12101206
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
1211-
if(!currentCl->screen->backgroundLoop) {
1207+
if(currentCl->screen->backgroundLoop) {
1208+
/* Wait for threads to finish. The thread has already been pipe-notified by rfbCloseClient() */
1209+
pthread_join(currentCl->client_thread, NULL);
1210+
} else {
12121211
/*
12131212
In threaded mode, rfbClientConnectionGone() is called by the client-to-server thread.
12141213
Only need to call this here for non-threaded mode.

0 commit comments

Comments
 (0)