Exit when the server goes away

pull/23/head
Andri Yngvason 2022-10-09 19:59:31 +00:00
parent 1baca2f9b4
commit 1baf3a902c
3 changed files with 12 additions and 5 deletions

View File

@ -610,7 +610,7 @@ extern rfbBool SendClientCutText(rfbClient* client,char *str, int len);
*/
extern rfbBool HandleRFBServerMessage(rfbClient* client);
extern void ReadToBuffer(rfbClient* client);
extern rfbBool ReadToBuffer(rfbClient* client);
/**
* Sends a text chat message to the server.

View File

@ -38,9 +38,9 @@ void run_main_loop_once(void);
rfbBool errorMessageOnReadFailure = TRUE;
void ReadToBuffer(rfbClient* client) {
rfbBool ReadToBuffer(rfbClient* client) {
if (client->buffered == RFB_BUF_SIZE)
return;
return FALSE;
ssize_t size;
@ -61,8 +61,13 @@ void ReadToBuffer(rfbClient* client) {
RFB_BUF_SIZE - client->buffered, MSG_DONTWAIT);
}
if (size == 0)
return FALSE;
if (size > 0)
client->buffered += size;
return TRUE;
}
rfbBool ReadFromRFBServer(rfbClient* client, char *out, unsigned int n)
@ -73,7 +78,8 @@ rfbBool ReadFromRFBServer(rfbClient* client, char *out, unsigned int n)
while (n != 0) {
while (n != 0 && client->buffered == 0) {
run_main_loop_once();
ReadToBuffer(client);
if (!ReadToBuffer(client))
return FALSE;
}
unsigned int size = MIN(client->buffered, n);

View File

@ -385,7 +385,8 @@ const char* vnc_client_get_desktop_name(const struct vnc_client* self)
int vnc_client_process(struct vnc_client* self)
{
ReadToBuffer(self->client);
if (!ReadToBuffer(self->client))
return -1;
if (!vnc_client_lock_handler(self))
return 0;