diff --git a/libguac/include/client.h b/libguac/include/client.h index 35335985..8d87d092 100644 --- a/libguac/include/client.h +++ b/libguac/include/client.h @@ -296,8 +296,11 @@ guac_client* guac_get_client(int client_fd); * Enter the main network message handling loop for the given client. * * @param client The proxy client to start handling messages of/for. + * @return Zero if the client successfully started, non-zero if an error + * occurs during startup. Note that this function will still return + * zero if an error occurs while the client is running. */ -void guac_start_client(guac_client* client); +int guac_start_client(guac_client* client); /** * Free all resources associated with the given client. diff --git a/libguac/src/client.c b/libguac/src/client.c index 276c7f83..cff714bc 100644 --- a/libguac/src/client.c +++ b/libguac/src/client.c @@ -387,18 +387,16 @@ void* __guac_client_input_thread(void* data) { } -void guac_start_client(guac_client* client) { +int guac_start_client(guac_client* client) { pthread_t input_thread, output_thread; if (pthread_create(&output_thread, NULL, __guac_client_output_thread, (void*) client)) { - /* THIS FUNCTION SHOULD RETURN A VALUE! */ - return; + return -1; } if (pthread_create(&input_thread, NULL, __guac_client_input_thread, (void*) client)) { - /* THIS FUNCTION SHOULD RETURN A VALUE! */ - return; + return -1; } /* Wait for I/O threads */ @@ -406,6 +404,7 @@ void guac_start_client(guac_client* client) { pthread_join(output_thread, NULL); /* Done */ + return 0; }