Skip to content

Commit 06c8695

Browse files
committed
libvncserver: lock out client reads during framebuffer exchange
Closes #435
1 parent 7238a5a commit 06c8695

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

libvncserver/main.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,13 @@ void rfbNewFramebuffer(rfbScreenInfoPtr screen, char *framebuffer,
10721072
rfbClientIteratorPtr iterator;
10731073
rfbClientPtr cl;
10741074

1075+
/* Lock out client reads. */
1076+
iterator = rfbGetClientIterator(screen);
1077+
while ((cl = rfbClientIteratorNext(iterator))) {
1078+
LOCK(cl->sendMutex);
1079+
}
1080+
rfbReleaseClientIterator(iterator);
1081+
10751082
/* Update information in the screenInfo structure */
10761083

10771084
old_format = screen->serverFormat;
@@ -1124,6 +1131,9 @@ void rfbNewFramebuffer(rfbScreenInfoPtr screen, char *framebuffer,
11241131

11251132
TSIGNAL(cl->updateCond);
11261133
UNLOCK(cl->updateMutex);
1134+
1135+
/* Swapping frame buffers finished, re-enable client reads. */
1136+
UNLOCK(cl->sendMutex);
11271137
}
11281138
rfbReleaseClientIterator(iterator);
11291139
}

0 commit comments

Comments
 (0)