Commit f27e1260 authored by Gavin Brown's avatar Gavin Brown

don't assume rename() works

parent a2cc9a47
......@@ -2,7 +2,6 @@
# Copyright 2014 CentralNic Ltd. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
use Config::Simple;
use Data::Dumper;
use File::Basename qw(basename);
use File::Temp qw(tempfile);
use Getopt::Long;
......@@ -171,9 +170,14 @@ sub process_packet {
$fh->print(encode_json($stats));
$fh->close;
my $dest = $config->{'dsd.directory'}.'/'.basename($file);
rename($file, $dest);
init_stats();
syslog(LOG_DEBUG, "wrote data to $dest") if ($debug);
if (!rename($file, $dest)) {
syslog(LOG_CRIT, "error renaming $file to $dest: $!");
} else {
init_stats();
syslog(LOG_DEBUG, "wrote data to $dest") if ($debug);
}
}
}
}
......@@ -245,10 +249,6 @@ Enable debugging. Implies --foreground.
Include DNS queries observed in debugging output. Ignored unless --debug is
used.
=item --once
Run for one loop then terminate.
=item --help
Show help.
......
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