Merge 1.3.0 changes back to master.
This commit is contained in:
commit
5124e78e05
@ -44,6 +44,8 @@ char __guac_socket_BASE64_CHARACTERS[64] = {
|
||||
|
||||
static void* __guac_socket_keep_alive_thread(void* data) {
|
||||
|
||||
int old_cancelstate;
|
||||
|
||||
/* Calculate sleep interval */
|
||||
struct timespec interval;
|
||||
interval.tv_sec = GUAC_SOCKET_KEEP_ALIVE_INTERVAL / 1000;
|
||||
@ -65,8 +67,11 @@ static void* __guac_socket_keep_alive_thread(void* data) {
|
||||
|
||||
}
|
||||
|
||||
/* Sleep until next keep-alive check */
|
||||
/* Sleep until next keep-alive check, but allow thread cancellation
|
||||
* during that sleep */
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old_cancelstate);
|
||||
nanosleep(&interval, NULL);
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_cancelstate);
|
||||
|
||||
}
|
||||
|
||||
@ -202,9 +207,11 @@ void guac_socket_free(guac_socket* socket) {
|
||||
/* Mark as closed */
|
||||
socket->state = GUAC_SOCKET_CLOSED;
|
||||
|
||||
/* Wait for keep-alive, if enabled */
|
||||
if (socket->__keep_alive_enabled)
|
||||
/* Stop keep-alive thread, if enabled */
|
||||
if (socket->__keep_alive_enabled) {
|
||||
pthread_cancel(socket->__keep_alive_thread);
|
||||
pthread_join(socket->__keep_alive_thread, NULL);
|
||||
}
|
||||
|
||||
free(socket);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user