Changeset 1982
- Timestamp:
- 09/05/2007 10:39:56 AM (14 months ago)
- Location:
- branches/lighttpd-1.4.x
- Files:
-
- 2 modified
-
NEWS (modified) (1 diff)
-
src/server.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/lighttpd-1.4.x/NEWS
r1980 r1982 6 6 - 1.4.18 - 7 7 * fixed compile error on IRIX 6.5.x on prctl() (#1333) 8 * fixed forwarding a SIGINT and SIGHUP when using max-workers (#902) 8 9 9 10 -
branches/lighttpd-1.4.x/src/server.c
r1980 r1982 69 69 static volatile sig_atomic_t handle_sig_alarm = 1; 70 70 static volatile sig_atomic_t handle_sig_hup = 0; 71 static volatile sig_atomic_t forwarded_sig_hup = 0; 71 72 72 73 #if defined(HAVE_SIGACTION) && defined(SA_SIGINFO) … … 95 96 break; 96 97 case SIGHUP: 97 handle_sig_hup = 1; 98 memcpy(&last_sighup_info, si, sizeof(*si)); 98 /** 99 * we send the SIGHUP to all procs in the process-group 100 * this includes ourself 101 * 102 * make sure we only send it once and don't create a 103 * infinite loop 104 */ 105 if (!forwarded_sig_hup) { 106 handle_sig_hup = 1; 107 memcpy(&last_sighup_info, si, sizeof(*si)); 108 } else { 109 forwarded_sig_hup = 0; 110 } 99 111 break; 100 112 case SIGCHLD: … … 989 1001 if (num_childs > 0) { 990 1002 int child = 0; 991 while (!child && !srv_shutdown ) {1003 while (!child && !srv_shutdown && !graceful_shutdown) { 992 1004 if (num_childs > 0) { 993 1005 switch (fork()) { … … 1004 1016 int status; 1005 1017 1006 /* ignore EINTR */ 1007 if (-1 != wait(&status)) num_childs++; 1008 } 1009 } 1010 if (srv_shutdown) { 1011 kill(0, SIGTERM); 1012 } 1013 if (!child) return 0; 1018 if (-1 != wait(&status)) { 1019 /** 1020 * one of our workers went away 1021 */ 1022 num_childs++; 1023 } else { 1024 switch (errno) { 1025 case EINTR: 1026 /** 1027 * if we receive a SIGHUP we have to close our logs ourself as we don't 1028 * have the mainloop who can help us here 1029 */ 1030 if (handle_sig_hup) { 1031 handle_sig_hup = 0; 1032 1033 log_error_cycle(srv); 1034 1035 /** 1036 * forward to all procs in the process-group 1037 * 1038 * we also send it ourself 1039 */ 1040 if (!forwarded_sig_hup) { 1041 forwarded_sig_hup = 1; 1042 kill(0, SIGHUP); 1043 } 1044 } 1045 break; 1046 default: 1047 break; 1048 } 1049 } 1050 } 1051 } 1052 1053 /** 1054 * for the parent this is the exit-point 1055 */ 1056 if (!child) { 1057 /** 1058 * kill all children too 1059 */ 1060 if (graceful_shutdown) { 1061 kill(0, SIGINT); 1062 } else if (srv_shutdown) { 1063 kill(0, SIGTERM); 1064 } 1065 1066 log_error_close(srv); 1067 network_close(srv); 1068 connections_free(srv); 1069 plugins_free(srv); 1070 server_free(srv); 1071 return 0; 1072 } 1014 1073 } 1015 1074 #endif … … 1102 1161 log_error_write(srv, __FILE__, __LINE__, "sdsd", 1103 1162 "logfiles cycled UID =", 1104 last_sig term_info.si_uid,1163 last_sighup_info.si_uid, 1105 1164 "PID =", 1106 last_sig term_info.si_pid);1165 last_sighup_info.si_pid); 1107 1166 #else 1108 1167 log_error_write(srv, __FILE__, __LINE__, "s",

