From 4b272cc0cf9a827cb014de41926e6a3f4c98fa03 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 31 Jul 2017 12:38:14 +0200 Subject: [PATCH] rsrv: locking in cas_send_bs_msg() Must lock around "pclient->send.stk = 0u;" --- src/rsrv/caserverio.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/rsrv/caserverio.c b/src/rsrv/caserverio.c index b6cb4b92c..f84412213 100644 --- a/src/rsrv/caserverio.c +++ b/src/rsrv/caserverio.c @@ -45,6 +45,10 @@ void cas_send_bs_msg ( struct client *pclient, int lock_needed ) { int status; + if ( lock_needed ) { + SEND_LOCK ( pclient ); + } + if ( CASDEBUG > 2 && pclient->send.stk ) { errlogPrintf ( "CAS: Sending a message of %d bytes\n", pclient->send.stk ); } @@ -55,13 +59,11 @@ void cas_send_bs_msg ( struct client *pclient, int lock_needed ) pclient->sock, (unsigned) pclient->addr.sin_addr.s_addr ); } pclient->send.stk = 0u; + if(lock_needed) + SEND_UNLOCK(pclient); return; } - if ( lock_needed ) { - SEND_LOCK ( pclient ); - } - while ( pclient->send.stk && ! pclient->disconnect ) { status = send ( pclient->sock, pclient->send.buf, pclient->send.stk, 0 ); if ( status >= 0 ) {