|
66 | 66 | #include <sys/socket.h>
|
67 | 67 | #include <arpa/inet.h>
|
68 | 68 | #include <netinet/in.h>
|
| 69 | +#include <sys/time.h> |
69 | 70 |
|
70 | 71 | #if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
|
71 | 72 | #include "lscriu.c"
|
@@ -620,7 +621,7 @@ static int sapi_lsapi_activate()
|
620 | 621 | static sapi_module_struct lsapi_sapi_module =
|
621 | 622 | {
|
622 | 623 | "litespeed",
|
623 |
| - "LiteSpeed V7.4.3", |
| 624 | + "LiteSpeed V7.5", |
624 | 625 |
|
625 | 626 | php_lsapi_startup, /* startup */
|
626 | 627 | php_module_shutdown_wrapper, /* shutdown */
|
@@ -703,66 +704,90 @@ static void lsapi_sigsegv( int signal )
|
703 | 704 |
|
704 | 705 | static int clean_onexit = 1;
|
705 | 706 |
|
706 |
| -static void lsapi_sigterm( int signal ) |
| 707 | + |
| 708 | +static void lsapi_clean_shutdown() |
707 | 709 | {
|
708 |
| - struct sigaction act, old_act; |
| 710 | + struct sigaction act; |
709 | 711 | int sa_rc;
|
| 712 | + struct itimerval tmv; |
| 713 | +#if PHP_MAJOR_VERSION >= 7 |
| 714 | + zend_string * key; |
| 715 | +#endif |
| 716 | + clean_onexit = 1; |
| 717 | + sigemptyset(&act.sa_mask); |
| 718 | + act.sa_flags = 0; |
| 719 | + act.sa_handler = lsapi_sigsegv; |
| 720 | + sa_rc = sigaction(SIGINT, &act, NULL); |
| 721 | + sa_rc = sigaction(SIGQUIT, &act, NULL); |
| 722 | + sa_rc = sigaction(SIGILL, &act, NULL); |
| 723 | + sa_rc = sigaction(SIGABRT, &act, NULL); |
| 724 | + sa_rc = sigaction(SIGBUS, &act, NULL); |
| 725 | + sa_rc = sigaction(SIGSEGV, &act, NULL); |
| 726 | + sa_rc = sigaction(SIGTERM, &act, NULL); |
| 727 | + |
| 728 | + sa_rc = sigaction(SIGPROF, &act, NULL); |
| 729 | + memset(&tmv, 0, sizeof(struct itimerval)); |
| 730 | + tmv.it_value.tv_sec = 0; |
| 731 | + tmv.it_value.tv_usec = 100000; |
| 732 | + setitimer(ITIMER_PROF, &tmv, NULL); |
| 733 | + |
| 734 | +#if PHP_MAJOR_VERSION >= 7 |
| 735 | + key = zend_string_init("error_reporting", 15, 1); |
| 736 | + zend_alter_ini_entry_chars_ex(key, "0", 1, |
| 737 | + PHP_INI_SYSTEM, PHP_INI_STAGE_SHUTDOWN, 1); |
| 738 | + zend_string_release(key); |
| 739 | +#else |
| 740 | + zend_alter_ini_entry("error_reporting", 16, "0", 1, |
| 741 | + PHP_INI_SYSTEM, PHP_INI_STAGE_SHUTDOWN); |
| 742 | +#endif |
| 743 | + |
| 744 | + zend_try { |
| 745 | + php_request_shutdown(NULL); |
| 746 | + } zend_end_try(); |
| 747 | +} |
| 748 | + |
| 749 | +static void lsapi_sigterm(int signal) |
| 750 | +{ |
710 | 751 |
|
711 | 752 | // fprintf(stderr, "lsapi_sigterm: %d: clean_onexit %d\n", getpid(), clean_onexit );
|
712 | 753 | if(!clean_onexit)
|
713 | 754 | {
|
714 |
| - clean_onexit = 1; |
715 |
| - act.sa_flags = 0; |
716 |
| - act.sa_handler = lsapi_sigsegv; |
717 |
| - sa_rc = sigaction( SIGINT, &act, &old_act ); |
718 |
| - sa_rc = sigaction( SIGQUIT, &act, &old_act ); |
719 |
| - sa_rc = sigaction( SIGILL, &act, &old_act ); |
720 |
| - sa_rc = sigaction( SIGABRT, &act, &old_act ); |
721 |
| - sa_rc = sigaction( SIGBUS, &act, &old_act ); |
722 |
| - sa_rc = sigaction( SIGSEGV, &act, &old_act ); |
723 |
| - sa_rc = sigaction( SIGTERM, &act, &old_act ); |
724 |
| - |
725 |
| - zend_try { |
726 |
| - php_request_shutdown(NULL); |
727 |
| - } zend_end_try(); |
| 755 | + lsapi_clean_shutdown(); |
728 | 756 | }
|
729 | 757 | exit(1);
|
730 | 758 | }
|
731 | 759 |
|
732 |
| -static void lsapi_atexit( void ) |
| 760 | +static void lsapi_atexit(void) |
733 | 761 | {
|
734 |
| - struct sigaction act, old_act; |
735 |
| - int sa_rc; |
736 |
| - |
737 | 762 | //fprintf(stderr, "lsapi_atexit: %d: clean_onexit %d\n", getpid(), clean_onexit );
|
738 | 763 | if(!clean_onexit)
|
739 | 764 | {
|
740 |
| - clean_onexit = 1; |
741 |
| - act.sa_flags = 0; |
742 |
| - act.sa_handler = lsapi_sigsegv; |
743 |
| - sa_rc = sigaction( SIGINT, &act, &old_act ); |
744 |
| - sa_rc = sigaction( SIGQUIT, &act, &old_act ); |
745 |
| - sa_rc = sigaction( SIGILL, &act, &old_act ); |
746 |
| - sa_rc = sigaction( SIGABRT, &act, &old_act ); |
747 |
| - sa_rc = sigaction( SIGBUS, &act, &old_act ); |
748 |
| - sa_rc = sigaction( SIGSEGV, &act, &old_act ); |
749 |
| - sa_rc = sigaction( SIGTERM, &act, &old_act ); |
750 |
| - |
751 |
| - //fprintf(stderr, "lsapi_atexit: %d: before php_request_shutdown\n", getpid(), clean_onexit ); |
752 |
| - zend_try { |
753 |
| - php_request_shutdown(NULL); |
754 |
| - } zend_end_try(); |
| 765 | + lsapi_clean_shutdown(); |
755 | 766 | }
|
756 | 767 | }
|
757 | 768 |
|
| 769 | + |
758 | 770 | static int lsapi_module_main(int show_source)
|
759 | 771 | {
|
| 772 | + struct sigaction act; |
| 773 | + int sa_rc; |
760 | 774 | zend_file_handle file_handle;
|
761 | 775 | memset(&file_handle, 0, sizeof(file_handle));
|
762 | 776 | if (php_request_startup() == FAILURE ) {
|
763 | 777 | return -1;
|
764 | 778 | }
|
765 | 779 |
|
| 780 | + sigemptyset(&act.sa_mask); |
| 781 | + act.sa_flags = SA_NODEFER; |
| 782 | + act.sa_handler = lsapi_sigterm; |
| 783 | + sa_rc = sigaction( SIGINT, &act, NULL); |
| 784 | + sa_rc = sigaction( SIGQUIT, &act, NULL); |
| 785 | + sa_rc = sigaction( SIGILL, &act, NULL); |
| 786 | + sa_rc = sigaction( SIGABRT, &act, NULL); |
| 787 | + sa_rc = sigaction( SIGBUS, &act, NULL); |
| 788 | + sa_rc = sigaction( SIGSEGV, &act, NULL); |
| 789 | + sa_rc = sigaction( SIGTERM, &act, NULL); |
| 790 | + |
766 | 791 | clean_onexit = 0;
|
767 | 792 |
|
768 | 793 | if (show_source) {
|
@@ -1397,6 +1422,7 @@ void start_children( int children )
|
1397 | 1422 | setsid();
|
1398 | 1423 |
|
1399 | 1424 | /* Set up handler to kill children upon exit */
|
| 1425 | + sigemptyset(&act.sa_mask); |
1400 | 1426 | act.sa_flags = 0;
|
1401 | 1427 | act.sa_handler = litespeed_cleanup;
|
1402 | 1428 | if( sigaction( SIGTERM, &act, &old_term ) ||
|
@@ -1473,15 +1499,6 @@ int main( int argc, char * argv[] )
|
1473 | 1499 | int slow_script_msec = 0;
|
1474 | 1500 | char time_buf[40];
|
1475 | 1501 |
|
1476 |
| - struct sigaction act, old_act; |
1477 |
| - struct sigaction INT_act; |
1478 |
| - struct sigaction QUIT_act; |
1479 |
| - struct sigaction ILL_act; |
1480 |
| - struct sigaction ABRT_act; |
1481 |
| - struct sigaction BUS_act; |
1482 |
| - struct sigaction SEGV_act; |
1483 |
| - struct sigaction TERM_act; |
1484 |
| - int sa_rc; |
1485 | 1502 |
|
1486 | 1503 | #ifdef HAVE_SIGNAL_H
|
1487 | 1504 | #if defined(SIGPIPE) && defined(SIG_IGN)
|
@@ -1584,15 +1601,6 @@ int main( int argc, char * argv[] )
|
1584 | 1601 | int iRequestsProcessed = 0;
|
1585 | 1602 | int result;
|
1586 | 1603 |
|
1587 |
| - act.sa_flags = SA_NODEFER; |
1588 |
| - act.sa_handler = lsapi_sigterm; |
1589 |
| - sa_rc = sigaction( SIGINT, &act, &INT_act ); |
1590 |
| - sa_rc = sigaction( SIGQUIT, &act, &QUIT_act ); |
1591 |
| - sa_rc = sigaction( SIGILL, &act, &ILL_act ); |
1592 |
| - sa_rc = sigaction( SIGABRT, &act, &ABRT_act ); |
1593 |
| - sa_rc = sigaction( SIGBUS, &act, &BUS_act ); |
1594 |
| - sa_rc = sigaction( SIGSEGV, &act, &SEGV_act ); |
1595 |
| - sa_rc = sigaction( SIGTERM, &act, &TERM_act ); |
1596 | 1604 | atexit(lsapi_atexit);
|
1597 | 1605 |
|
1598 | 1606 | while( ( result = LSAPI_Prefork_Accept_r( &g_req )) >= 0 ) {
|
@@ -1625,14 +1633,6 @@ int main( int argc, char * argv[] )
|
1625 | 1633 | }
|
1626 | 1634 | }
|
1627 | 1635 |
|
1628 |
| - sa_rc = sigaction( SIGINT, &INT_act, &old_act ); |
1629 |
| - sa_rc = sigaction( SIGQUIT, &QUIT_act, &old_act ); |
1630 |
| - sa_rc = sigaction( SIGILL, &ILL_act, &old_act ); |
1631 |
| - sa_rc = sigaction( SIGABRT, &ABRT_act, &old_act ); |
1632 |
| - sa_rc = sigaction( SIGBUS, &BUS_act, &old_act ); |
1633 |
| - sa_rc = sigaction( SIGSEGV, &SEGV_act, &old_act ); |
1634 |
| - sa_rc = sigaction( SIGTERM, &TERM_act, &old_act ); |
1635 |
| - |
1636 | 1636 | php_module_shutdown();
|
1637 | 1637 |
|
1638 | 1638 | #ifdef ZTS
|
|
0 commit comments