mirror of
https://github.com/tsl0922/ttyd.git
synced 2025-12-22 20:04:19 +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;
|
||||
|
||||
pthread_mutex_lock(&client->mutex);
|
||||
client->state = STATE_DONE;
|
||||
pthread_cond_signal(&client->cond);
|
||||
pthread_mutex_unlock(&client->mutex);
|
||||
if (pthread_mutex_trylock(&client->mutex)) {
|
||||
client->state = STATE_DONE;
|
||||
pthread_cond_signal(&client->cond);
|
||||
pthread_mutex_unlock(&client->mutex);
|
||||
}
|
||||
|
||||
// kill process (group) and free resource
|
||||
int pgid = getpgid(client->pid);
|
||||
|
||||
Reference in New Issue
Block a user