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 ) {