Yeah, the performance cost is why I only update the DB after a successful send, and then only with basic info, not all the different pkt type counts.You could consider using a shared memory segment or mmap'd file for this sort of information; they're very fast, but the OS can provide persistence even if your process dies.
As for the eval{}, feel free to try it on the above code.Well, the code below worked for me reliably over a few hundred connects...
#!/usr/bin/perl use warnings; use strict; use DBI; while(1) { eval { my $dbh = DBI->connect("DBI:mysql:database=test","blah","blah") or die "Couldn't connect to DB\n"; my $sth = $dbh->prepare("SELECT * FROM sometable\n") or die "Couldn't prepare\n"; $sth->execute() or die "Couldn't execute\n"; my @row = $sth->fetchrow_array(); $sth->finish; }; if ($@) { warn "DB error: $@"; } }
In reply to Re^5: Ignoring/Trapping the DIE signal
by sgifford
in thread Ignoring/Trapping the DIE signal
by chrism01
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |