|
47 | 47 | #include <sys/socket.h>
|
48 | 48 | #include <arpa/inet.h>
|
49 | 49 | #include <netinet/in.h>
|
| 50 | +#include <sys/time.h> |
50 | 51 |
|
51 | 52 | #if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
|
52 | 53 | #include "lscriu.c"
|
@@ -602,7 +603,7 @@ static int sapi_lsapi_activate()
|
602 | 603 | static sapi_module_struct lsapi_sapi_module =
|
603 | 604 | {
|
604 | 605 | "litespeed",
|
605 |
| - "LiteSpeed V7.4.3", |
| 606 | + "LiteSpeed V7.5", |
606 | 607 |
|
607 | 608 | php_lsapi_startup, /* startup */
|
608 | 609 | php_module_shutdown_wrapper, /* shutdown */
|
@@ -681,66 +682,90 @@ static void lsapi_sigsegv( int signal )
|
681 | 682 |
|
682 | 683 | static int clean_onexit = 1;
|
683 | 684 |
|
684 |
| -static void lsapi_sigterm( int signal ) |
| 685 | + |
| 686 | +static void lsapi_clean_shutdown() |
685 | 687 | {
|
686 |
| - struct sigaction act, old_act; |
| 688 | + struct sigaction act; |
687 | 689 | 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 | +{ |
688 | 729 |
|
689 | 730 | // fprintf(stderr, "lsapi_sigterm: %d: clean_onexit %d\n", getpid(), clean_onexit );
|
690 | 731 | if(!clean_onexit)
|
691 | 732 | {
|
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(); |
706 | 734 | }
|
707 | 735 | exit(1);
|
708 | 736 | }
|
709 | 737 |
|
710 |
| -static void lsapi_atexit( void ) |
| 738 | +static void lsapi_atexit(void) |
711 | 739 | {
|
712 |
| - struct sigaction act, old_act; |
713 |
| - int sa_rc; |
714 |
| - |
715 | 740 | //fprintf(stderr, "lsapi_atexit: %d: clean_onexit %d\n", getpid(), clean_onexit );
|
716 | 741 | if(!clean_onexit)
|
717 | 742 | {
|
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(); |
733 | 744 | }
|
734 | 745 | }
|
735 | 746 |
|
| 747 | + |
736 | 748 | static int lsapi_module_main(int show_source)
|
737 | 749 | {
|
| 750 | + struct sigaction act; |
| 751 | + int sa_rc; |
738 | 752 | zend_file_handle file_handle;
|
739 | 753 | memset(&file_handle, 0, sizeof(file_handle));
|
740 | 754 | if (php_request_startup() == FAILURE ) {
|
741 | 755 | return -1;
|
742 | 756 | }
|
743 | 757 |
|
| 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 | + |
744 | 769 | clean_onexit = 0;
|
745 | 770 |
|
746 | 771 | if (show_source) {
|
@@ -1367,6 +1392,7 @@ void start_children( int children )
|
1367 | 1392 | setsid();
|
1368 | 1393 |
|
1369 | 1394 | /* Set up handler to kill children upon exit */
|
| 1395 | + sigemptyset(&act.sa_mask); |
1370 | 1396 | act.sa_flags = 0;
|
1371 | 1397 | act.sa_handler = litespeed_cleanup;
|
1372 | 1398 | if( sigaction( SIGTERM, &act, &old_term ) ||
|
@@ -1443,15 +1469,6 @@ int main( int argc, char * argv[] )
|
1443 | 1469 | int slow_script_msec = 0;
|
1444 | 1470 | char time_buf[40];
|
1445 | 1471 |
|
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; |
1455 | 1472 |
|
1456 | 1473 | #if defined(SIGPIPE) && defined(SIG_IGN)
|
1457 | 1474 | signal(SIGPIPE, SIG_IGN);
|
@@ -1550,15 +1567,6 @@ int main( int argc, char * argv[] )
|
1550 | 1567 |
|
1551 | 1568 | int result;
|
1552 | 1569 |
|
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 ); |
1562 | 1570 | atexit(lsapi_atexit);
|
1563 | 1571 |
|
1564 | 1572 | while( ( result = LSAPI_Prefork_Accept_r( &g_req )) >= 0 ) {
|
@@ -1591,14 +1599,6 @@ int main( int argc, char * argv[] )
|
1591 | 1599 | }
|
1592 | 1600 | }
|
1593 | 1601 |
|
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 |
| - |
1602 | 1602 | php_module_shutdown();
|
1603 | 1603 |
|
1604 | 1604 | #ifdef ZTS
|
|
0 commit comments