term: destroy: don't wait for PTY reading thread if it was never started

This commit is contained in:
Daniel Eklöf 2020-06-19 14:53:07 +02:00
parent fd32fa0a0f
commit 984d008250
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -1289,13 +1289,16 @@ term_destroy(struct terminal *term)
tll_free(term->render.workers.queue); tll_free(term->render.workers.queue);
/* Make sure we wake up the reader thread if it is blocking on a full buffer */ /* Make sure we wake up the reader thread if it is blocking on a full buffer */
mtx_lock(&term->ptmx_read_buffer.lock); if (term->ptmx_read_buffer.thread_id != 0) {
term->ptmx_read_buffer.buf[0].len = 0; mtx_lock(&term->ptmx_read_buffer.lock);
term->ptmx_read_buffer.buf[1].len = 0; term->ptmx_read_buffer.buf[0].len = 0;
cnd_signal(&term->ptmx_read_buffer.cond); term->ptmx_read_buffer.buf[1].len = 0;
mtx_unlock(&term->ptmx_read_buffer.lock); cnd_signal(&term->ptmx_read_buffer.cond);
mtx_unlock(&term->ptmx_read_buffer.lock);
thrd_join(term->ptmx_read_buffer.thread_id, NULL);
}
thrd_join(term->ptmx_read_buffer.thread_id, NULL);
cnd_destroy(&term->ptmx_read_buffer.cond); cnd_destroy(&term->ptmx_read_buffer.cond);
mtx_destroy(&term->ptmx_read_buffer.lock); mtx_destroy(&term->ptmx_read_buffer.lock);
free(term->ptmx_read_buffer.buf[0].data); free(term->ptmx_read_buffer.buf[0].data);