Skip to content

Commit ce73841

Browse files
author
George Wang
committed
Improved LSAPI_End_Response_r() .
1 parent ccf051c commit ce73841

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

sapi/litespeed/lsapilib.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,8 +1600,11 @@ int LSAPI_Accept_r( LSAPI_Request * pReq )
16001600
}
16011601

16021602

1603-
static struct lsapi_packet_header finish = {'L', 'S',
1604-
LSAPI_RESP_END, LSAPI_ENDIAN, {LSAPI_PACKET_HEADER_LEN} };
1603+
static struct lsapi_packet_header finish_close[2] =
1604+
{
1605+
{'L', 'S', LSAPI_RESP_END, LSAPI_ENDIAN, {LSAPI_PACKET_HEADER_LEN} },
1606+
{'L', 'S', LSAPI_CONN_CLOSE, LSAPI_ENDIAN, {LSAPI_PACKET_HEADER_LEN} }
1607+
};
16051608

16061609

16071610
int LSAPI_Finish_r( LSAPI_Request * pReq )
@@ -1622,7 +1625,7 @@ int LSAPI_Finish_r( LSAPI_Request * pReq )
16221625
Flush_RespBuf_r( pReq );
16231626
}
16241627

1625-
pReq->m_pIovecCur->iov_base = (void *)&finish;
1628+
pReq->m_pIovecCur->iov_base = (void *)finish_close;
16261629
pReq->m_pIovecCur->iov_len = LSAPI_PACKET_HEADER_LEN;
16271630
pReq->m_totalLen += LSAPI_PACKET_HEADER_LEN;
16281631
++pReq->m_pIovecCur;
@@ -1638,27 +1641,31 @@ int LSAPI_End_Response_r(LSAPI_Request * pReq)
16381641
{
16391642
if (!pReq)
16401643
return -1;
1644+
if (pReq->m_reqState & LSAPI_ST_BACKGROUND)
1645+
return 0;
16411646
if (pReq->m_reqState)
16421647
{
16431648
if ( pReq->m_fd != -1 )
16441649
{
16451650
if ( pReq->m_reqState & LSAPI_ST_RESP_HEADER )
16461651
{
1652+
if ( pReq->m_pRespHeaderBufPos <= pReq->m_pRespHeaderBuf )
1653+
return 0;
1654+
16471655
LSAPI_FinalizeRespHeaders_r( pReq );
16481656
}
16491657
if ( pReq->m_pRespBufPos != pReq->m_pRespBuf )
16501658
{
16511659
Flush_RespBuf_r( pReq );
16521660
}
16531661

1654-
pReq->m_pIovecCur->iov_base = (void *)&finish;
1655-
pReq->m_pIovecCur->iov_len = LSAPI_PACKET_HEADER_LEN;
1656-
pReq->m_totalLen += LSAPI_PACKET_HEADER_LEN;
1662+
pReq->m_pIovecCur->iov_base = (void *)finish_close;
1663+
pReq->m_pIovecCur->iov_len = LSAPI_PACKET_HEADER_LEN << 1;
1664+
pReq->m_totalLen += LSAPI_PACKET_HEADER_LEN << 1;
16571665
++pReq->m_pIovecCur;
16581666
LSAPI_Flush_r( pReq );
1667+
lsapi_close_connection(pReq);
16591668
}
1660-
send_conn_close_notification(pReq->m_fd);
1661-
lsapi_close_connection(pReq);
16621669
pReq->m_reqState |= LSAPI_ST_BACKGROUND;
16631670
}
16641671
return 0;
@@ -3163,8 +3170,8 @@ static int lsapi_prefork_server_accept( lsapi_prefork_server * pServer,
31633170

31643171
#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
31653172
*s_avail_pages = sysconf(_SC_AVPHYS_PAGES);
3166-
lsapi_log("Memory total: %zd, free: %zd, free %%%zd\n",
3167-
s_total_pages, *s_avail_pages, *s_avail_pages * 100 / s_total_pages);
3173+
// lsapi_log("Memory total: %zd, free: %zd, free %%%zd\n",
3174+
// s_total_pages, *s_avail_pages, *s_avail_pages * 100 / s_total_pages);
31683175

31693176
#endif
31703177
FD_ZERO( &readfds );

0 commit comments

Comments
 (0)