~ubuntu-branches/ubuntu/hardy/lighttpd/hardy

« back to all changes in this revision

Viewing changes to src/server.c

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2007-09-05 09:30:15 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070905093015-pm98jekbu9ylcd3w
Tags: 1.4.17-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Update maintainer field in debian/control.
  - Build against libgamin-dev rather than libfam-dev (fixes a warning
    during startup)
  - Make sure that upgrades succeed, even if we can't restart lighttpd.
  - Clean environment in init.d script.

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
static volatile sig_atomic_t handle_sig_hup = 0;
71
71
 
72
72
#if defined(HAVE_SIGACTION) && defined(SA_SIGINFO)
 
73
static volatile siginfo_t last_sigterm_info;
 
74
static volatile siginfo_t last_sighup_info;
 
75
 
73
76
static void sigaction_handler(int sig, siginfo_t *si, void *context) {
74
 
        UNUSED(si);
75
77
        UNUSED(context);
76
78
 
77
79
        switch (sig) {
78
 
        case SIGTERM: srv_shutdown = 1; break;
 
80
        case SIGTERM:
 
81
                srv_shutdown = 1;
 
82
                memcpy(&last_sigterm_info, si, sizeof(*si));
 
83
                break;
79
84
        case SIGINT:
80
 
             if (graceful_shutdown) srv_shutdown = 1;
81
 
             else graceful_shutdown = 1;
 
85
                if (graceful_shutdown) {
 
86
                        srv_shutdown = 1;
 
87
                } else {
 
88
                        graceful_shutdown = 1;
 
89
                }
 
90
                memcpy(&last_sigterm_info, si, sizeof(*si));
82
91
 
83
 
             break;
84
 
        case SIGALRM: handle_sig_alarm = 1; break;
85
 
        case SIGHUP:  handle_sig_hup = 1; break;
86
 
        case SIGCHLD: break;
 
92
                break;
 
93
        case SIGALRM: 
 
94
                handle_sig_alarm = 1; 
 
95
                break;
 
96
        case SIGHUP:
 
97
                handle_sig_hup = 1;
 
98
                memcpy(&last_sighup_info, si, sizeof(*si));
 
99
                break;
 
100
        case SIGCHLD:
 
101
                break;
87
102
        }
88
103
}
89
104
#elif defined(HAVE_SIGNAL) || defined(HAVE_SIGACTION)
760
775
                        setuid(pwd->pw_uid);
761
776
                }
762
777
#endif
763
 
#ifdef HAVE_PRCTL
 
778
#ifdef HAVE_SYS_PRCTL_H
764
779
                if (srv->srvconf.enable_cores) {
765
780
                        prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
766
781
                }
1079
1094
                                log_error_write(srv, __FILE__, __LINE__, "s", "cycling errorlog failed, dying");
1080
1095
 
1081
1096
                                return -1;
 
1097
                        } else {
 
1098
#ifdef HAVE_SIGACTION
 
1099
                                log_error_write(srv, __FILE__, __LINE__, "sdsd", 
 
1100
                                        "logfiles cycled UID =",
 
1101
                                        last_sigterm_info.si_uid,
 
1102
                                        "PID =",
 
1103
                                        last_sigterm_info.si_pid);
 
1104
#else
 
1105
                                log_error_write(srv, __FILE__, __LINE__, "s", 
 
1106
                                        "logfiles cycled");
 
1107
#endif
1082
1108
                        }
1083
1109
                }
1084
1110
 
1378
1404
                }
1379
1405
        }
1380
1406
 
 
1407
#ifdef HAVE_SIGACTION
 
1408
        log_error_write(srv, __FILE__, __LINE__, "sdsd", 
 
1409
                        "server stopped by UID =",
 
1410
                        last_sigterm_info.si_uid,
 
1411
                        "PID =",
 
1412
                        last_sigterm_info.si_pid);
 
1413
#else
 
1414
        log_error_write(srv, __FILE__, __LINE__, "s", 
 
1415
                        "server stopped");
 
1416
#endif
 
1417
 
1381
1418
        /* clean-up */
1382
1419
        log_error_close(srv);
1383
1420
        network_close(srv);