Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
7bf8736c
Commit
7bf8736c
authored
May 22, 2003
by
Mac Newbold
Browse files
Fix sig handling per Rob's instructions so we don't reenter the elvin
code when taking a signal.
parent
cbfd8776
Changes
1
Hide whitespace changes
Inline
Side-by-side
event/stated/stated.in
View file @
7bf8736c
...
@@ -191,6 +191,8 @@ if ($debug) { qshow(); }
...
@@ -191,6 +191,8 @@ if ($debug) { qshow(); }
# Gets set if a reload of state from the database should happen.
# Gets set if a reload of state from the database should happen.
my
$do_reload
=
0
;
my
$do_reload
=
0
;
my
$sigrestart
=
0
;
my
$sigcleanup
=
0
;
# Make the daemon reload database state on a sighup - but I'm worried
# Make the daemon reload database state on a sighup - but I'm worried
# about what would happen if we tried to do this mid-loop. So, we'll
# about what would happen if we tried to do this mid-loop. So, we'll
...
@@ -198,13 +200,13 @@ my $do_reload = 0;
...
@@ -198,13 +200,13 @@ my $do_reload = 0;
$SIG
{
HUP
}
=
sub
{
info
("
SIGHUP - Reloading DB state
\n
");
$do_reload
=
1
;
};
$SIG
{
HUP
}
=
sub
{
info
("
SIGHUP - Reloading DB state
\n
");
$do_reload
=
1
;
};
# Set up other signals.
# Set up other signals.
$SIG
{
USR1
}
=
\
&restart
;
$SIG
{
USR1
}
=
\
&restart
_wrap
;
$SIG
{
USR2
}
=
\
&cleanup
;
$SIG
{
USR2
}
=
\
&cleanup
_wrap
;
$SIG
{
INT
}
=
\
&cleanup
;
$SIG
{
INT
}
=
\
&cleanup
_wrap
;
$SIG
{
QUIT
}
=
\
&cleanup
;
$SIG
{
QUIT
}
=
\
&cleanup
_wrap
;
$SIG
{
ABRT
}
=
\
&cleanup
;
$SIG
{
ABRT
}
=
\
&cleanup
_wrap
;
$SIG
{
TERM
}
=
\
&cleanup
;
$SIG
{
TERM
}
=
\
&cleanup
_wrap
;
$SIG
{
KILL
}
=
\
&cleanup
;
$SIG
{
KILL
}
=
\
&cleanup
_wrap
;
# Track if I handled an event or not
# Track if I handled an event or not
my
$event_count
=
0
;
my
$event_count
=
0
;
...
@@ -312,6 +314,9 @@ while (1) {
...
@@ -312,6 +314,9 @@ while (1) {
# Send any messages in the queue if it is time
# Send any messages in the queue if it is time
notify
("",
1
);
notify
("",
1
);
if
(
$sigrestart
)
{
restart
();
}
if
(
$sigcleanup
)
{
cleanup
();
}
#sleep(1);
#sleep(1);
}
}
...
@@ -1084,10 +1089,10 @@ sub info($;$) {
...
@@ -1084,10 +1089,10 @@ sub info($;$) {
syslog
(
$prio
,
$message
)
||
notify
("
syslog failed: $? $!
\n
");
syslog
(
$prio
,
$message
)
||
notify
("
syslog failed: $? $!
\n
");
}
}
sub
restart_wrap
{
$sigrestart
=
1
;
}
# This gets called if we catch a signal USR1
# This gets called if we catch a signal USR1
sub
restart
{
sub
restart
{
info
("
SIGUSER1 received: Performing final event poll before restarting
\n
");
process_event_queue
;
my
$params
=
join
("
",
@args
);
my
$params
=
join
("
",
@args
);
my
$prog
=
"";
my
$prog
=
"";
# If we're started from an abosolute path, use that.
# If we're started from an abosolute path, use that.
...
@@ -1096,6 +1101,9 @@ sub restart {
...
@@ -1096,6 +1101,9 @@ sub restart {
}
else
{
}
else
{
$prog
=
"
$TB
/sbin/stated
";
$prog
=
"
$TB
/sbin/stated
";
}
}
info
("
SIGUSER1 received: Performing final event poll before restarting
\n
");
$blockwait
=
0
;
process_event_queue
;
info
("
Restarting from '
$prog
"
.
(
$params
ne
""
?
"
$params
"
:
"")
.
"
'
\n
");
info
("
Restarting from '
$prog
"
.
(
$params
ne
""
?
"
$params
"
:
"")
.
"
'
\n
");
if
(
$handle
&&
event_unregister
(
$handle
)
==
0
)
{
if
(
$handle
&&
event_unregister
(
$handle
)
==
0
)
{
warn
"
Unable to unregister with event system
\n
";
warn
"
Unable to unregister with event system
\n
";
...
@@ -1117,6 +1125,8 @@ sub restart {
...
@@ -1117,6 +1125,8 @@ sub restart {
};
};
}
}
sub
cleanup_wrap
{
$sigcleanup
=
1
;
}
# This gets called if we catch a signal (TERM, etc.)
# This gets called if we catch a signal (TERM, etc.)
sub
cleanup
{
sub
cleanup
{
notify
("
Signal received, exiting
\n
");
notify
("
Signal received, exiting
\n
");
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment