callbacks do not seem to be returning GEARMAN_SUCCESS by default
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Gearman::XS |
Invalid
|
Medium
|
Dennis Schön |
Bug Description
#!/usr/bin/perl -w
$|++;
use strict;
use Gearman:
use Gearman::XS qw(:constants);
my $client = new Gearman:
sub complete {
my $task = shift;
my $data = $task->data();
print "server: complete called with data: $data\n";
# if you do not specify GEARMAN_SUCCESS bad things happen
# should return GEARMAN_SUCCESS if a user does not supply one.
# return GEARMAN_SUCCESS;
}
$client-
for my $n (1..5) {
my ($rv, $task) = $client-
if ($rv != GEARMAN_SUCCESS) {
die $client-
}
print "server: task added with data: $n ha\n";
}
my $ret = $client-
$client-
exit;
Changed in gearmanxs: | |
assignee: | nobody → Dennis Schön (roccoblues) |
importance: | Undecided → Medium |
milestone: | none → 0.2 |
Changed in gearmanxs: | |
status: | New → Confirmed |
Perl subroutines can return values in one of two ways, either implicitly, by reaching the end of their block, or explicitly, through the use of the return statement. That means in your example you return the valid value "1" which unfortunatly translates to "GEARMAN_IO_WAIT" and causes the client to abort. I don't see an easy way to fix this. I will however add a note to the documentation that callback functions should always explicitly return a valid gearman_return_t.