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',
);
my $rebuild_mib = 1;
my $rebuild_mib = 0;
### Mappings of types provided by SNMP::getType() to those
### used by NetSNMP::ASN
......@@ -147,7 +147,7 @@ my %type_tr =
);
##
my $snabb_shmem_dir_ctime;
my $snabb_shmem_dir_ctime = 0;
my %shmem;
our %compound_scalar_handlers =
( accumulator => sub {
......@@ -505,13 +505,12 @@ sub agentx_handler {
sub idx_watcher() {
unless ($rebuild_mib) {
opendir(SHMEMD, $config{shmem_dir}) or die
"open of directory $config{shmem_dir} failed: $!";
if (opendir(SHMEMD, $config{shmem_dir})) {
my $ctime = (stat(SHMEMD))[9] or die
"stat of directory $config{shmem_dir} failed: $!";
close(SHMEMD);
if ($ctime != $snabb_shmem_dir_ctime) {
print("idx_watcher: data directory change detected.\n");
print("idx_watcher: data directory $config{shmem_dir} change detected\n");
$rebuild_mib = 1;
} else {
for my $segment (keys(%shmem)) {
......@@ -528,6 +527,9 @@ sub idx_watcher() {
}
}
}
} else {
warn "open of directory $config{shmem_dir} failed: $!";
}
}
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