This server has been upgraded to version 12.6.4. Enjoy!

Commit 65b799d9 authored by Alexander Gall's avatar Alexander Gall

Improve detection of changed shmem segments

Always check for a change of the shmem segment at startup
and don't die when the shmem directory doesn't exist.
parent c791471a
...@@ -130,7 +130,7 @@ my %class_map = ( INTEGER => 'Snabb::SNMP::Tie::INTEGER', ...@@ -130,7 +130,7 @@ my %class_map = ( INTEGER => 'Snabb::SNMP::Tie::INTEGER',
); );
my $rebuild_mib = 1; my $rebuild_mib = 0;
### Mappings of types provided by SNMP::getType() to those ### Mappings of types provided by SNMP::getType() to those
### used by NetSNMP::ASN ### used by NetSNMP::ASN
...@@ -147,7 +147,7 @@ my %type_tr = ...@@ -147,7 +147,7 @@ my %type_tr =
); );
## ##
my $snabb_shmem_dir_ctime; my $snabb_shmem_dir_ctime = 0;
my %shmem; my %shmem;
our %compound_scalar_handlers = our %compound_scalar_handlers =
( accumulator => sub { ( accumulator => sub {
...@@ -505,28 +505,30 @@ sub agentx_handler { ...@@ -505,28 +505,30 @@ sub agentx_handler {
sub idx_watcher() { sub idx_watcher() {
unless ($rebuild_mib) { unless ($rebuild_mib) {
opendir(SHMEMD, $config{shmem_dir}) or die if (opendir(SHMEMD, $config{shmem_dir})) {
"open of directory $config{shmem_dir} failed: $!"; my $ctime = (stat(SHMEMD))[9] or die
my $ctime = (stat(SHMEMD))[9] or die "stat of directory $config{shmem_dir} failed: $!";
"stat of directory $config{shmem_dir} failed: $!"; close(SHMEMD);
close(SHMEMD); if ($ctime != $snabb_shmem_dir_ctime) {
if ($ctime != $snabb_shmem_dir_ctime) { print("idx_watcher: data directory $config{shmem_dir} change detected\n");
print("idx_watcher: data directory change detected.\n"); $rebuild_mib = 1;
$rebuild_mib = 1; } else {
} else { for my $segment (keys(%shmem)) {
for my $segment (keys(%shmem)) { my $idx = $shmem{$segment}{file}.".index";
my $idx = $shmem{$segment}{file}.".index"; open(IDX, $idx) or die
open(IDX, $idx) or die "idx_watcher: can't open $idx: $!";
"idx_watcher: can't open $idx: $!"; my $mtime = (stat(IDX))[9] or die
my $mtime = (stat(IDX))[9] or die "idx_watcher: can't stat $idx: $!";
"idx_watcher: can't stat $idx: $!"; close(IDX);
close(IDX); if ($mtime != $shmem{$segment}{idx_mtime}) {
if ($mtime != $shmem{$segment}{idx_mtime}) { print("idx_watcher: $idx changed\n");
print("idx_watcher: $idx changed\n"); $rebuild_mib = 1;
$rebuild_mib = 1; last;
last; }
} }
} }
} else {
warn "open of directory $config{shmem_dir} failed: $!";
} }
} }
alarm $config{check_interval}; alarm $config{check_interval};
......
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