Changed semantics of guac_read_instruction, fixed timeout.
This commit is contained in:
parent
3e14b52b1c
commit
a08cd5b8b7
@ -248,9 +248,10 @@ int guac_instructions_waiting(GUACIO* io);
|
||||
* will be populated with data read from the given
|
||||
* GUACIO connection.
|
||||
* @return A positive value if data was successfully read, negative on
|
||||
* error, or zero if the instrucion could not be read completely,
|
||||
* in which case, subsequent calls to guac_read_instruction() will
|
||||
* return the parsed instruction once enough data is available.
|
||||
* error, or zero if the instruction could not be read completely
|
||||
* because GUAC_TIMEOUT elapsed, in which case subsequent calls to
|
||||
* guac_read_instruction() will return the parsed instruction once
|
||||
* enough data is available.
|
||||
*/
|
||||
int guac_read_instruction(GUACIO* io, guac_instruction* parsed_instruction);
|
||||
|
||||
|
@ -308,6 +308,7 @@ guac_client* guac_get_client(int client_fd) {
|
||||
}
|
||||
|
||||
void guac_client_stop(guac_client* client) {
|
||||
fprintf(stderr, "***************** STOPPING! *********************\n");
|
||||
client->state = STOPPING;
|
||||
}
|
||||
|
||||
@ -397,25 +398,16 @@ void* __guac_client_input_thread(void* data) {
|
||||
guac_instruction instruction;
|
||||
|
||||
/* Guacamole client input loop */
|
||||
while (client->state == RUNNING && guac_instructions_waiting(io) > 0) {
|
||||
|
||||
int retval;
|
||||
while ((retval = guac_read_instruction(io, &instruction)) > 0) {
|
||||
|
||||
if (guac_client_handle_instruction(client, &instruction) < 0) {
|
||||
guac_free_instruction_data(&instruction);
|
||||
guac_client_stop(client);
|
||||
return NULL;
|
||||
}
|
||||
while (client->state == RUNNING && guac_read_instruction(io, &instruction) > 0) {
|
||||
|
||||
/* Call handler, stop on error */
|
||||
if (guac_client_handle_instruction(client, &instruction) < 0) {
|
||||
guac_free_instruction_data(&instruction);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (retval < 0)
|
||||
break;
|
||||
|
||||
/* Otherwise, retval == 0 implies unfinished instruction */
|
||||
/* Free allocate instruction data */
|
||||
guac_free_instruction_data(&instruction);
|
||||
|
||||
}
|
||||
|
||||
|
@ -497,16 +497,15 @@ int guac_read_instruction(GUACIO* io, guac_instruction* parsed_instruction) {
|
||||
}
|
||||
|
||||
/* No instruction yet? Get more data ... */
|
||||
retval = guac_select(io, 1000);
|
||||
retval = guac_select(io, GUAC_USEC_TIMEOUT);
|
||||
if (retval <= 0)
|
||||
return retval;
|
||||
|
||||
/* If more data is available, fill into buffer */
|
||||
retval = __guac_fill_instructionbuf(io);
|
||||
if (retval < 0)
|
||||
return retval;
|
||||
if (retval < 0) return retval; /* Error */
|
||||
if (retval == 0) return -1; /* EOF */
|
||||
|
||||
if (retval == 0)
|
||||
return -1; /* EOF */
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user