tag 475197 patch
# the lenny version has the bug too
found 475197 0.94-2
thanks

On Wed, Apr 09, 2008 at 08:00:54PM +0200, Lucas Nussbaum wrote:
> Package: libgearman-client-async-perl
> Version: 0.94-2.1
> Severity: serious
> User: [EMAIL PROTECTED]
> Usertags: qa-ftbfs-20080409 qa-ftbfs
> Justification: FTBFS on i386

> > t/err8............Can't call method "watch_read" on an undefined value at 
> > t/err8.t line 57.
> > # Looks like your test died before it could output anything.

This is a race condition in the test.

The test starts up a job scheduler process (listening at port 9000)
and a worker backend process that connects to the job scheduler.

It then connects to the scheduler itself with $client->add_task($task)
and sets up event loop callbacks to ignore the replies from the scheduler
until the worker timeouts. Finally, it starts the event loop.

The problem is that the add_task() method sets up a timer in
Gearman::Client::Async::Connection->connect() that expects that something
gets written to the job server in .25 seconds after connecting. On a
loaded host it's possible that the event loop isn't started before that,
and the client never has the time to write anything.

This can be verified by inserting something like 'Time::HiRes::sleep(.3)'
right after the add_task() invocation in t/err8.t.

I think this will always be racy, but the attached patch should cut the
window to a minimum by running the event loop once after connecting.

While this works for me, I'm not quite sure if it may happen too soon
on some hosts where the job scheduler responds slowly. At least it 
shouldn't make matters worse.  Disabling the test altogether is a valid 
option too, of course.
-- 
Niko Tyni   [EMAIL PROTECTED]
diff --git a/t/err8.t b/t/err8.t
index 08b38d0..4deaf67 100644
--- a/t/err8.t
+++ b/t/err8.t
@@ -44,6 +44,14 @@ my $taskptr;
         },
     });
     $client->add_task($task);
+
+    # call the event loop just once so that connect timeout code
+    # in Gearman::Client::Async::Connection->connect() isn't
+    # triggered before the main event loop
+    # see http://bugs.debian.org/475197
+    Danga::Socket->SetPostLoopCallback(sub {return 0});
+    Danga::Socket->EventLoop();
+
     $taskptr = $task;
     weaken($taskptr);
 }

Reply via email to