Exit when the server goes away
parent
1baca2f9b4
commit
1baf3a902c
|
@ -610,7 +610,7 @@ extern rfbBool SendClientCutText(rfbClient* client,char *str, int len);
|
||||||
*/
|
*/
|
||||||
extern rfbBool HandleRFBServerMessage(rfbClient* client);
|
extern rfbBool HandleRFBServerMessage(rfbClient* client);
|
||||||
|
|
||||||
extern void ReadToBuffer(rfbClient* client);
|
extern rfbBool ReadToBuffer(rfbClient* client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a text chat message to the server.
|
* Sends a text chat message to the server.
|
||||||
|
|
|
@ -38,9 +38,9 @@ void run_main_loop_once(void);
|
||||||
|
|
||||||
rfbBool errorMessageOnReadFailure = TRUE;
|
rfbBool errorMessageOnReadFailure = TRUE;
|
||||||
|
|
||||||
void ReadToBuffer(rfbClient* client) {
|
rfbBool ReadToBuffer(rfbClient* client) {
|
||||||
if (client->buffered == RFB_BUF_SIZE)
|
if (client->buffered == RFB_BUF_SIZE)
|
||||||
return;
|
return FALSE;
|
||||||
|
|
||||||
ssize_t size;
|
ssize_t size;
|
||||||
|
|
||||||
|
@ -61,8 +61,13 @@ void ReadToBuffer(rfbClient* client) {
|
||||||
RFB_BUF_SIZE - client->buffered, MSG_DONTWAIT);
|
RFB_BUF_SIZE - client->buffered, MSG_DONTWAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (size == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
client->buffered += size;
|
client->buffered += size;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
rfbBool ReadFromRFBServer(rfbClient* client, char *out, unsigned int n)
|
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) {
|
||||||
while (n != 0 && client->buffered == 0) {
|
while (n != 0 && client->buffered == 0) {
|
||||||
run_main_loop_once();
|
run_main_loop_once();
|
||||||
ReadToBuffer(client);
|
if (!ReadToBuffer(client))
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int size = MIN(client->buffered, n);
|
unsigned int size = MIN(client->buffered, n);
|
||||||
|
|
|
@ -385,7 +385,8 @@ const char* vnc_client_get_desktop_name(const struct vnc_client* self)
|
||||||
|
|
||||||
int vnc_client_process(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))
|
if (!vnc_client_lock_handler(self))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue