From fd15c4631bcce3e9ea1a82c03bfe9b72c47a3161 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Thu, 20 Oct 2011 23:01:24 +0000
Subject: [PATCH] Handle locking the same as other output methods.

---
 src/syncterm/ssh.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/syncterm/ssh.c b/src/syncterm/ssh.c
index 6f58578cf0..5157512d61 100644
--- a/src/syncterm/ssh.c
+++ b/src/syncterm/ssh.c
@@ -97,9 +97,7 @@ void ssh_output_thread(void *args)
 	while(ssh_active && !conn_api.terminate) {
 		pthread_mutex_lock(&(conn_outbuf.mutex));
 		wr=conn_buf_wait_bytes(&conn_outbuf, 1, 100);
-		pthread_mutex_unlock(&(conn_outbuf.mutex));
 		if(wr) {
-			pthread_mutex_lock(&(conn_outbuf.mutex));
 			wr=conn_buf_get(&conn_outbuf, conn_api.wr_buf, conn_api.wr_buf_size);
 			pthread_mutex_unlock(&(conn_outbuf.mutex));
 			sent=0;
@@ -118,6 +116,8 @@ void ssh_output_thread(void *args)
 			if(sent)
 				cl.FlushData(ssh_session);
 		}
+		else
+			pthread_mutex_unlock(&(conn_outbuf.mutex));
 	}
 	conn_api.output_thread_running=0;
 }
-- 
GitLab