diff options
Diffstat (limited to 'libvncserver/main.c')
-rw-r--r-- | libvncserver/main.c | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/libvncserver/main.c b/libvncserver/main.c index 52bd4e7..1c9a4e7 100644 --- a/libvncserver/main.c +++ b/libvncserver/main.c @@ -444,22 +444,34 @@ clientOutput(void *data) while (1) { haveUpdate = false; while (!haveUpdate) { - if (cl->sock == -1) { - /* Client has disconnected. */ - return NULL; - } - LOCK(cl->updateMutex); - haveUpdate = FB_UPDATE_PENDING(cl); - if(!haveUpdate) { - updateRegion = sraRgnCreateRgn(cl->modifiedRegion); - haveUpdate = sraRgnAnd(updateRegion,cl->requestedRegion); - sraRgnDestroy(updateRegion); - } - - if (!haveUpdate) { - WAIT(cl->updateCond, cl->updateMutex); - } - UNLOCK(cl->updateMutex); + if (cl->sock == -1) { + /* Client has disconnected. */ + return NULL; + } + if (cl->state != RFB_NORMAL || cl->onHold) { + /* just sleep until things get normal */ + usleep(cl->screen->deferUpdateTime * 1000); + continue; + } + + LOCK(cl->updateMutex); + + if (sraRgnEmpty(cl->requestedRegion)) { + ; /* always require a FB Update Request (otherwise can crash.) */ + } else { + haveUpdate = FB_UPDATE_PENDING(cl); + if(!haveUpdate) { + updateRegion = sraRgnCreateRgn(cl->modifiedRegion); + haveUpdate = sraRgnAnd(updateRegion,cl->requestedRegion); + sraRgnDestroy(updateRegion); + } + } + + if (!haveUpdate) { + WAIT(cl->updateCond, cl->updateMutex); + } + + UNLOCK(cl->updateMutex); } /* OK, now, to save bandwidth, wait a little while for more @@ -476,7 +488,9 @@ clientOutput(void *data) /* Now actually send the update. */ rfbIncrClientRef(cl); + LOCK(cl->sendMutex); rfbSendFramebufferUpdate(cl, updateRegion); + UNLOCK(cl->sendMutex); rfbDecrClientRef(cl); sraRgnDestroy(updateRegion); |