|
55 | 55 | #include <sys/socket.h>
|
56 | 56 | #include <arpa/inet.h>
|
57 | 57 | #include <netinet/in.h>
|
| 58 | +#include <sys/time.h> |
58 | 59 |
|
59 | 60 | #if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
|
60 | 61 | #include "lscriu.c"
|
@@ -609,7 +610,7 @@ static int sapi_lsapi_activate()
|
609 | 610 | static sapi_module_struct lsapi_sapi_module =
|
610 | 611 | {
|
611 | 612 | "litespeed",
|
612 |
| - "LiteSpeed V7.4.3", |
| 613 | + "LiteSpeed V7.5", |
613 | 614 |
|
614 | 615 | php_lsapi_startup, /* startup */
|
615 | 616 | php_module_shutdown_wrapper, /* shutdown */
|
@@ -692,66 +693,90 @@ static void lsapi_sigsegv( int signal )
|
692 | 693 |
|
693 | 694 | static int clean_onexit = 1;
|
694 | 695 |
|
695 |
| -static void lsapi_sigterm( int signal ) |
| 696 | + |
| 697 | +static void lsapi_clean_shutdown() |
696 | 698 | {
|
697 |
| - struct sigaction act, old_act; |
| 699 | + struct sigaction act; |
698 | 700 | 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 | +{ |
699 | 740 |
|
700 | 741 | // fprintf(stderr, "lsapi_sigterm: %d: clean_onexit %d\n", getpid(), clean_onexit );
|
701 | 742 | if(!clean_onexit)
|
702 | 743 | {
|
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(); |
717 | 745 | }
|
718 | 746 | exit(1);
|
719 | 747 | }
|
720 | 748 |
|
721 |
| -static void lsapi_atexit( void ) |
| 749 | +static void lsapi_atexit(void) |
722 | 750 | {
|
723 |
| - struct sigaction act, old_act; |
724 |
| - int sa_rc; |
725 |
| - |
726 | 751 | //fprintf(stderr, "lsapi_atexit: %d: clean_onexit %d\n", getpid(), clean_onexit );
|
727 | 752 | if(!clean_onexit)
|
728 | 753 | {
|
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(); |
744 | 755 | }
|
745 | 756 | }
|
746 | 757 |
|
| 758 | + |
747 | 759 | static int lsapi_module_main(int show_source)
|
748 | 760 | {
|
| 761 | + struct sigaction act; |
| 762 | + int sa_rc; |
749 | 763 | zend_file_handle file_handle;
|
750 | 764 | memset(&file_handle, 0, sizeof(file_handle));
|
751 | 765 | if (php_request_startup() == FAILURE ) {
|
752 | 766 | return -1;
|
753 | 767 | }
|
754 | 768 |
|
| 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 | + |
755 | 780 | clean_onexit = 0;
|
756 | 781 |
|
757 | 782 | if (show_source) {
|
@@ -1382,6 +1407,7 @@ void start_children( int children )
|
1382 | 1407 | setsid();
|
1383 | 1408 |
|
1384 | 1409 | /* Set up handler to kill children upon exit */
|
| 1410 | + sigemptyset(&act.sa_mask); |
1385 | 1411 | act.sa_flags = 0;
|
1386 | 1412 | act.sa_handler = litespeed_cleanup;
|
1387 | 1413 | if( sigaction( SIGTERM, &act, &old_term ) ||
|
@@ -1458,15 +1484,6 @@ int main( int argc, char * argv[] )
|
1458 | 1484 | int slow_script_msec = 0;
|
1459 | 1485 | char time_buf[40];
|
1460 | 1486 |
|
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; |
1470 | 1487 |
|
1471 | 1488 | #ifdef HAVE_SIGNAL_H
|
1472 | 1489 | #if defined(SIGPIPE) && defined(SIG_IGN)
|
@@ -1568,15 +1585,6 @@ int main( int argc, char * argv[] )
|
1568 | 1585 |
|
1569 | 1586 | int result;
|
1570 | 1587 |
|
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 ); |
1580 | 1588 | atexit(lsapi_atexit);
|
1581 | 1589 |
|
1582 | 1590 | while( ( result = LSAPI_Prefork_Accept_r( &g_req )) >= 0 ) {
|
@@ -1609,14 +1617,6 @@ int main( int argc, char * argv[] )
|
1609 | 1617 | }
|
1610 | 1618 | }
|
1611 | 1619 |
|
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 |
| - |
1620 | 1620 | php_module_shutdown();
|
1621 | 1621 |
|
1622 | 1622 | #ifdef ZTS
|
|
0 commit comments