From 5496b5c876c9a120711af8bfa0e0049e96d6f798 Mon Sep 17 00:00:00 2001 From: deuce <> Date: Wed, 2 Dec 2015 05:11:24 +0000 Subject: [PATCH] Hold the outpub_write mutex until the data is send, not just until it is removed from the ring buffer. This prevents the session thread from closing the socket before send() is called with the data. Fixed issue seen on techdorks.net with the 404.ssjs file (and likely others where static files were truncated on send). --- src/sbbs3/websrvr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sbbs3/websrvr.c b/src/sbbs3/websrvr.c index 3c35e9b956..6c3fa08dc4 100644 --- a/src/sbbs3/websrvr.c +++ b/src/sbbs3/websrvr.c @@ -6108,7 +6108,6 @@ void http_output_thread(void *arg) pthread_mutex_lock(&session->outbuf_write); RingBufRead(obuf, (uchar*)bufdata, avail); - pthread_mutex_unlock(&session->outbuf_write); if(chunked) { bufdata+=avail; *(bufdata++)='\r'; @@ -6118,6 +6117,7 @@ void http_output_thread(void *arg) if(!failed) sess_sendbuf(session, buf, len, &failed); + pthread_mutex_unlock(&session->outbuf_write); } thread_down(); /* Ensure outbuf isn't currently being drained */ -- GitLab