From 2037f62a00b3d1aed7d1036eda177503f7ca8746 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Fri, 2 Jun 2006 17:21:13 +0000
Subject: [PATCH] Move the mutex destruction until the session destruction...
 possible the hung threads are hanging while attempting to lock a destroyed
 semaphore.

---
 src/sbbs3/websrvr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/sbbs3/websrvr.c b/src/sbbs3/websrvr.c
index 0f0f6b5ec0..77e56cafb3 100644
--- a/src/sbbs3/websrvr.c
+++ b/src/sbbs3/websrvr.c
@@ -4026,7 +4026,6 @@ void http_output_thread(void *arg)
 			sock_sendbuf(&session->socket, buf, len, &failed);
 		pthread_mutex_unlock(&session->outbuf_write);
     }
-	pthread_mutex_destroy(&session->outbuf_write);
 	thread_down();
 	sem_post(&session->output_thread_terminated);
 }
@@ -4101,6 +4100,7 @@ void http_session_thread(void* arg)
 			close_socket(&session.socket);
 			sem_wait(&session.output_thread_terminated);
 			RingBufDispose(&session.outbuf);
+			pthread_mutex_destroy(&session->outbuf_write);
 			lprintf(LOG_NOTICE,"%04d !CLIENT BLOCKED in host.can: %s", session.socket, host_name);
 			thread_down();
 			session_threads--;
@@ -4113,6 +4113,7 @@ void http_session_thread(void* arg)
 		close_socket(&session.socket);
 		sem_wait(&session.output_thread_terminated);
 		RingBufDispose(&session.outbuf);
+		pthread_mutex_destroy(&session->outbuf_write);
 		lprintf(LOG_NOTICE,"%04d !CLIENT BLOCKED in ip.can: %s", session.socket, session.host_ip);
 		thread_down();
 		session_threads--;
@@ -4225,6 +4226,7 @@ void http_session_thread(void* arg)
 	sem_wait(&session.output_thread_terminated);
 	sem_destroy(&session.output_thread_terminated);
 	RingBufDispose(&session.outbuf);
+	pthread_mutex_destroy(&session->outbuf_write);
 
 	active_clients--;
 	update_clients();
-- 
GitLab