mirror of
https://github.com/tsl0922/ttyd.git
synced 2025-12-23 04:14:18 +01:00
protocol: do not block main thread when destroying client
This commit is contained in:
@@ -135,10 +135,11 @@ tty_client_destroy(struct tty_client *client) {
|
|||||||
|
|
||||||
client->running = false;
|
client->running = false;
|
||||||
|
|
||||||
pthread_mutex_lock(&client->mutex);
|
if (pthread_mutex_trylock(&client->mutex)) {
|
||||||
client->state = STATE_DONE;
|
client->state = STATE_DONE;
|
||||||
pthread_cond_signal(&client->cond);
|
pthread_cond_signal(&client->cond);
|
||||||
pthread_mutex_unlock(&client->mutex);
|
pthread_mutex_unlock(&client->mutex);
|
||||||
|
}
|
||||||
|
|
||||||
// kill process (group) and free resource
|
// kill process (group) and free resource
|
||||||
int pgid = getpgid(client->pid);
|
int pgid = getpgid(client->pid);
|
||||||
|
|||||||
Reference in New Issue
Block a user