diff options
author | Eric Wong <e@80x24.org> | 2023-10-10 10:07:56 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-10-10 19:11:45 +0000 |
commit | 7d75e148e550a93548d09f05cc98be6c5fd63fc0 (patch) | |
tree | 690e06d483426653d5594fbe8b7018000b6118e3 /lib/PublicInbox/Over.pm | |
parent | c3599884198dd5db51ed82058b08fc6851a3e375 (diff) | |
download | public-inbox-7d75e148e550a93548d09f05cc98be6c5fd63fc0.tar.gz |
These may've been causing strange errors[1] in t/imapd.t from the -watch daemon, such as: Cannot copy to HASH in scalar assignment ../PublicInbox/Over.pm in the Over->dbh() sub. I've only noticed this failure on FreeBSD 13.2 (Perl 5.32.1, DBD::SQLite 1.72 (bundled SQLite 3.39.4), DBI 1.643) so far, so it could also be something to do with the versions used and/or memory layout differences with libc or build toolchain.
Diffstat (limited to 'lib/PublicInbox/Over.pm')
-rw-r--r-- | lib/PublicInbox/Over.pm | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm index e3a8adb1..4eed4f46 100644 --- a/lib/PublicInbox/Over.pm +++ b/lib/PublicInbox/Over.pm @@ -82,7 +82,13 @@ sub dbh_close { } } -sub dbh ($) { $_[0]->{dbh} //= $_[0]->dbh_new } # dbh_new may be subclassed +sub dbh ($) { + my ($self) = @_; + $self->{dbh} // do { + my $dbh = $self->dbh_new; # dbh_new may be subclassed + $self->{dbh} = $dbh; + } +} sub load_from_row ($;$) { my ($smsg, $cull) = @_; @@ -256,9 +262,12 @@ SELECT ts,ds,ddd FROM over WHERE $s sub get_art { my ($self, $num) = @_; # caching $sth ourselves is faster than prepare_cached - my $sth = $self->{-get_art} //= dbh($self)->prepare(<<''); + my $sth = $self->{-get_art} // do { + my $sth = dbh($self)->prepare(<<''); SELECT num,tid,ds,ts,ddd FROM over WHERE num = ? LIMIT 1 + $self->{-get_art} = $sth; + }; $sth->execute($num); my $smsg = $sth->fetchrow_hashref; $smsg ? load_from_row($smsg) : undef; |