Commit 7d153ac4 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Merge branch 'master' of git-public.flux.utah.edu:/flux/git/emulab-devel

parents d6064c8b a528684d
......@@ -47,6 +47,7 @@ use POSIX; # for strftime, and sigprocmask and friends
use Fcntl; # file constants for pidfile
use POSIX ":sys_wait_h";
use IO::Poll qw(POLLIN);
use POSIX qw(:errno_h);
# Set up some notification throttling
my $mailgap = 15; # in seconds
......@@ -226,6 +227,7 @@ if ($debug) { qshow(); }
# Gets set if a reload of state from the database should happen.
my $do_reload = 0;
my $do_reopen = 0;
my $sigrestart= 0;
my $sigcleanup= 0;
my $exiting = 0;
......@@ -234,7 +236,7 @@ my $exiting = 0;
# about what would happen if we tried to do this mid-loop. So, we'll
# just set a flag and do it when we're done with our current pass.
$SIG{HUP} = sub { info("SIGHUP - Reloading DB state\n"); $do_reload = 1; };
$SIG{USR2} = sub { info("SIGUSR2 - Reopening logfile\n"); ReOpenLog($LOGFILE); };
$SIG{USR2} = sub { info("SIGUSR2 - Reopening logfile\n"); $do_reopen = 1; };
# Set up other signals.
$SIG{USR1} = \&restart_wrap;
......@@ -281,10 +283,10 @@ sub process_event_queue() {
if ($wait < 0) { debug("Wait was $wait!\n"); $wait=0; }
my $finish = $now + $wait;
while (($event_count != $lastcount || $wait > 0) &&
!($sigrestart || $sigcleanup || $do_reload)) {
!($sigrestart || $sigcleanup || $do_reload || $do_reopen)) {
$lastcount = $event_count;
# Don't block if we got a signal!
if ($wait<=0 || $sigrestart || $sigcleanup || $do_reload) {
if ($wait<=0 || $sigrestart || $sigcleanup || $do_reload || $do_reload){
PollEvents(0, 0);
} else {
#debug("Using blocking event poll - $wait seconds\n");
......@@ -296,7 +298,7 @@ sub process_event_queue() {
#debug("Finished blocking event poll - $wait seconds remain\n");
if ($event_count > 0 &&
(qsize() > 0 || $mailqueue ||
$sigrestart || $sigcleanup || $do_reload)) {
$sigrestart || $sigcleanup || $do_reload || $do_reopen)) {
$blockwait=0;
$wait=0;
#debug("Cancelling wait - timeouts/msgs waiting, or HUP'd\n");
......@@ -347,7 +349,13 @@ while (1) {
if ($sigrestart) { restart(); }
if ($sigcleanup) { cleanup(); }
if ($do_reopen) {
ReOpenLog($LOGFILE);
if (! kill('USR2', $eventchild)) {
fatal("Could not signal(USR2) event reader child\n");
}
$do_reopen = 0;
}
process_event_queue;
}
......@@ -1788,6 +1796,17 @@ sub StartEvents()
# We want to exit on any warning. Let the caller notice.
$SIG{__WARN__} = sub { print STDERR $_[0]; exit(-1); };
# Make sure this child starts writing into the new logfile.
$SIG{USR2} = sub {
print STDERR "Caught a USR2 in child\n";
# Only STDERR can be redirected to the newfile. STDOUT is writing
# to the parent process.
open(STDERR, ">> $LOGFILE") or fatal("reopening $LOGFILE: $!");
select STDERR;
$OUTPUT_AUTOFLUSH = 1;
print STDERR "Opened new logfile in child\n";
};
#
# Just read events and print them to stdout. Parent gets them.
#
......@@ -1806,7 +1825,7 @@ sub StubHandleEvent($$$) {
#
# Print the stuff we care about to stdout for the parent to pick up.
#
print "OBJTYPE='$objtype', OBJNAME='$objname', EVENTTYPE='$eventtype'\n";
print "OBJTYPE='$objtype', OBJNAME='$objname', EVENTTYPE='$eventtype'\n";
if (1) {
print STDERR
"OBJTYPE='$objtype', OBJNAME='$objname', EVENTTYPE='$eventtype'\n";
......@@ -1860,7 +1879,8 @@ sub PollEvents($$)
}
}
elsif ($pollval < 0) {
fatal("Error in nonblocking poll\n");
fatal("Error in nonblocking poll: $!\n")
if ($! != EINTR);
}
return undef;
}
......@@ -430,7 +430,11 @@ sub newVlanNumber($$) {
#
if ((grep {$_ == $number} @numbers) ||
!defined(reserveVlanTag($vlan_id, $number))) {
print STDERR "desired vlan tag for $vlan_id already in use!\n";
my $vlan_using_tag = $self->findVlanUsingTag($number);
print STDERR
"*** desired vlan tag $number for vlan $vlan_id already in " .
"use" . ($vlan_using_tag ? " by vlan $vlan_using_tag" : "") .
"\n";
# Indicates no tag assigned.
return 0;
}
......@@ -444,7 +448,11 @@ sub newVlanNumber($$) {
$number = getReservedVlanTag($vlan_id);
if ($number) {
if (grep {$_ == $number} @numbers) {
print STDERR "reserved vlan tag for $vlan_id already in use!\n";
my $vlan_using_tag = $self->findVlanUsingTag($number);
print STDERR
"*** reserved vlan tag $number for vlan $vlan_id already in " .
"use" . ($vlan_using_tag ? " by vlan $vlan_using_tag" : "") .
"\n";
return 0;
}
return $number;
......@@ -608,6 +616,37 @@ sub findVlan($$) {
return 0;
}
#
# Find what vlan a tag is associated with.
#
# usage: findVlanUsingTag($self, $number)
# returns the vlan_id if found
# 0 otherwise;
#
sub findVlanUsingTag($$) {
my ($self, $number) = @_;
$self->debug("snmpit_stack::findVlanUsingTag( $number )\n");
if ($parallelized) {
my %dev_map = $self->findVlans();
foreach my $vlan_id (keys(%dev_map)) {
return $vlan_id
if ($number == $dev_map{$vlan_id});
}
return 0;
}
foreach my $devicename (sort {tbsort($a,$b)} keys %{$self->{DEVICES}}) {
my $device = $self->{DEVICES}->{$devicename};
my %dev_map = $device->findVlans();
foreach my $vlan_id (keys(%dev_map)) {
return $vlan_id
if ($number == $dev_map{$vlan_id});
}
return 0;
}
return 0;
}
#
# Check to see if the given VLAN exists in the stack
#
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment