[freeside-commits] branch master updated. d8540d8199066c1c0f3fde450f68bceb0e341531
Ivan
ivan at 420.am
Tue Mar 25 21:30:44 PDT 2014
The branch, master has been updated
via d8540d8199066c1c0f3fde450f68bceb0e341531 (commit)
from 90dd1d7c7a1b1d0c57c05a696f936df6247d98e3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit d8540d8199066c1c0f3fde450f68bceb0e341531
Author: Ivan Kohler <ivan at freeside.biz>
Date: Tue Mar 25 21:30:38 2014 -0700
close cursors on DESTROY in same process, RT#26262
diff --git a/FS/FS/Cursor.pm b/FS/FS/Cursor.pm
index 24ebf58..ec7af93 100644
--- a/FS/FS/Cursor.pm
+++ b/FS/FS/Cursor.pm
@@ -49,6 +49,9 @@ sub new {
# the class of record object to return
$self->{class} = "FS::".($q->{table} || 'Record');
+ # save for later, so forked children will not destroy me when they exit
+ $self->{pid} = $$;
+
$self->{id} = sprintf('cursor%08x', refaddr($self));
my $statement = "DECLARE ".$self->{id}." CURSOR FOR ".$q->{statement};
@@ -101,6 +104,7 @@ sub refill {
sub DESTROY {
my $self = shift;
+ return unless $self->{pid} eq $$;
dbh->do('CLOSE '. $self->{id}) or die dbh->errstr; # clean-up the cursor in Pg
}
@@ -114,6 +118,12 @@ Replace all uses of qsearch with this.
Doesn't support MySQL.
+The cursor will close prematurely if any code issues a rollback/commit. If
+you need protection against this use qsearch or fork and get a new dbh
+handle.
+Normally this issue will represent itself this message.
+ERROR: cursor "cursorXXXXXXX" does not exist.
+
=head1 SEE ALSO
L<FS::Record>
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Cursor.pm | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
More information about the freeside-commits
mailing list