Skip to content

Commit 30de357

Browse files
author
George Wang
committed
Merge branch 'PHP-7.3' into PHP-7.4
2 parents 1a031a2 + 82f35ab commit 30de357

File tree

1 file changed

+62
-62
lines changed

1 file changed

+62
-62
lines changed

sapi/litespeed/lsapi_main.c

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include <sys/socket.h>
4848
#include <arpa/inet.h>
4949
#include <netinet/in.h>
50+
#include <sys/time.h>
5051

5152
#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
5253
#include "lscriu.c"
@@ -602,7 +603,7 @@ static int sapi_lsapi_activate()
602603
static sapi_module_struct lsapi_sapi_module =
603604
{
604605
"litespeed",
605-
"LiteSpeed V7.4.3",
606+
"LiteSpeed V7.5",
606607

607608
php_lsapi_startup, /* startup */
608609
php_module_shutdown_wrapper, /* shutdown */
@@ -681,66 +682,90 @@ static void lsapi_sigsegv( int signal )
681682

682683
static int clean_onexit = 1;
683684

684-
static void lsapi_sigterm( int signal )
685+
686+
static void lsapi_clean_shutdown()
685687
{
686-
struct sigaction act, old_act;
688+
struct sigaction act;
687689
int sa_rc;
690+
struct itimerval tmv;
691+
#if PHP_MAJOR_VERSION >= 7
692+
zend_string * key;
693+
#endif
694+
clean_onexit = 1;
695+
sigemptyset(&act.sa_mask);
696+
act.sa_flags = 0;
697+
act.sa_handler = lsapi_sigsegv;
698+
sa_rc = sigaction(SIGINT, &act, NULL);
699+
sa_rc = sigaction(SIGQUIT, &act, NULL);
700+
sa_rc = sigaction(SIGILL, &act, NULL);
701+
sa_rc = sigaction(SIGABRT, &act, NULL);
702+
sa_rc = sigaction(SIGBUS, &act, NULL);
703+
sa_rc = sigaction(SIGSEGV, &act, NULL);
704+
sa_rc = sigaction(SIGTERM, &act, NULL);
705+
706+
sa_rc = sigaction(SIGPROF, &act, NULL);
707+
memset(&tmv, 0, sizeof(struct itimerval));
708+
tmv.it_value.tv_sec = 0;
709+
tmv.it_value.tv_usec = 100000;
710+
setitimer(ITIMER_PROF, &tmv, NULL);
711+
712+
#if PHP_MAJOR_VERSION >= 7
713+
key = zend_string_init("error_reporting", 15, 1);
714+
zend_alter_ini_entry_chars_ex(key, "0", 1,
715+
PHP_INI_SYSTEM, PHP_INI_STAGE_SHUTDOWN, 1);
716+
zend_string_release(key);
717+
#else
718+
zend_alter_ini_entry("error_reporting", 16, "0", 1,
719+
PHP_INI_SYSTEM, PHP_INI_STAGE_SHUTDOWN);
720+
#endif
721+
722+
zend_try {
723+
php_request_shutdown(NULL);
724+
} zend_end_try();
725+
}
726+
727+
static void lsapi_sigterm(int signal)
728+
{
688729

689730
// fprintf(stderr, "lsapi_sigterm: %d: clean_onexit %d\n", getpid(), clean_onexit );
690731
if(!clean_onexit)
691732
{
692-
clean_onexit = 1;
693-
act.sa_flags = 0;
694-
act.sa_handler = lsapi_sigsegv;
695-
sa_rc = sigaction( SIGINT, &act, &old_act );
696-
sa_rc = sigaction( SIGQUIT, &act, &old_act );
697-
sa_rc = sigaction( SIGILL, &act, &old_act );
698-
sa_rc = sigaction( SIGABRT, &act, &old_act );
699-
sa_rc = sigaction( SIGBUS, &act, &old_act );
700-
sa_rc = sigaction( SIGSEGV, &act, &old_act );
701-
sa_rc = sigaction( SIGTERM, &act, &old_act );
702-
703-
zend_try {
704-
php_request_shutdown(NULL);
705-
} zend_end_try();
733+
lsapi_clean_shutdown();
706734
}
707735
exit(1);
708736
}
709737

710-
static void lsapi_atexit( void )
738+
static void lsapi_atexit(void)
711739
{
712-
struct sigaction act, old_act;
713-
int sa_rc;
714-
715740
//fprintf(stderr, "lsapi_atexit: %d: clean_onexit %d\n", getpid(), clean_onexit );
716741
if(!clean_onexit)
717742
{
718-
clean_onexit = 1;
719-
act.sa_flags = 0;
720-
act.sa_handler = lsapi_sigsegv;
721-
sa_rc = sigaction( SIGINT, &act, &old_act );
722-
sa_rc = sigaction( SIGQUIT, &act, &old_act );
723-
sa_rc = sigaction( SIGILL, &act, &old_act );
724-
sa_rc = sigaction( SIGABRT, &act, &old_act );
725-
sa_rc = sigaction( SIGBUS, &act, &old_act );
726-
sa_rc = sigaction( SIGSEGV, &act, &old_act );
727-
sa_rc = sigaction( SIGTERM, &act, &old_act );
728-
729-
//fprintf(stderr, "lsapi_atexit: %d: before php_request_shutdown\n", getpid(), clean_onexit );
730-
zend_try {
731-
php_request_shutdown(NULL);
732-
} zend_end_try();
743+
lsapi_clean_shutdown();
733744
}
734745
}
735746

747+
736748
static int lsapi_module_main(int show_source)
737749
{
750+
struct sigaction act;
751+
int sa_rc;
738752
zend_file_handle file_handle;
739753
memset(&file_handle, 0, sizeof(file_handle));
740754
if (php_request_startup() == FAILURE ) {
741755
return -1;
742756
}
743757

758+
sigemptyset(&act.sa_mask);
759+
act.sa_flags = SA_NODEFER;
760+
act.sa_handler = lsapi_sigterm;
761+
sa_rc = sigaction( SIGINT, &act, NULL);
762+
sa_rc = sigaction( SIGQUIT, &act, NULL);
763+
sa_rc = sigaction( SIGILL, &act, NULL);
764+
sa_rc = sigaction( SIGABRT, &act, NULL);
765+
sa_rc = sigaction( SIGBUS, &act, NULL);
766+
sa_rc = sigaction( SIGSEGV, &act, NULL);
767+
sa_rc = sigaction( SIGTERM, &act, NULL);
768+
744769
clean_onexit = 0;
745770

746771
if (show_source) {
@@ -1367,6 +1392,7 @@ void start_children( int children )
13671392
setsid();
13681393

13691394
/* Set up handler to kill children upon exit */
1395+
sigemptyset(&act.sa_mask);
13701396
act.sa_flags = 0;
13711397
act.sa_handler = litespeed_cleanup;
13721398
if( sigaction( SIGTERM, &act, &old_term ) ||
@@ -1443,15 +1469,6 @@ int main( int argc, char * argv[] )
14431469
int slow_script_msec = 0;
14441470
char time_buf[40];
14451471

1446-
struct sigaction act, old_act;
1447-
struct sigaction INT_act;
1448-
struct sigaction QUIT_act;
1449-
struct sigaction ILL_act;
1450-
struct sigaction ABRT_act;
1451-
struct sigaction BUS_act;
1452-
struct sigaction SEGV_act;
1453-
struct sigaction TERM_act;
1454-
int sa_rc;
14551472

14561473
#if defined(SIGPIPE) && defined(SIG_IGN)
14571474
signal(SIGPIPE, SIG_IGN);
@@ -1550,15 +1567,6 @@ int main( int argc, char * argv[] )
15501567

15511568
int result;
15521569

1553-
act.sa_flags = SA_NODEFER;
1554-
act.sa_handler = lsapi_sigterm;
1555-
sa_rc = sigaction( SIGINT, &act, &INT_act );
1556-
sa_rc = sigaction( SIGQUIT, &act, &QUIT_act );
1557-
sa_rc = sigaction( SIGILL, &act, &ILL_act );
1558-
sa_rc = sigaction( SIGABRT, &act, &ABRT_act );
1559-
sa_rc = sigaction( SIGBUS, &act, &BUS_act );
1560-
sa_rc = sigaction( SIGSEGV, &act, &SEGV_act );
1561-
sa_rc = sigaction( SIGTERM, &act, &TERM_act );
15621570
atexit(lsapi_atexit);
15631571

15641572
while( ( result = LSAPI_Prefork_Accept_r( &g_req )) >= 0 ) {
@@ -1591,14 +1599,6 @@ int main( int argc, char * argv[] )
15911599
}
15921600
}
15931601

1594-
sa_rc = sigaction( SIGINT, &INT_act, &old_act );
1595-
sa_rc = sigaction( SIGQUIT, &QUIT_act, &old_act );
1596-
sa_rc = sigaction( SIGILL, &ILL_act, &old_act );
1597-
sa_rc = sigaction( SIGABRT, &ABRT_act, &old_act );
1598-
sa_rc = sigaction( SIGBUS, &BUS_act, &old_act );
1599-
sa_rc = sigaction( SIGSEGV, &SEGV_act, &old_act );
1600-
sa_rc = sigaction( SIGTERM, &TERM_act, &old_act );
1601-
16021602
php_module_shutdown();
16031603

16041604
#ifdef ZTS

0 commit comments

Comments
 (0)