diff options
author | Yorhel <git@yorhel.nl> | 2009-07-17 17:57:42 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2009-07-17 17:57:42 +0200 |
commit | 43bb085304ae5646d4037d9b5778601e6b00dc19 (patch) | |
tree | f9efafc1bd03660147dc5b672a5f9dd19bbcf075 | |
parent | 06d56c048d30ae13b3048ea342e7f06be668d03b (diff) |
Check for notifications -before- query results
It took me an entire day just to find out why the heck PoCo::Pg wouldn't
always receive a dbi_canread event when the query result is available.
Found out it was because pg_notifies does, apparently, read something
from the socket. (But apparently not in a blocking way... so it was hard
to detect...)
-rw-r--r-- | lib/POE/Component/Pg.pm | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/POE/Component/Pg.pm b/lib/POE/Component/Pg.pm index e61935b..8217eeb 100644 --- a/lib/POE/Component/Pg.pm +++ b/lib/POE/Component/Pg.pm @@ -247,8 +247,14 @@ sub process_queue { sub dbi_canread { + # check for any notifications + while(my $not = $_[HEAP]{dbi}->pg_notifies) { + $_[KERNEL]->post($_->[0], $_->[2], @$not) + for (grep $_->[1] eq $not->[0], @{$_[HEAP]{listen}}); + } + # check for query results - if($_[HEAP]{state} == 2 && $_[HEAP]{dbi}->pg_ready) { + if($_[HEAP]{state} == 2 && $_[HEAP]{dbi}->pg_ready()) { my $item = shift @{$_[HEAP]{queue}}; # fetch results @@ -270,12 +276,6 @@ sub dbi_canread { # execute next query in the queue, if any $_[KERNEL]->call($_[SESSION], 'process_queue'); } - - # check for any notifications - while(my $not = $_[HEAP]{dbi}->pg_notifies) { - $_[KERNEL]->post($_->[0], $_->[2], @$not) - for (grep $_->[1] eq $not->[0], @{$_[HEAP]{listen}}); - } } |