From 3aca4f551791a99503398fdfeceaf74bd56ba80e Mon Sep 17 00:00:00 2001 From: Yorhel Date: Fri, 17 Jul 2009 18:07:25 +0200 Subject: Don't process queries if we're not connected Queries will now be queued untill we are connected. This may be what you want in some cases, but may not in other cases... At least it's the easiest way of handling DB requests without being connected. --- lib/POE/Component/Pg.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/POE/Component/Pg.pm') diff --git a/lib/POE/Component/Pg.pm b/lib/POE/Component/Pg.pm index 8217eeb..174ab60 100644 --- a/lib/POE/Component/Pg.pm +++ b/lib/POE/Component/Pg.pm @@ -207,8 +207,8 @@ sub addqueue { push @{$_[HEAP]{queue}}, $_[ARG0]; $_[KERNEL]->refcount_increment($_[ARG0][QSESID], 'P:C:PG'); - # if there's no query in progress, initiate query - if($_[HEAP]{state} == 0) { + # if there's no query in progress and we're connected, initiate query + if($_[HEAP]{state} == 0 && $_[HEAP]{dbi}) { $_[HEAP]{state} = 1; $_[KERNEL]->select_resume_write($_[HEAP]{fh}); } @@ -236,7 +236,7 @@ sub shutdown { sub process_queue { - if(@{$_[HEAP]{queue}}) { + if(@{$_[HEAP]{queue}} && $_[HEAP]{dbi}) { $_[HEAP]{state} = 1; $_[KERNEL]->select_resume_write($_[HEAP]{fh}); } else { -- cgit v1.2.3