Browse files

Re-prime data avail condvar before waiting

If @data_queue has data before the collector is first called, then
->recv would not be called and the condvar not recreated. This meant
on the next call @data_queue was empty but the condvar was ready
resulting in undef being returned.

So we re-prime the condvar before we wait so that the condvar will
only be ready when the next chunk is placed into @data_queue
  • Loading branch information...
1 parent fd38fb2 commit f942421a11f42fbfc94bc0010e7e1f3cd9c24cdd @gbarr committed Feb 22, 2012
Showing with 4 additions and 3 deletions.
  1. +1 −0 Changes.txt
  2. +3 −3 lib/LWP/Protocol/AnyEvent/
@@ -5,6 +5,7 @@ Revision history for LWP-Protocol-AnyEvent-http
- Fix duplicate headers in response
- Add proxy support
- Prevent AnyEvent::HTTP adding Referer header with the request URL
+ - Fix bug causing cannot use undefined value as SCALAR reference
1.0.3 2011-06-17
- Skip tests that will fail due to DNS hijacking.
@@ -115,11 +115,11 @@ sub request {
return $self->collect($arg, $response, sub {
if (!@data_queue) {
- # Wait for more data to arrive
- $data_avail->recv();
# Re-prime our channel, in case there is more.
$data_avail = AnyEvent->condvar();
+ # Wait for more data to arrive
+ $data_avail->recv();
return shift(@data_queue);

0 comments on commit f942421

Please sign in to comment.