update to LSAPI 6.6

Conflicts:
	sapi/litespeed/lsapi_main.c
This commit is contained in:
George Wang 2013-11-26 18:53:35 -05:00
parent e3df0c5f60
commit 1f46bec9ce
2 changed files with 36 additions and 10 deletions

View file

@ -370,7 +370,7 @@ static void sapi_lsapi_log_message(char *message TSRMLS_DC)
static sapi_module_struct lsapi_sapi_module = static sapi_module_struct lsapi_sapi_module =
{ {
"litespeed", "litespeed",
"LiteSpeed V6.4", "LiteSpeed V6.6",
php_lsapi_startup, /* startup */ php_lsapi_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */ php_module_shutdown_wrapper, /* shutdown */

View file

@ -1229,6 +1229,7 @@ int LSAPI_IsRunning(void)
int LSAPI_InitRequest( LSAPI_Request * pReq, int fd ) int LSAPI_InitRequest( LSAPI_Request * pReq, int fd )
{ {
int newfd;
if ( !pReq ) if ( !pReq )
return -1; return -1;
memset( pReq, 0, sizeof( LSAPI_Request ) ); memset( pReq, 0, sizeof( LSAPI_Request ) );
@ -1243,6 +1244,13 @@ int LSAPI_InitRequest( LSAPI_Request * pReq, int fd )
if ( allocateRespHeaderBuf( pReq, LSAPI_INIT_RESP_HEADER_LEN ) == -1 ) if ( allocateRespHeaderBuf( pReq, LSAPI_INIT_RESP_HEADER_LEN ) == -1 )
return -1; return -1;
if ( fd == STDIN_FILENO )
{
fd = dup( fd );
newfd = open( "/dev/null", O_RDWR );
dup2( newfd, STDIN_FILENO );
}
if ( isPipe( fd ) ) if ( isPipe( fd ) )
{ {
pReq->m_fdListen = -1; pReq->m_fdListen = -1;
@ -2404,6 +2412,8 @@ typedef struct _lsapi_prefork_server
int m_iAvoidFork; int m_iAvoidFork;
lsapi_child_status * m_pChildrenStatus; lsapi_child_status * m_pChildrenStatus;
lsapi_child_status * m_pChildrenStatusCur;
lsapi_child_status * m_pChildrenStatusEnd;
}lsapi_prefork_server; }lsapi_prefork_server;
@ -2492,11 +2502,15 @@ static void lsapi_cleanup(int signal)
static lsapi_child_status * find_child_status( int pid ) static lsapi_child_status * find_child_status( int pid )
{ {
lsapi_child_status * pStatus = g_prefork_server->m_pChildrenStatus; lsapi_child_status * pStatus = g_prefork_server->m_pChildrenStatus;
lsapi_child_status * pEnd = g_prefork_server->m_pChildrenStatus + g_prefork_server->m_iMaxChildren * 2; lsapi_child_status * pEnd = g_prefork_server->m_pChildrenStatusEnd;
while( pStatus < pEnd ) while( pStatus < pEnd )
{ {
if ( pStatus->m_pid == pid ) if ( pStatus->m_pid == pid )
{
if ( pStatus + 1 > g_prefork_server->m_pChildrenStatusCur )
g_prefork_server->m_pChildrenStatusCur = pStatus + 1;
return pStatus; return pStatus;
}
++pStatus; ++pStatus;
} }
return NULL; return NULL;
@ -2531,8 +2545,12 @@ static void lsapi_sigchild( int signal )
{ {
child_status->m_pid = 0; child_status->m_pid = 0;
--g_prefork_server->m_iCurChildren; --g_prefork_server->m_iCurChildren;
} }
} }
while(( g_prefork_server->m_pChildrenStatusCur > g_prefork_server->m_pChildrenStatus )
&&( g_prefork_server->m_pChildrenStatusCur[-1].m_pid == 0 ))
--g_prefork_server->m_pChildrenStatusCur;
} }
@ -2541,7 +2559,7 @@ static int lsapi_init_children_status()
int size = 4096; int size = 4096;
char * pBuf; char * pBuf;
size = g_prefork_server->m_iMaxChildren * sizeof( lsapi_child_status ) * 2; size = (g_prefork_server->m_iMaxChildren + g_prefork_server->m_iExtraChildren ) * sizeof( lsapi_child_status ) * 2;
size = (size + 4095 ) / 4096 * 4096; size = (size + 4095 ) / 4096 * 4096;
pBuf =( char*) mmap( NULL, size, PROT_READ | PROT_WRITE, pBuf =( char*) mmap( NULL, size, PROT_READ | PROT_WRITE,
MAP_ANON | MAP_SHARED, -1, 0 ); MAP_ANON | MAP_SHARED, -1, 0 );
@ -2552,6 +2570,8 @@ static int lsapi_init_children_status()
} }
memset( pBuf, 0, size ); memset( pBuf, 0, size );
g_prefork_server->m_pChildrenStatus = (lsapi_child_status *)pBuf; g_prefork_server->m_pChildrenStatus = (lsapi_child_status *)pBuf;
g_prefork_server->m_pChildrenStatusCur = (lsapi_child_status *)pBuf;
g_prefork_server->m_pChildrenStatusEnd = (lsapi_child_status *)pBuf + size / sizeof( lsapi_child_status );
return 0; return 0;
} }
@ -2581,7 +2601,7 @@ static void lsapi_check_child_status( long tmCur )
int dying = 0; int dying = 0;
int count = 0; int count = 0;
lsapi_child_status * pStatus = g_prefork_server->m_pChildrenStatus; lsapi_child_status * pStatus = g_prefork_server->m_pChildrenStatus;
lsapi_child_status * pEnd = g_prefork_server->m_pChildrenStatus + g_prefork_server->m_iMaxChildren * 2; lsapi_child_status * pEnd = g_prefork_server->m_pChildrenStatusCur;
while( pStatus < pEnd ) while( pStatus < pEnd )
{ {
tobekilled = 0; tobekilled = 0;
@ -2594,13 +2614,15 @@ static void lsapi_check_child_status( long tmCur )
if (( g_prefork_server->m_iCurChildren - dying > g_prefork_server->m_iMaxChildren)|| if (( g_prefork_server->m_iCurChildren - dying > g_prefork_server->m_iMaxChildren)||
( idle > g_prefork_server->m_iMaxIdleChildren )) ( idle > g_prefork_server->m_iMaxIdleChildren ))
{ {
tobekilled = SIGUSR1; ++pStatus->m_iKillSent;
//tobekilled = SIGUSR1;
} }
else else
{ {
if (( s_max_idle_secs> 0)&&(tmCur - pStatus->m_tmWaitBegin > s_max_idle_secs + 5 )) if (( s_max_idle_secs> 0)&&(tmCur - pStatus->m_tmWaitBegin > s_max_idle_secs + 5 ))
{ {
tobekilled = SIGUSR1; ++pStatus->m_iKillSent;
//tobekilled = SIGUSR1;
} }
} }
if ( !tobekilled ) if ( !tobekilled )
@ -2734,6 +2756,8 @@ static int lsapi_prefork_server_accept( lsapi_prefork_server * pServer, LSAPI_Re
if ( pServer->m_iCurChildren >= (pServer->m_iMaxChildren + pServer->m_iExtraChildren ) ) if ( pServer->m_iCurChildren >= (pServer->m_iMaxChildren + pServer->m_iExtraChildren ) )
{ {
fprintf( stderr, "Reached max children process limit: %d, extra: %d, current: %d, please increase LSAPI_CHILDREN.\n",
pServer->m_iMaxChildren, pServer->m_iExtraChildren, pServer->m_iCurChildren );
usleep( 100000 ); usleep( 100000 );
continue; continue;
} }
@ -2894,7 +2918,7 @@ int LSAPI_Prefork_Accept_r( LSAPI_Request * pReq )
{ {
if ( !g_running ) if ( !g_running )
return -1; return -1;
if (( s_pChildStatus )&&( s_pChildStatus->m_iKillSent )) if ((s_req_processed)&&( s_pChildStatus )&&( s_pChildStatus->m_iKillSent ))
return -1; return -1;
FD_ZERO( &readfds ); FD_ZERO( &readfds );
FD_SET( fd, &readfds ); FD_SET( fd, &readfds );
@ -2922,7 +2946,7 @@ int LSAPI_Prefork_Accept_r( LSAPI_Request * pReq )
} }
else if ( ret >= 1 ) else if ( ret >= 1 )
{ {
if (( s_pChildStatus )&&( s_pChildStatus->m_iKillSent )) if (s_req_processed && ( s_pChildStatus )&&( s_pChildStatus->m_iKillSent ))
return -1; return -1;
if ( fd == pReq->m_fdListen ) if ( fd == pReq->m_fdListen )
{ {
@ -3084,6 +3108,8 @@ static int lsapi_initSuEXEC()
{ {
if ( g_prefork_server->m_iMaxChildren < 100 ) if ( g_prefork_server->m_iMaxChildren < 100 )
g_prefork_server->m_iMaxChildren = 100; g_prefork_server->m_iMaxChildren = 100;
if ( g_prefork_server->m_iExtraChildren < 1000 )
g_prefork_server->m_iExtraChildren = 1000;
} }
} }
if ( !s_defaultUid || !s_defaultGid ) if ( !s_defaultUid || !s_defaultGid )