... | ... |
@@ -40,7 +40,7 @@ export makefile_defs |
40 | 40 |
VERSION = 0 |
41 | 41 |
PATCHLEVEL = 8 |
42 | 42 |
SUBLEVEL = 11 |
43 |
-EXTRAVERSION = pre30 |
|
43 |
+EXTRAVERSION = pre31 |
|
44 | 44 |
|
45 | 45 |
RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) |
46 | 46 |
OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]") |
... | ... |
@@ -34,8 +34,8 @@ x (different way) add request header bitmap field for the modules |
34 | 34 |
- ? variable number of params functions in script (no longer limited to 2)? |
35 | 35 |
- kill bind_idx |
36 | 36 |
x fix bind_address for tcp (in some way) |
37 |
-- add conflict in debs/rpms/etc (conflict w/ older ser-mysql, ser-jabber) |
|
38 |
-- new packages ser-radius etc |
|
37 |
+x add conflict in debs/rpms/etc (conflict w/ older ser-mysql, ser-jabber) |
|
38 |
+x new packages ser-radius etc |
|
39 | 39 |
x tcp_destroy (called on ser exit) |
40 | 40 |
- BUG:?? ipv6 only and try to send to ipv4 => getsendsocket=>0 (send_ipv6=0) |
41 | 41 |
the reverse is also true |
... | ... |
@@ -36,6 +36,10 @@ |
36 | 36 |
* init_shm_mallocs called after cmd. line parsing (andrei) |
37 | 37 |
* 2003-04-15 added tcp_disable support (andrei) |
38 | 38 |
* 2003-05-09 closelog() before openlog to force opening a new fd (needed on solaris) (andrei) |
39 |
+ * 2003-06-11 moved all signal handlers init. in install_sigs and moved it |
|
40 |
+ * after daemonize (so that we won't catch anymore our own |
|
41 |
+ * SIGCHLD generated when becoming session leader) (andrei) |
|
42 |
+ * changed is_main default value to 1 (andrei) |
|
39 | 43 |
* |
40 | 44 |
*/ |
41 | 45 |
|
... | ... |
@@ -350,7 +354,7 @@ extern FILE* yyin; |
350 | 354 |
extern int yyparse(); |
351 | 355 |
|
352 | 356 |
|
353 |
-int is_main=0; /* flag = is this the "main" process? */ |
|
357 |
+int is_main=1; /* flag = is this the "main" process? */ |
|
354 | 358 |
|
355 | 359 |
char* pid_file = 0; /* filename as asked by use */ |
356 | 360 |
|
... | ... |
@@ -595,6 +599,101 @@ void handle_sigs() |
595 | 599 |
|
596 | 600 |
|
597 | 601 |
|
602 |
+/* added by jku; allows for regular exit on a specific signal; |
|
603 |
+ good for profiling which only works if exited regularly and |
|
604 |
+ not by default signal handlers |
|
605 |
+ - modified by andrei: moved most of the stuff to handle_sigs, |
|
606 |
+ made it safer for the "fork" case |
|
607 |
+*/ |
|
608 |
+static void sig_usr(int signo) |
|
609 |
+{ |
|
610 |
+ |
|
611 |
+ |
|
612 |
+ if (is_main){ |
|
613 |
+ if (sig_flag==0) sig_flag=signo; |
|
614 |
+ else /* previous sig. not processed yet, ignoring? */ |
|
615 |
+ return; ; |
|
616 |
+ if (dont_fork) |
|
617 |
+ /* only one proc, doing everything from the sig handler, |
|
618 |
+ unsafe, but this is only for debugging mode*/ |
|
619 |
+ handle_sigs(); |
|
620 |
+ }else{ |
|
621 |
+ /* process the important signals */ |
|
622 |
+ switch(signo){ |
|
623 |
+ case SIGPIPE: |
|
624 |
+ LOG(L_INFO, "INFO: signal %d received\n", signo); |
|
625 |
+ break; |
|
626 |
+ case SIGINT: |
|
627 |
+ case SIGTERM: |
|
628 |
+ LOG(L_INFO, "INFO: signal %d received\n", signo); |
|
629 |
+ /* print memory stats for non-main too */ |
|
630 |
+ #ifdef PKG_MALLOC |
|
631 |
+ LOG(memlog, "Memory status (pkg):\n"); |
|
632 |
+ pkg_status(); |
|
633 |
+ #endif |
|
634 |
+ exit(0); |
|
635 |
+ break; |
|
636 |
+ case SIGUSR1: |
|
637 |
+ /* statistics, do nothing, printed only from the main proc */ |
|
638 |
+ break; |
|
639 |
+ /* ignored*/ |
|
640 |
+ case SIGUSR2: |
|
641 |
+ case SIGHUP: |
|
642 |
+ break; |
|
643 |
+ case SIGCHLD: |
|
644 |
+#ifndef STOP_JIRIS_CHANGES |
|
645 |
+ LOG(L_INFO, "INFO: SIGCHLD received: " |
|
646 |
+ "we do not worry about grand-children\n"); |
|
647 |
+#else |
|
648 |
+ exit(0); /* terminate if one child died */ |
|
649 |
+#endif |
|
650 |
+ } |
|
651 |
+ } |
|
652 |
+} |
|
653 |
+ |
|
654 |
+ |
|
655 |
+ |
|
656 |
+/* install the signal handlers, returns 0 on success, -1 on error */ |
|
657 |
+int install_sigs() |
|
658 |
+{ |
|
659 |
+ /* added by jku: add exit handler */ |
|
660 |
+ if (signal(SIGINT, sig_usr) == SIG_ERR ) { |
|
661 |
+ DPrint("ERROR: no SIGINT signal handler can be installed\n"); |
|
662 |
+ goto error; |
|
663 |
+ } |
|
664 |
+ /* if we debug and write to a pipe, we want to exit nicely too */ |
|
665 |
+ if (signal(SIGPIPE, sig_usr) == SIG_ERR ) { |
|
666 |
+ DPrint("ERROR: no SIGINT signal handler can be installed\n"); |
|
667 |
+ goto error; |
|
668 |
+ } |
|
669 |
+ |
|
670 |
+ if (signal(SIGUSR1, sig_usr) == SIG_ERR ) { |
|
671 |
+ DPrint("ERROR: no SIGUSR1 signal handler can be installed\n"); |
|
672 |
+ goto error; |
|
673 |
+ } |
|
674 |
+ if (signal(SIGCHLD , sig_usr) == SIG_ERR ) { |
|
675 |
+ DPrint("ERROR: no SIGCHLD signal handler can be installed\n"); |
|
676 |
+ goto error; |
|
677 |
+ } |
|
678 |
+ if (signal(SIGTERM , sig_usr) == SIG_ERR ) { |
|
679 |
+ DPrint("ERROR: no SIGTERM signal handler can be installed\n"); |
|
680 |
+ goto error; |
|
681 |
+ } |
|
682 |
+ if (signal(SIGHUP , sig_usr) == SIG_ERR ) { |
|
683 |
+ DPrint("ERROR: no SIGHUP signal handler can be installed\n"); |
|
684 |
+ goto error; |
|
685 |
+ } |
|
686 |
+ if (signal(SIGUSR2 , sig_usr) == SIG_ERR ) { |
|
687 |
+ DPrint("ERROR: no SIGUSR2 signal handler can be installed\n"); |
|
688 |
+ goto error; |
|
689 |
+ } |
|
690 |
+ return 0; |
|
691 |
+error: |
|
692 |
+ return -1; |
|
693 |
+} |
|
694 |
+ |
|
695 |
+ |
|
696 |
+ |
|
598 | 697 |
/* main loop */ |
599 | 698 |
int main_loop() |
600 | 699 |
{ |
... | ... |
@@ -607,7 +706,7 @@ int main_loop() |
607 | 706 |
|
608 | 707 |
/* one "main" process and n children handling i/o */ |
609 | 708 |
|
610 |
- |
|
709 |
+ is_main=0; |
|
611 | 710 |
if (dont_fork){ |
612 | 711 |
#ifdef STATS |
613 | 712 |
setstats( 0 ); |
... | ... |
@@ -906,61 +1005,6 @@ int main_loop() |
906 | 1005 |
|
907 | 1006 |
} |
908 | 1007 |
|
909 |
- |
|
910 |
-/* added by jku; allows for regular exit on a specific signal; |
|
911 |
- good for profiling which only works if exited regularly and |
|
912 |
- not by default signal handlers |
|
913 |
- - modified by andrei: moved most of the stuff to handle_sigs, |
|
914 |
- made it safer for the "fork" case |
|
915 |
-*/ |
|
916 |
-static void sig_usr(int signo) |
|
917 |
-{ |
|
918 |
- |
|
919 |
- |
|
920 |
- if (is_main){ |
|
921 |
- if (sig_flag==0) sig_flag=signo; |
|
922 |
- else /* previous sig. not processed yet, ignoring? */ |
|
923 |
- return; ; |
|
924 |
- if (dont_fork) |
|
925 |
- /* only one proc, doing everything from the sig handler, |
|
926 |
- unsafe, but this is only for debugging mode*/ |
|
927 |
- handle_sigs(); |
|
928 |
- }else{ |
|
929 |
- /* process the important signals */ |
|
930 |
- switch(signo){ |
|
931 |
- case SIGPIPE: |
|
932 |
- LOG(L_INFO, "INFO: signal %d received\n", signo); |
|
933 |
- break; |
|
934 |
- case SIGINT: |
|
935 |
- case SIGTERM: |
|
936 |
- LOG(L_INFO, "INFO: signal %d received\n", signo); |
|
937 |
- /* print memory stats for non-main too */ |
|
938 |
- #ifdef PKG_MALLOC |
|
939 |
- LOG(memlog, "Memory status (pkg):\n"); |
|
940 |
- pkg_status(); |
|
941 |
- #endif |
|
942 |
- exit(0); |
|
943 |
- break; |
|
944 |
- case SIGUSR1: |
|
945 |
- /* statistics, do nothing, printed only from the main proc */ |
|
946 |
- break; |
|
947 |
- /* ignored*/ |
|
948 |
- case SIGUSR2: |
|
949 |
- case SIGHUP: |
|
950 |
- break; |
|
951 |
- case SIGCHLD: |
|
952 |
-#ifndef STOP_JIRIS_CHANGES |
|
953 |
- LOG(L_INFO, "INFO: SIGCHLD received: " |
|
954 |
- "we do not worry about grand-children\n"); |
|
955 |
-#else |
|
956 |
- exit(0); /* terminate if one child died */ |
|
957 |
-#endif |
|
958 |
- } |
|
959 |
- } |
|
960 |
-} |
|
961 |
- |
|
962 |
- |
|
963 |
- |
|
964 | 1008 |
/* add all family type addresses of interface if_name to the socket_info array |
965 | 1009 |
* if if_name==0, adds all addresses on all interfaces |
966 | 1010 |
* WARNING: it only works with ipv6 addresses on FreeBSD |
... | ... |
@@ -1120,37 +1164,6 @@ int main(int argc, char** argv) |
1120 | 1164 |
if (init_pkg_mallocs()==-1) |
1121 | 1165 |
goto error; |
1122 | 1166 |
|
1123 |
- /* added by jku: add exit handler */ |
|
1124 |
- if (signal(SIGINT, sig_usr) == SIG_ERR ) { |
|
1125 |
- DPrint("ERROR: no SIGINT signal handler can be installed\n"); |
|
1126 |
- goto error; |
|
1127 |
- } |
|
1128 |
- /* if we debug and write to a pipe, we want to exit nicely too */ |
|
1129 |
- if (signal(SIGPIPE, sig_usr) == SIG_ERR ) { |
|
1130 |
- DPrint("ERROR: no SIGINT signal handler can be installed\n"); |
|
1131 |
- goto error; |
|
1132 |
- } |
|
1133 |
- |
|
1134 |
- if (signal(SIGUSR1, sig_usr) == SIG_ERR ) { |
|
1135 |
- DPrint("ERROR: no SIGUSR1 signal handler can be installed\n"); |
|
1136 |
- goto error; |
|
1137 |
- } |
|
1138 |
- if (signal(SIGCHLD , sig_usr) == SIG_ERR ) { |
|
1139 |
- DPrint("ERROR: no SIGCHLD signal handler can be installed\n"); |
|
1140 |
- goto error; |
|
1141 |
- } |
|
1142 |
- if (signal(SIGTERM , sig_usr) == SIG_ERR ) { |
|
1143 |
- DPrint("ERROR: no SIGTERM signal handler can be installed\n"); |
|
1144 |
- goto error; |
|
1145 |
- } |
|
1146 |
- if (signal(SIGHUP , sig_usr) == SIG_ERR ) { |
|
1147 |
- DPrint("ERROR: no SIGHUP signal handler can be installed\n"); |
|
1148 |
- goto error; |
|
1149 |
- } |
|
1150 |
- if (signal(SIGUSR2 , sig_usr) == SIG_ERR ) { |
|
1151 |
- DPrint("ERROR: no SIGUSR2 signal handler can be installed\n"); |
|
1152 |
- goto error; |
|
1153 |
- } |
|
1154 | 1167 |
#ifdef DBG_MSG_QA |
1155 | 1168 |
fprintf(stderr, "WARNING: ser startup: " |
1156 | 1169 |
"DBG_MSG_QA enabled, ser may exit abruptly\n"); |
... | ... |
@@ -1635,6 +1648,11 @@ try_again: |
1635 | 1648 |
if (!dont_fork){ |
1636 | 1649 |
if ( daemonize(argv[0]) <0 ) goto error; |
1637 | 1650 |
} |
1651 |
+ if (install_sigs() != 0){ |
|
1652 |
+ fprintf(stderr, "ERROR: could not install the signal handlers\n"); |
|
1653 |
+ goto error; |
|
1654 |
+ } |
|
1655 |
+ |
|
1638 | 1656 |
if (init_modules() != 0) { |
1639 | 1657 |
fprintf(stderr, "ERROR: error while initializing modules\n"); |
1640 | 1658 |
goto error; |