Skip to content

Commit 82f35ab

Browse files
author
George Wang
committed
Merge branch 'PHP-7.2' into PHP-7.3
2 parents 4a9f78f + eb7e45f commit 82f35ab

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
@@ -55,6 +55,7 @@
5555
#include <sys/socket.h>
5656
#include <arpa/inet.h>
5757
#include <netinet/in.h>
58+
#include <sys/time.h>
5859

5960
#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
6061
#include "lscriu.c"
@@ -609,7 +610,7 @@ static int sapi_lsapi_activate()
609610
static sapi_module_struct lsapi_sapi_module =
610611
{
611612
"litespeed",
612-
"LiteSpeed V7.4.3",
613+
"LiteSpeed V7.5",
613614

614615
php_lsapi_startup, /* startup */
615616
php_module_shutdown_wrapper, /* shutdown */
@@ -692,66 +693,90 @@ static void lsapi_sigsegv( int signal )
692693

693694
static int clean_onexit = 1;
694695

695-
static void lsapi_sigterm( int signal )
696+
697+
static void lsapi_clean_shutdown()
696698
{
697-
struct sigaction act, old_act;
699+
struct sigaction act;
698700
int sa_rc;
701+
struct itimerval tmv;
702+
#if PHP_MAJOR_VERSION >= 7
703+
zend_string * key;
704+
#endif
705+
clean_onexit = 1;
706+
sigemptyset(&act.sa_mask);
707+
act.sa_flags = 0;
708+
act.sa_handler = lsapi_sigsegv;
709+
sa_rc = sigaction(SIGINT, &act, NULL);
710+
sa_rc = sigaction(SIGQUIT, &act, NULL);
711+
sa_rc = sigaction(SIGILL, &act, NULL);
712+
sa_rc = sigaction(SIGABRT, &act, NULL);
713+
sa_rc = sigaction(SIGBUS, &act, NULL);
714+
sa_rc = sigaction(SIGSEGV, &act, NULL);
715+
sa_rc = sigaction(SIGTERM, &act, NULL);
716+
717+
sa_rc = sigaction(SIGPROF, &act, NULL);
718+
memset(&tmv, 0, sizeof(struct itimerval));
719+
tmv.it_value.tv_sec = 0;
720+
tmv.it_value.tv_usec = 100000;
721+
setitimer(ITIMER_PROF, &tmv, NULL);
722+
723+
#if PHP_MAJOR_VERSION >= 7
724+
key = zend_string_init("error_reporting", 15, 1);
725+
zend_alter_ini_entry_chars_ex(key, "0", 1,
726+
PHP_INI_SYSTEM, PHP_INI_STAGE_SHUTDOWN, 1);
727+
zend_string_release(key);
728+
#else
729+
zend_alter_ini_entry("error_reporting", 16, "0", 1,
730+
PHP_INI_SYSTEM, PHP_INI_STAGE_SHUTDOWN);
731+
#endif
732+
733+
zend_try {
734+
php_request_shutdown(NULL);
735+
} zend_end_try();
736+
}
737+
738+
static void lsapi_sigterm(int signal)
739+
{
699740

700741
// fprintf(stderr, "lsapi_sigterm: %d: clean_onexit %d\n", getpid(), clean_onexit );
701742
if(!clean_onexit)
702743
{
703-
clean_onexit = 1;
704-
act.sa_flags = 0;
705-
act.sa_handler = lsapi_sigsegv;
706-
sa_rc = sigaction( SIGINT, &act, &old_act );
707-
sa_rc = sigaction( SIGQUIT, &act, &old_act );
708-
sa_rc = sigaction( SIGILL, &act, &old_act );
709-
sa_rc = sigaction( SIGABRT, &act, &old_act );
710-
sa_rc = sigaction( SIGBUS, &act, &old_act );
711-
sa_rc = sigaction( SIGSEGV, &act, &old_act );
712-
sa_rc = sigaction( SIGTERM, &act, &old_act );
713-
714-
zend_try {
715-
php_request_shutdown(NULL);
716-
} zend_end_try();
744+
lsapi_clean_shutdown();
717745
}
718746
exit(1);
719747
}
720748

721-
static void lsapi_atexit( void )
749+
static void lsapi_atexit(void)
722750
{
723-
struct sigaction act, old_act;
724-
int sa_rc;
725-
726751
//fprintf(stderr, "lsapi_atexit: %d: clean_onexit %d\n", getpid(), clean_onexit );
727752
if(!clean_onexit)
728753
{
729-
clean_onexit = 1;
730-
act.sa_flags = 0;
731-
act.sa_handler = lsapi_sigsegv;
732-
sa_rc = sigaction( SIGINT, &act, &old_act );
733-
sa_rc = sigaction( SIGQUIT, &act, &old_act );
734-
sa_rc = sigaction( SIGILL, &act, &old_act );
735-
sa_rc = sigaction( SIGABRT, &act, &old_act );
736-
sa_rc = sigaction( SIGBUS, &act, &old_act );
737-
sa_rc = sigaction( SIGSEGV, &act, &old_act );
738-
sa_rc = sigaction( SIGTERM, &act, &old_act );
739-
740-
//fprintf(stderr, "lsapi_atexit: %d: before php_request_shutdown\n", getpid(), clean_onexit );
741-
zend_try {
742-
php_request_shutdown(NULL);
743-
} zend_end_try();
754+
lsapi_clean_shutdown();
744755
}
745756
}
746757

758+
747759
static int lsapi_module_main(int show_source)
748760
{
761+
struct sigaction act;
762+
int sa_rc;
749763
zend_file_handle file_handle;
750764
memset(&file_handle, 0, sizeof(file_handle));
751765
if (php_request_startup() == FAILURE ) {
752766
return -1;
753767
}
754768

769+
sigemptyset(&act.sa_mask);
770+
act.sa_flags = SA_NODEFER;
771+
act.sa_handler = lsapi_sigterm;
772+
sa_rc = sigaction( SIGINT, &act, NULL);
773+
sa_rc = sigaction( SIGQUIT, &act, NULL);
774+
sa_rc = sigaction( SIGILL, &act, NULL);
775+
sa_rc = sigaction( SIGABRT, &act, NULL);
776+
sa_rc = sigaction( SIGBUS, &act, NULL);
777+
sa_rc = sigaction( SIGSEGV, &act, NULL);
778+
sa_rc = sigaction( SIGTERM, &act, NULL);
779+
755780
clean_onexit = 0;
756781

757782
if (show_source) {
@@ -1382,6 +1407,7 @@ void start_children( int children )
13821407
setsid();
13831408

13841409
/* Set up handler to kill children upon exit */
1410+
sigemptyset(&act.sa_mask);
13851411
act.sa_flags = 0;
13861412
act.sa_handler = litespeed_cleanup;
13871413
if( sigaction( SIGTERM, &act, &old_term ) ||
@@ -1458,15 +1484,6 @@ int main( int argc, char * argv[] )
14581484
int slow_script_msec = 0;
14591485
char time_buf[40];
14601486

1461-
struct sigaction act, old_act;
1462-
struct sigaction INT_act;
1463-
struct sigaction QUIT_act;
1464-
struct sigaction ILL_act;
1465-
struct sigaction ABRT_act;
1466-
struct sigaction BUS_act;
1467-
struct sigaction SEGV_act;
1468-
struct sigaction TERM_act;
1469-
int sa_rc;
14701487

14711488
#ifdef HAVE_SIGNAL_H
14721489
#if defined(SIGPIPE) && defined(SIG_IGN)
@@ -1568,15 +1585,6 @@ int main( int argc, char * argv[] )
15681585

15691586
int result;
15701587

1571-
act.sa_flags = SA_NODEFER;
1572-
act.sa_handler = lsapi_sigterm;
1573-
sa_rc = sigaction( SIGINT, &act, &INT_act );
1574-
sa_rc = sigaction( SIGQUIT, &act, &QUIT_act );
1575-
sa_rc = sigaction( SIGILL, &act, &ILL_act );
1576-
sa_rc = sigaction( SIGABRT, &act, &ABRT_act );
1577-
sa_rc = sigaction( SIGBUS, &act, &BUS_act );
1578-
sa_rc = sigaction( SIGSEGV, &act, &SEGV_act );
1579-
sa_rc = sigaction( SIGTERM, &act, &TERM_act );
15801588
atexit(lsapi_atexit);
15811589

15821590
while( ( result = LSAPI_Prefork_Accept_r( &g_req )) >= 0 ) {
@@ -1609,14 +1617,6 @@ int main( int argc, char * argv[] )
16091617
}
16101618
}
16111619

1612-
sa_rc = sigaction( SIGINT, &INT_act, &old_act );
1613-
sa_rc = sigaction( SIGQUIT, &QUIT_act, &old_act );
1614-
sa_rc = sigaction( SIGILL, &ILL_act, &old_act );
1615-
sa_rc = sigaction( SIGABRT, &ABRT_act, &old_act );
1616-
sa_rc = sigaction( SIGBUS, &BUS_act, &old_act );
1617-
sa_rc = sigaction( SIGSEGV, &SEGV_act, &old_act );
1618-
sa_rc = sigaction( SIGTERM, &TERM_act, &old_act );
1619-
16201620
php_module_shutdown();
16211621

16221622
#ifdef ZTS

0 commit comments

Comments
 (0)