Removed GUAC_*_TIMEOUT, added usec_timeout parameters to functions which need them, updated docs.
This commit is contained in:
parent
a932c2f1a0
commit
087ed54fc2
@ -301,11 +301,13 @@ typedef int guac_client_init_handler(guac_client* client, int argc, char** argv)
|
||||
* Initialize and return a new guac_client. The pluggable client will be chosen based on
|
||||
* the first connect message received on the given file descriptor.
|
||||
*
|
||||
* @param client_fd The file descriptor associated with the socket associated with the connection to the
|
||||
* web-client tunnel.
|
||||
* @param client_fd The file descriptor associated with the socket associated
|
||||
* with the connection to the web-client tunnel.
|
||||
* @param usec_timeout The maximum number of microseconds to wait for each
|
||||
* instruction during the initial client handshake.
|
||||
* @return A pointer to the newly initialized client.
|
||||
*/
|
||||
guac_client* guac_get_client(int client_fd);
|
||||
guac_client* guac_get_client(int client_fd, int usec_timeout);
|
||||
|
||||
/**
|
||||
* Free all resources associated with the given client.
|
||||
|
@ -51,19 +51,6 @@
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* The number of milliseconds to wait for messages in any phase before
|
||||
* timing out and closing the connection with an error.
|
||||
*/
|
||||
#define GUAC_TIMEOUT 15000
|
||||
|
||||
/**
|
||||
* The number of microseconds to wait for messages in any phase before
|
||||
* timing out and closing the conncetion with an error. This is always
|
||||
* equal to GUAC_TIMEOUT * 1000.
|
||||
*/
|
||||
#define GUAC_USEC_TIMEOUT (GUAC_TIMEOUT*1000)
|
||||
|
||||
/**
|
||||
* An arbitrary timestamp denoting a relative time value in milliseconds.
|
||||
*/
|
||||
@ -348,10 +335,12 @@ int guac_send_cursor(GUACIO* io, int x, int y, cairo_surface_t* surface);
|
||||
* connection for parsing.
|
||||
*
|
||||
* @param io The GUACIO connection to use.
|
||||
* @param usec_timeout The maximum number of microseconds to wait before
|
||||
* giving up.
|
||||
* @return A positive value if data is available, negative on error, or
|
||||
* zero if no data is currently available.
|
||||
*/
|
||||
int guac_instructions_waiting(GUACIO* io);
|
||||
int guac_instructions_waiting(GUACIO* io, int usec_timeout);
|
||||
|
||||
/**
|
||||
* Reads a single instruction from the given GUACIO connection.
|
||||
@ -360,16 +349,19 @@ int guac_instructions_waiting(GUACIO* io);
|
||||
* returned, and guac_error is set appropriately.
|
||||
*
|
||||
* @param io The GUACIO connection to use.
|
||||
* @param usec_timeout The maximum number of microseconds to wait before
|
||||
* giving up.
|
||||
* @param parsed_instruction A pointer to a guac_instruction structure which
|
||||
* 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 instruction could not be read completely
|
||||
* because GUAC_TIMEOUT elapsed, in which case subsequent calls to
|
||||
* because the 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);
|
||||
int guac_read_instruction(GUACIO* io, int usec_timeout,
|
||||
guac_instruction* parsed_instruction);
|
||||
|
||||
/**
|
||||
* Returns an arbitrary timestamp. The difference between return values of any
|
||||
|
@ -128,7 +128,7 @@ void guac_client_free_buffer(guac_client* client, guac_layer* layer) {
|
||||
|
||||
}
|
||||
|
||||
guac_client* guac_get_client(int client_fd) {
|
||||
guac_client* guac_get_client(int client_fd, int usec_timeout) {
|
||||
|
||||
guac_client* client;
|
||||
GUACIO* io = guac_open(client_fd);
|
||||
@ -159,7 +159,7 @@ guac_client* guac_get_client(int client_fd) {
|
||||
int result;
|
||||
|
||||
/* Wait for data until timeout */
|
||||
result = guac_instructions_waiting(io);
|
||||
result = guac_instructions_waiting(io, usec_timeout);
|
||||
if (result == 0) {
|
||||
guac_send_error(io, "Select timeout.");
|
||||
guac_close(io);
|
||||
@ -172,7 +172,7 @@ guac_client* guac_get_client(int client_fd) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = guac_read_instruction(io, &instruction);
|
||||
result = guac_read_instruction(io, usec_timeout, &instruction);
|
||||
if (result < 0) {
|
||||
guac_close(io);
|
||||
return NULL;
|
||||
@ -254,7 +254,7 @@ guac_client* guac_get_client(int client_fd) {
|
||||
int result;
|
||||
|
||||
/* Wait for data until timeout */
|
||||
result = guac_instructions_waiting(io);
|
||||
result = guac_instructions_waiting(io, usec_timeout);
|
||||
if (result == 0) {
|
||||
guac_send_error(io, "Connect timeout.");
|
||||
guac_close(io);
|
||||
@ -267,7 +267,7 @@ guac_client* guac_get_client(int client_fd) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = guac_read_instruction(io, &instruction);
|
||||
result = guac_read_instruction(io, usec_timeout, &instruction);
|
||||
if (result < 0) {
|
||||
guac_log_error("Error reading instruction while waiting for connect");
|
||||
guac_close(io);
|
||||
|
@ -356,7 +356,8 @@ int __guac_fill_instructionbuf(GUACIO* io) {
|
||||
}
|
||||
|
||||
/* Returns new instruction if one exists, or NULL if no more instructions. */
|
||||
int guac_read_instruction(GUACIO* io, guac_instruction* parsed_instruction) {
|
||||
int guac_read_instruction(GUACIO* io, int usec_timeout,
|
||||
guac_instruction* parsed_instruction) {
|
||||
|
||||
int retval;
|
||||
int i = io->instructionbuf_parse_start;
|
||||
@ -441,7 +442,7 @@ int guac_read_instruction(GUACIO* io, guac_instruction* parsed_instruction) {
|
||||
}
|
||||
|
||||
/* No instruction yet? Get more data ... */
|
||||
retval = guac_select(io, GUAC_USEC_TIMEOUT);
|
||||
retval = guac_select(io, usec_timeout);
|
||||
if (retval <= 0)
|
||||
return retval;
|
||||
|
||||
@ -467,12 +468,12 @@ void guac_free_instruction(guac_instruction* instruction) {
|
||||
}
|
||||
|
||||
|
||||
int guac_instructions_waiting(GUACIO* io) {
|
||||
int guac_instructions_waiting(GUACIO* io, int usec_timeout) {
|
||||
|
||||
if (io->instructionbuf_used_length > 0)
|
||||
return 1;
|
||||
|
||||
return guac_select(io, GUAC_USEC_TIMEOUT);
|
||||
return guac_select(io, usec_timeout);
|
||||
}
|
||||
|
||||
guac_timestamp guac_current_timestamp() {
|
||||
|
Loading…
Reference in New Issue
Block a user