#include "fs.h"
#include <fcntl.h>
#include <string.h>
+#include <signal.h>
#include <stdlib.h>
#include <sys/ioc_memory.h>
#include <sys/svrctl.h>
* three major activities: getting new work, processing the work, and sending
* the reply. This loop never terminates as long as the file system runs.
*/
+ sigset_t sigset;
int error;
fs_init();
super_user = (fp->fp_effuid == SU_UID ? TRUE : FALSE); /* su? */
/* Check for special control messages first. */
-#if DEAD_CODE
- if (call_nr == HARD_STOP) {
- do_sync();
- sys_exit(0); /* never returns */
- } else
-#endif
- if(call_nr == SYN_ALARM) {
+ if (call_nr == SYS_EVENT) {
+ sigset = m_in.NOTIFY_ARG;
+ if (sigismember(&sigset, SIGKSTOP)) {
+ do_sync();
+ sys_exit(0); /* never returns */
+ }
+ } else if (call_nr == SYN_ALARM) {
/* Not a user request; system has expired one of our timers,
* currently only in use for select(). Check it.
*/
fs_expire_timers(m_in.NOTIFY_TIMESTAMP);
- } else if(call_nr == DEV_SELECTED) {
+ } else if (call_nr == DEV_SELECTED) {
/* Device notify()s us of fd that has become usable. */
select_notified(&m_in);
} else {
case SYS_EVENT:
sigset = (sigset_t) m_in.NOTIFY_ARG;
if (sigismember(&sigset, SIGKMESS)) {
- printf("IS proc SIGKMESS\n");
result = do_new_kmess(&m_in);
- } else if (sigismember(&sigset, SIGTERM)) {
- printf("IS proc SIGTERM\n");
- } else {
- report("IS","warning, got unknown signal", NO_NUM);
+ }
+ if (sigismember(&sigset, SIGTERM)) {
+ /* nothing to do on shutdown */
+ }
+ if (sigismember(&sigset, SIGKSTOP)) {
+ /* nothing to do on shutdown */
}
continue;
case DIAGNOSTICS:
PUBLIC void pm_set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg)
{
int r;
- clock_t now, old_head = 0, new_head;
+ clock_t now, prev_time = 0, next_time;
if((r = getuptime(&now)) != OK)
panic(__FILE__, "PM couldn't get uptime from system task.", NO_NUM);
- tmr_inittimer(tp);
+ /* Set timer argument. */
tmr_arg(tp)->ta_int = arg;
- old_head = tmrs_settimer(&pm_timers, tp, now+ticks, watchdog, &new_head);
+ prev_time = tmrs_settimer(&pm_timers, tp, now+ticks, watchdog, &next_time);
/* reschedule our synchronous alarm if necessary */
- if(! old_head || old_head > new_head) {
- if(sys_syncalrm(SELF, new_head, 1) != OK)
+ if(! prev_time || prev_time > next_time) {
+ if(sys_syncalrm(SELF, next_time, 1) != OK)
panic(__FILE__, "PM set timer couldn't set synchronous alarm.", NO_NUM);
#if VERBOSE
else
- printf("timers: after setting, set synalarm to %d -> %d\n", old_head, new_head);
+ printf("timers: after setting, set synalarm to %d -> %d\n", prev_time, next_time);
#endif
}
PUBLIC void pm_expire_timers(clock_t now)
{
- clock_t new_head;
- tmrs_exptimers(&pm_timers, now, &new_head);
- if(new_head > 0) {
- if(sys_syncalrm(SELF, new_head, 1) != OK)
+ clock_t next_time;
+ tmrs_exptimers(&pm_timers, now, &next_time);
+ if(next_time > 0) {
+ if(sys_syncalrm(SELF, next_time, 1) != OK)
panic(__FILE__, "PM expire timer couldn't set synchronous alarm.", NO_NUM);
#if VERBOSE
else
- printf("timers: after expiry, set synalarm to %d\n", new_head);
+ printf("timers: after expiry, set synalarm to %d\n", next_time);
#endif
}
#if VERBOSE
PUBLIC void pm_cancel_timer(timer_t *tp)
{
- clock_t new_head, old_head;
- old_head = tmrs_clrtimer(&pm_timers, tp, &new_head);
+ clock_t next_time, prev_time;
+ prev_time = tmrs_clrtimer(&pm_timers, tp, &next_time);
/* if the earliest timer has been removed, we have to set
* the synalarm to the next timer, or cancel the synalarm
- * altogether if th last time has been cancelled (new_head
+ * altogether if th last time has been cancelled (next_time
* will be 0 then).
*/
- if(old_head < new_head || ! new_head) {
- if(sys_syncalrm(SELF, new_head, 1) != OK)
+ if(prev_time < next_time || ! next_time) {
+ if(sys_syncalrm(SELF, next_time, 1) != OK)
panic(__FILE__, "PM expire timer couldn't set synchronous alarm.", NO_NUM);
#if VERBOSE
- printf("timers: after cancelling, set synalarm to %d -> %d\n", old_head, new_head);
+ printf("timers: after cancelling, set synalarm to %d -> %d\n", prev_time, next_time);
#endif
}
#if VERBOSE