Grokbase Groups Perl dbi-dev May 2003
FAQ
Tim,

While the subject is current, here are some proposed patches for PlRPC,
Proxy and ProxyServer.

In no particular order:

- Ensure that a disconnect actually does so. The code currently leaves
both database connection at the server and the TCP socket open, tieing up
resources.

- Fix PlRPC connect when compression is in use.

- Mark client handle as 'Active' following a synchronous prepare. Fixes
complaints about "..handle clear whilst active..".

Index: lib/DBD/Proxy.pm
===================================================================
RCS file: /afs/btv.ibm.com/data/a29v/devel/cvs_repository/ACT/hirschs/perl_modules/DBI/lib/DBD/Proxy.pm,v
retrieving revision 1.1.1.2
retrieving revision 1.14
diff -u -r1.1.1.2 -r1.14
--- lib/DBD/Proxy.pm 2003/05/05 14:10:34 1.1.1.2
+++ lib/DBD/Proxy.pm 2003/05/08 18:20:12 1.14
@@ -25,7 +25,7 @@
require DBI;
DBI->require_version(1.0201);

-use RPC::PlClient 0.2000;
+use RPC::PlClient 0.2017;



@@ -267,12 +267,16 @@

sub disconnect ($) {
my ($dbh) = @_;
- # XXX this should call $rdbh->disconnect to get the right
- # disconnect behaviour. It should not undef these values.
- # A proxy_no_disconnect option could be added (like for finish)
- # to let people trade safety for speed if they need to.
- undef $dbh->{'proxy_dbh'}; # Bug in Perl 5.004; would prefer delete
- undef $dbh->{'proxy_client'};
+
+ # Drop database connection at remote end
+ my $rdbh = $dbh->{'proxy_dbh'};
+ local $SIG{__DIE__} = 'DEFAULT';
+ eval { $rdbh->disconnect() };
+ return DBD::Proxy::proxy_set_err($dbh, $@) if $@;
+
+ # Close TCP connect to remote
+ $dbh->{proxy_client}->Disconnect();
+
$dbh->SUPER::STORE('Active' => 0);
1;
}
@@ -339,6 +343,8 @@
$sth->{'proxy_sth'} = $rsth;
# If statement is a positioned update we do not want any readahead.
$sth->{'RowCacheSize'} = 1 if $stmt =~ /\bfor\s+update\b/i;
+ # Since resources are used by prepared remote handle, mark us active.
+ $sth->SUPER::STORE('Active' => 1);
}
$sth;
}
Index: lib/DBI/ProxyServer.pm
===================================================================
RCS file: /afs/btv.ibm.com/data/a29v/devel/cvs_repository/ACT/hirschs/perl_modules/DBI/lib/DBI/ProxyServer.pm,v
retrieving revision 1.1.1.2
retrieving revision 1.10
diff -u -r1.1.1.2 -r1.10
--- lib/DBI/ProxyServer.pm 2003/05/05 14:10:34 1.1.1.2
+++ lib/DBI/ProxyServer.pm 2003/05/08 18:18:19 1.10
@@ -90,7 +90,8 @@
'func' => 1,
'quote' => 1,
'type_info_all' => 1,
- 'table_info' => 1
+ 'table_info' => 1,
+ 'disconnect' => 1
},
'DBI::ProxyServer::st' => {
'execute' => 1,


Index: lib/RPC/PlClient.pm
===================================================================
RCS file: /afs/btv.ibm.com/data/a29v/devel/cvs_repository/ACT/hirschs/perl_modules/PlRPC/lib/RPC/PlClient.pm,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
--- lib/RPC/PlClient.pm 2003/05/05 18:12:39 1.1.1.1
+++ lib/RPC/PlClient.pm 2003/05/05 18:19:02 1.3
@@ -30,7 +30,7 @@

package RPC::PlClient;

-$RPC::PlClient::VERSION = '0.2016';
+$RPC::PlClient::VERSION = '0.2017';
@RPC::PlClient::ISA = qw(Net::Daemon::Log);


@@ -52,6 +52,8 @@
my $self = {@_};
bless($self, (ref($proto) || $proto));

+ $self->RPC::PlServer::Comm::Init();
+
my $app = $self->{'application'} or
$self->Fatal("Missing application name");
my $version = $self->{'version'} or
@@ -86,7 +88,6 @@
die "Refused by server: $msg" unless $reply->[0];
$self->Debug("Logged in, server replies: $msg");

- $self->RPC::PlServer::Comm::Init();
return ($self, $msg) if wantarray;
$self;
}
@@ -125,6 +126,11 @@
RPC::PlClient::Object->new($1, $client, $object);
}

+sub Disconnect {
+ my $self = shift;
+ $self->{'socket'} = undef;
+ 1;
+}

package RPC::PlClient::Object;




--
----------------------------------------------------------------
Steven N. Hirsch tie-line: 446-6557 ext: 802-769-6557

Staff Engineer Methodology Integration Team
ASIC Product Development IBM Microelectronics
----------------------------------------------------------------

Search Discussions

  • Tim Bunce at May 9, 2003 at 4:36 pm
    Great. Thanks.

    Tim.
    On Fri, May 09, 2003 at 11:07:22AM -0400, Steven N. Hirsch wrote:
    Tim,

    While the subject is current, here are some proposed patches for PlRPC,
    Proxy and ProxyServer.

    In no particular order:

    - Ensure that a disconnect actually does so. The code currently leaves
    both database connection at the server and the TCP socket open, tieing up
    resources.

    - Fix PlRPC connect when compression is in use.

    - Mark client handle as 'Active' following a synchronous prepare. Fixes
    complaints about "..handle clear whilst active..".

    Index: lib/DBD/Proxy.pm
    ===================================================================
    RCS file: /afs/btv.ibm.com/data/a29v/devel/cvs_repository/ACT/hirschs/perl_modules/DBI/lib/DBD/Proxy.pm,v
    retrieving revision 1.1.1.2
    retrieving revision 1.14
    diff -u -r1.1.1.2 -r1.14
    --- lib/DBD/Proxy.pm 2003/05/05 14:10:34 1.1.1.2
    +++ lib/DBD/Proxy.pm 2003/05/08 18:20:12 1.14
    @@ -25,7 +25,7 @@
    require DBI;
    DBI->require_version(1.0201);

    -use RPC::PlClient 0.2000;
    +use RPC::PlClient 0.2017;



    @@ -267,12 +267,16 @@

    sub disconnect ($) {
    my ($dbh) = @_;
    - # XXX this should call $rdbh->disconnect to get the right
    - # disconnect behaviour. It should not undef these values.
    - # A proxy_no_disconnect option could be added (like for finish)
    - # to let people trade safety for speed if they need to.
    - undef $dbh->{'proxy_dbh'}; # Bug in Perl 5.004; would prefer delete
    - undef $dbh->{'proxy_client'};
    +
    + # Drop database connection at remote end
    + my $rdbh = $dbh->{'proxy_dbh'};
    + local $SIG{__DIE__} = 'DEFAULT';
    + eval { $rdbh->disconnect() };
    + return DBD::Proxy::proxy_set_err($dbh, $@) if $@;
    +
    + # Close TCP connect to remote
    + $dbh->{proxy_client}->Disconnect();
    +
    $dbh->SUPER::STORE('Active' => 0);
    1;
    }
    @@ -339,6 +343,8 @@
    $sth->{'proxy_sth'} = $rsth;
    # If statement is a positioned update we do not want any readahead.
    $sth->{'RowCacheSize'} = 1 if $stmt =~ /\bfor\s+update\b/i;
    + # Since resources are used by prepared remote handle, mark us active.
    + $sth->SUPER::STORE('Active' => 1);
    }
    $sth;
    }
    Index: lib/DBI/ProxyServer.pm
    ===================================================================
    RCS file: /afs/btv.ibm.com/data/a29v/devel/cvs_repository/ACT/hirschs/perl_modules/DBI/lib/DBI/ProxyServer.pm,v
    retrieving revision 1.1.1.2
    retrieving revision 1.10
    diff -u -r1.1.1.2 -r1.10
    --- lib/DBI/ProxyServer.pm 2003/05/05 14:10:34 1.1.1.2
    +++ lib/DBI/ProxyServer.pm 2003/05/08 18:18:19 1.10
    @@ -90,7 +90,8 @@
    'func' => 1,
    'quote' => 1,
    'type_info_all' => 1,
    - 'table_info' => 1
    + 'table_info' => 1,
    + 'disconnect' => 1
    },
    'DBI::ProxyServer::st' => {
    'execute' => 1,


    Index: lib/RPC/PlClient.pm
    ===================================================================
    RCS file: /afs/btv.ibm.com/data/a29v/devel/cvs_repository/ACT/hirschs/perl_modules/PlRPC/lib/RPC/PlClient.pm,v
    retrieving revision 1.1.1.1
    retrieving revision 1.3
    diff -u -r1.1.1.1 -r1.3
    --- lib/RPC/PlClient.pm 2003/05/05 18:12:39 1.1.1.1
    +++ lib/RPC/PlClient.pm 2003/05/05 18:19:02 1.3
    @@ -30,7 +30,7 @@

    package RPC::PlClient;

    -$RPC::PlClient::VERSION = '0.2016';
    +$RPC::PlClient::VERSION = '0.2017';
    @RPC::PlClient::ISA = qw(Net::Daemon::Log);


    @@ -52,6 +52,8 @@
    my $self = {@_};
    bless($self, (ref($proto) || $proto));

    + $self->RPC::PlServer::Comm::Init();
    +
    my $app = $self->{'application'} or
    $self->Fatal("Missing application name");
    my $version = $self->{'version'} or
    @@ -86,7 +88,6 @@
    die "Refused by server: $msg" unless $reply->[0];
    $self->Debug("Logged in, server replies: $msg");

    - $self->RPC::PlServer::Comm::Init();
    return ($self, $msg) if wantarray;
    $self;
    }
    @@ -125,6 +126,11 @@
    RPC::PlClient::Object->new($1, $client, $object);
    }

    +sub Disconnect {
    + my $self = shift;
    + $self->{'socket'} = undef;
    + 1;
    +}

    package RPC::PlClient::Object;




    --
    ----------------------------------------------------------------
    Steven N. Hirsch tie-line: 446-6557 ext: 802-769-6557

    Staff Engineer Methodology Integration Team
    ASIC Product Development IBM Microelectronics
    ----------------------------------------------------------------
  • Tim Bunce at May 10, 2003 at 9:28 pm
    I've CC'd Jochen as he needs to apply the PlRPC patches and make a
    new release before I can depend on them being available.

    For the Disconnect calls I'll just explicitly undef the socket entry
    in the hash.

    Thanks.

    Tim.
    On Fri, May 09, 2003 at 11:07:22AM -0400, Steven N. Hirsch wrote:
    Tim,

    While the subject is current, here are some proposed patches for PlRPC,
    Proxy and ProxyServer.

    In no particular order:

    - Ensure that a disconnect actually does so. The code currently leaves
    both database connection at the server and the TCP socket open, tieing up
    resources.

    - Fix PlRPC connect when compression is in use.

    - Mark client handle as 'Active' following a synchronous prepare. Fixes
    complaints about "..handle clear whilst active..".

    Index: lib/DBD/Proxy.pm
    ===================================================================
    RCS file: /afs/btv.ibm.com/data/a29v/devel/cvs_repository/ACT/hirschs/perl_modules/DBI/lib/DBD/Proxy.pm,v
    retrieving revision 1.1.1.2
    retrieving revision 1.14
    diff -u -r1.1.1.2 -r1.14
    --- lib/DBD/Proxy.pm 2003/05/05 14:10:34 1.1.1.2
    +++ lib/DBD/Proxy.pm 2003/05/08 18:20:12 1.14
    @@ -25,7 +25,7 @@
    require DBI;
    DBI->require_version(1.0201);

    -use RPC::PlClient 0.2000;
    +use RPC::PlClient 0.2017;



    @@ -267,12 +267,16 @@

    sub disconnect ($) {
    my ($dbh) = @_;
    - # XXX this should call $rdbh->disconnect to get the right
    - # disconnect behaviour. It should not undef these values.
    - # A proxy_no_disconnect option could be added (like for finish)
    - # to let people trade safety for speed if they need to.
    - undef $dbh->{'proxy_dbh'}; # Bug in Perl 5.004; would prefer delete
    - undef $dbh->{'proxy_client'};
    +
    + # Drop database connection at remote end
    + my $rdbh = $dbh->{'proxy_dbh'};
    + local $SIG{__DIE__} = 'DEFAULT';
    + eval { $rdbh->disconnect() };
    + return DBD::Proxy::proxy_set_err($dbh, $@) if $@;
    +
    + # Close TCP connect to remote
    + $dbh->{proxy_client}->Disconnect();
    +
    $dbh->SUPER::STORE('Active' => 0);
    1;
    }
    @@ -339,6 +343,8 @@
    $sth->{'proxy_sth'} = $rsth;
    # If statement is a positioned update we do not want any readahead.
    $sth->{'RowCacheSize'} = 1 if $stmt =~ /\bfor\s+update\b/i;
    + # Since resources are used by prepared remote handle, mark us active.
    + $sth->SUPER::STORE('Active' => 1);
    }
    $sth;
    }
    Index: lib/DBI/ProxyServer.pm
    ===================================================================
    RCS file: /afs/btv.ibm.com/data/a29v/devel/cvs_repository/ACT/hirschs/perl_modules/DBI/lib/DBI/ProxyServer.pm,v
    retrieving revision 1.1.1.2
    retrieving revision 1.10
    diff -u -r1.1.1.2 -r1.10
    --- lib/DBI/ProxyServer.pm 2003/05/05 14:10:34 1.1.1.2
    +++ lib/DBI/ProxyServer.pm 2003/05/08 18:18:19 1.10
    @@ -90,7 +90,8 @@
    'func' => 1,
    'quote' => 1,
    'type_info_all' => 1,
    - 'table_info' => 1
    + 'table_info' => 1,
    + 'disconnect' => 1
    },
    'DBI::ProxyServer::st' => {
    'execute' => 1,


    Index: lib/RPC/PlClient.pm
    ===================================================================
    RCS file: /afs/btv.ibm.com/data/a29v/devel/cvs_repository/ACT/hirschs/perl_modules/PlRPC/lib/RPC/PlClient.pm,v
    retrieving revision 1.1.1.1
    retrieving revision 1.3
    diff -u -r1.1.1.1 -r1.3
    --- lib/RPC/PlClient.pm 2003/05/05 18:12:39 1.1.1.1
    +++ lib/RPC/PlClient.pm 2003/05/05 18:19:02 1.3
    @@ -30,7 +30,7 @@

    package RPC::PlClient;

    -$RPC::PlClient::VERSION = '0.2016';
    +$RPC::PlClient::VERSION = '0.2017';
    @RPC::PlClient::ISA = qw(Net::Daemon::Log);


    @@ -52,6 +52,8 @@
    my $self = {@_};
    bless($self, (ref($proto) || $proto));

    + $self->RPC::PlServer::Comm::Init();
    +
    my $app = $self->{'application'} or
    $self->Fatal("Missing application name");
    my $version = $self->{'version'} or
    @@ -86,7 +88,6 @@
    die "Refused by server: $msg" unless $reply->[0];
    $self->Debug("Logged in, server replies: $msg");

    - $self->RPC::PlServer::Comm::Init();
    return ($self, $msg) if wantarray;
    $self;
    }
    @@ -125,6 +126,11 @@
    RPC::PlClient::Object->new($1, $client, $object);
    }

    +sub Disconnect {
    + my $self = shift;
    + $self->{'socket'} = undef;
    + 1;
    +}

    package RPC::PlClient::Object;




    --
    ----------------------------------------------------------------
    Steven N. Hirsch tie-line: 446-6557 ext: 802-769-6557

    Staff Engineer Methodology Integration Team
    ASIC Product Development IBM Microelectronics
    ----------------------------------------------------------------
  • Steven N. Hirsch at May 10, 2003 at 10:00 pm

    On Sat, 10 May 2003, Tim Bunce wrote:

    I've CC'd Jochen as he needs to apply the PlRPC patches and make a
    new release before I can depend on them being available.

    For the Disconnect calls I'll just explicitly undef the socket entry
    in the hash.
    Cool. That's actually what I started off with before deciding to "do the
    right thing (tm)" and abstract behind a method!

    Steve

    Thanks.

    Tim.
    On Fri, May 09, 2003 at 11:07:22AM -0400, Steven N. Hirsch wrote:
    Tim,

    While the subject is current, here are some proposed patches for PlRPC,
    Proxy and ProxyServer.

    In no particular order:

    - Ensure that a disconnect actually does so. The code currently leaves
    both database connection at the server and the TCP socket open, tieing up
    resources.

    - Fix PlRPC connect when compression is in use.

    - Mark client handle as 'Active' following a synchronous prepare. Fixes
    complaints about "..handle clear whilst active..".

    Index: lib/DBD/Proxy.pm
    ===================================================================
    RCS file: /afs/btv.ibm.com/data/a29v/devel/cvs_repository/ACT/hirschs/perl_modules/DBI/lib/DBD/Proxy.pm,v
    retrieving revision 1.1.1.2
    retrieving revision 1.14
    diff -u -r1.1.1.2 -r1.14
    --- lib/DBD/Proxy.pm 2003/05/05 14:10:34 1.1.1.2
    +++ lib/DBD/Proxy.pm 2003/05/08 18:20:12 1.14
    @@ -25,7 +25,7 @@
    require DBI;
    DBI->require_version(1.0201);

    -use RPC::PlClient 0.2000;
    +use RPC::PlClient 0.2017;



    @@ -267,12 +267,16 @@

    sub disconnect ($) {
    my ($dbh) = @_;
    - # XXX this should call $rdbh->disconnect to get the right
    - # disconnect behaviour. It should not undef these values.
    - # A proxy_no_disconnect option could be added (like for finish)
    - # to let people trade safety for speed if they need to.
    - undef $dbh->{'proxy_dbh'}; # Bug in Perl 5.004; would prefer delete
    - undef $dbh->{'proxy_client'};
    +
    + # Drop database connection at remote end
    + my $rdbh = $dbh->{'proxy_dbh'};
    + local $SIG{__DIE__} = 'DEFAULT';
    + eval { $rdbh->disconnect() };
    + return DBD::Proxy::proxy_set_err($dbh, $@) if $@;
    +
    + # Close TCP connect to remote
    + $dbh->{proxy_client}->Disconnect();
    +
    $dbh->SUPER::STORE('Active' => 0);
    1;
    }
    @@ -339,6 +343,8 @@
    $sth->{'proxy_sth'} = $rsth;
    # If statement is a positioned update we do not want any readahead.
    $sth->{'RowCacheSize'} = 1 if $stmt =~ /\bfor\s+update\b/i;
    + # Since resources are used by prepared remote handle, mark us active.
    + $sth->SUPER::STORE('Active' => 1);
    }
    $sth;
    }
    Index: lib/DBI/ProxyServer.pm
    ===================================================================
    RCS file: /afs/btv.ibm.com/data/a29v/devel/cvs_repository/ACT/hirschs/perl_modules/DBI/lib/DBI/ProxyServer.pm,v
    retrieving revision 1.1.1.2
    retrieving revision 1.10
    diff -u -r1.1.1.2 -r1.10
    --- lib/DBI/ProxyServer.pm 2003/05/05 14:10:34 1.1.1.2
    +++ lib/DBI/ProxyServer.pm 2003/05/08 18:18:19 1.10
    @@ -90,7 +90,8 @@
    'func' => 1,
    'quote' => 1,
    'type_info_all' => 1,
    - 'table_info' => 1
    + 'table_info' => 1,
    + 'disconnect' => 1
    },
    'DBI::ProxyServer::st' => {
    'execute' => 1,


    Index: lib/RPC/PlClient.pm
    ===================================================================
    RCS file: /afs/btv.ibm.com/data/a29v/devel/cvs_repository/ACT/hirschs/perl_modules/PlRPC/lib/RPC/PlClient.pm,v
    retrieving revision 1.1.1.1
    retrieving revision 1.3
    diff -u -r1.1.1.1 -r1.3
    --- lib/RPC/PlClient.pm 2003/05/05 18:12:39 1.1.1.1
    +++ lib/RPC/PlClient.pm 2003/05/05 18:19:02 1.3
    @@ -30,7 +30,7 @@

    package RPC::PlClient;

    -$RPC::PlClient::VERSION = '0.2016';
    +$RPC::PlClient::VERSION = '0.2017';
    @RPC::PlClient::ISA = qw(Net::Daemon::Log);


    @@ -52,6 +52,8 @@
    my $self = {@_};
    bless($self, (ref($proto) || $proto));

    + $self->RPC::PlServer::Comm::Init();
    +
    my $app = $self->{'application'} or
    $self->Fatal("Missing application name");
    my $version = $self->{'version'} or
    @@ -86,7 +88,6 @@
    die "Refused by server: $msg" unless $reply->[0];
    $self->Debug("Logged in, server replies: $msg");

    - $self->RPC::PlServer::Comm::Init();
    return ($self, $msg) if wantarray;
    $self;
    }
    @@ -125,6 +126,11 @@
    RPC::PlClient::Object->new($1, $client, $object);
    }

    +sub Disconnect {
    + my $self = shift;
    + $self->{'socket'} = undef;
    + 1;
    +}

    package RPC::PlClient::Object;




    --
    ----------------------------------------------------------------
    Steven N. Hirsch tie-line: 446-6557 ext: 802-769-6557

    Staff Engineer Methodology Integration Team
    ASIC Product Development IBM Microelectronics
    ----------------------------------------------------------------
  • Jochen Wiedmann at Jun 9, 2003 at 9:33 am

    Quoting Tim Bunce <Tim.Bunce@pobox.com>:

    I've CC'd Jochen as he needs to apply the PlRPC patches and make a
    new release before I can depend on them being available.
    Done. Besides, Tim, I have no problems if you apply any changes.
    As we all know, it is very unlikely that I'll be actively developing
    the module in the future.


    Jochen
  • Tim Bunce at Jun 9, 2003 at 10:24 am

    On Mon, Jun 09, 2003 at 11:32:56AM +0200, Jochen Wiedmann wrote:
    Quoting Tim Bunce <Tim.Bunce@pobox.com>:
    I've CC'd Jochen as he needs to apply the PlRPC patches and make a
    new release before I can depend on them being available.
    Done.
    Thanks. Have you (will you) make a new release?
    Besides, Tim, I have no problems if you apply any changes.
    As we all know, it is very unlikely that I'll be actively developing
    the module in the future.
    Maybe we could find a new maintainer... Any volunteers on dbi-dev?

    Tim.
  • Jochen Wiedmann at Jun 9, 2003 at 2:39 pm

    Quoting Tim Bunce <Tim.Bunce@pobox.com>:

    Thanks. Have you (will you) make a new release?
    Sorry for not being precise. Of course this is what I already have done.


    Jochen

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdbi-dev @
categoriesperl
postedMay 9, '03 at 3:08p
activeJun 9, '03 at 2:39p
posts7
users4
websitedbi.perl.org

People

Translate

site design / logo © 2019 Grokbase