callbacks do not seem to be returning GEARMAN_SUCCESS by default

Bug #379584 reported by James M. Luedke
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Gearman::XS
Invalid
Medium
Dennis Schön

Bug Description

#!/usr/bin/perl -w

$|++;

use strict;
use Gearman::XS::Client;
use Gearman::XS qw(:constants);

my $client = new Gearman::XS::Client;

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->set_complete_fn(\&complete);

for my $n (1..5) {
    my ($rv, $task) = $client->add_task('reverse', "$n ha");

    if ($rv != GEARMAN_SUCCESS) {
        die $client->error(),"\n";
    }

    print "server: task added with data: $n ha\n";
}

my $ret = $client->add_server("127.0.0.1", 0);
$client->run_tasks();

exit;

Changed in gearmanxs:
assignee: nobody → Dennis Schön (roccoblues)
importance: Undecided → Medium
milestone: none → 0.2
Changed in gearmanxs:
status: New → Confirmed
Revision history for this message
Dennis Schön (roccoblues) wrote :

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.

Changed in gearmanxs:
status: Confirmed → Invalid
milestone: 0.2 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.