summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Wang <gwang@php.net>2019-04-21 15:04:54 -0400
committerGeorge Wang <gwang@php.net>2019-04-21 15:04:54 -0400
commitce73841cdcfd86a2cf5d7e1c251095254985324d (patch)
tree91360f6584dd94a66e830c27f000a56749ebb2d8
parentccf051c317e606c2a4d9099c6e79a5c42bfdb298 (diff)
downloadphp-git-ce73841cdcfd86a2cf5d7e1c251095254985324d.tar.gz
Improved LSAPI_End_Response_r() .
-rw-r--r--sapi/litespeed/lsapilib.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c
index 371bc6b0e3..88a30a7f6a 100644
--- a/sapi/litespeed/lsapilib.c
+++ b/sapi/litespeed/lsapilib.c
@@ -1600,8 +1600,11 @@ int LSAPI_Accept_r( LSAPI_Request * pReq )
}
-static struct lsapi_packet_header finish = {'L', 'S',
- LSAPI_RESP_END, LSAPI_ENDIAN, {LSAPI_PACKET_HEADER_LEN} };
+static struct lsapi_packet_header finish_close[2] =
+{
+ {'L', 'S', LSAPI_RESP_END, LSAPI_ENDIAN, {LSAPI_PACKET_HEADER_LEN} },
+ {'L', 'S', LSAPI_CONN_CLOSE, LSAPI_ENDIAN, {LSAPI_PACKET_HEADER_LEN} }
+};
int LSAPI_Finish_r( LSAPI_Request * pReq )
@@ -1622,7 +1625,7 @@ int LSAPI_Finish_r( LSAPI_Request * pReq )
Flush_RespBuf_r( pReq );
}
- pReq->m_pIovecCur->iov_base = (void *)&finish;
+ pReq->m_pIovecCur->iov_base = (void *)finish_close;
pReq->m_pIovecCur->iov_len = LSAPI_PACKET_HEADER_LEN;
pReq->m_totalLen += LSAPI_PACKET_HEADER_LEN;
++pReq->m_pIovecCur;
@@ -1638,12 +1641,17 @@ int LSAPI_End_Response_r(LSAPI_Request * pReq)
{
if (!pReq)
return -1;
+ if (pReq->m_reqState & LSAPI_ST_BACKGROUND)
+ return 0;
if (pReq->m_reqState)
{
if ( pReq->m_fd != -1 )
{
if ( pReq->m_reqState & LSAPI_ST_RESP_HEADER )
{
+ if ( pReq->m_pRespHeaderBufPos <= pReq->m_pRespHeaderBuf )
+ return 0;
+
LSAPI_FinalizeRespHeaders_r( pReq );
}
if ( pReq->m_pRespBufPos != pReq->m_pRespBuf )
@@ -1651,14 +1659,13 @@ int LSAPI_End_Response_r(LSAPI_Request * pReq)
Flush_RespBuf_r( pReq );
}
- pReq->m_pIovecCur->iov_base = (void *)&finish;
- pReq->m_pIovecCur->iov_len = LSAPI_PACKET_HEADER_LEN;
- pReq->m_totalLen += LSAPI_PACKET_HEADER_LEN;
+ pReq->m_pIovecCur->iov_base = (void *)finish_close;
+ pReq->m_pIovecCur->iov_len = LSAPI_PACKET_HEADER_LEN << 1;
+ pReq->m_totalLen += LSAPI_PACKET_HEADER_LEN << 1;
++pReq->m_pIovecCur;
LSAPI_Flush_r( pReq );
+ lsapi_close_connection(pReq);
}
- send_conn_close_notification(pReq->m_fd);
- lsapi_close_connection(pReq);
pReq->m_reqState |= LSAPI_ST_BACKGROUND;
}
return 0;
@@ -3163,8 +3170,8 @@ static int lsapi_prefork_server_accept( lsapi_prefork_server * pServer,
#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
*s_avail_pages = sysconf(_SC_AVPHYS_PAGES);
- lsapi_log("Memory total: %zd, free: %zd, free %%%zd\n",
- s_total_pages, *s_avail_pages, *s_avail_pages * 100 / s_total_pages);
+// lsapi_log("Memory total: %zd, free: %zd, free %%%zd\n",
+// s_total_pages, *s_avail_pages, *s_avail_pages * 100 / s_total_pages);
#endif
FD_ZERO( &readfds );