CAN_DO_TIMEOUT not properly handled

Bug #1007362 reported by Jan Gnezda on 2012-06-01
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Gearman
Medium
Brian Aker

Bug Description

Hello

I am using latest gearman release (0.33). When a worker registers a function with CAN_DO_TIMEOUT message, gearman server ignores the second argument (file server.c, around line 390) . I believe this might be actually a small typo, because otherwise server handles worker timeouts (worker.cc and connection.c). The fix is very trivial, simply read the second argument of CAN_DO_TIMEOUT message and feed it to gearman_server_worker_add() function.
Change from this (lines 388-396 in server.c):
====
case GEARMAN_COMMAND_CAN_DO_TIMEOUT:
    if (gearman_server_worker_add(server_con, (char *)(packet->arg[0]),
                                  packet->arg_size[0] - 1,
                                  0) == NULL)
    {
      return GEARMAN_MEMORY_ALLOCATION_FAILURE;
    }

    break;
====

To this:
====
case GEARMAN_COMMAND_CAN_DO_TIMEOUT:
  {
    uint32_t timeout = 0;
    sscanf((char *)packet->arg[1], "%d", (int *)&timeout);

    if (gearman_server_worker_add(server_con, (char *)(packet->arg[0]),
                                  packet->arg_size[0] - 1,
                                  timeout) == NULL)
    {
      return GEARMAN_MEMORY_ALLOCATION_FAILURE;
    }

    break;
  }
====

I apologize to have posted like this (instead of proper diff), but I haven't yet set-up the project repository.

Minor nitpick: it would be nice if gearman protocol docs would specify that all packet arguments are actually strings and that all timestamp/timeout/epoch arguments are in seconds.

Jan Gnezda (zebrca) on 2012-06-01
description: updated
Jan Gnezda (zebrca) on 2012-06-01
description: updated
Brian Aker (brianaker) on 2012-06-01
Changed in gearmand:
importance: Undecided → Medium
assignee: nobody → Brian Aker (brianaker)
status: New → In Progress
Brian Aker (brianaker) on 2012-06-04
Changed in gearmand:
milestone: none → 0.34
Brian Aker (brianaker) on 2012-06-30
Changed in gearmand:
status: In Progress → Fix Committed
Brian Aker (brianaker) on 2012-07-12
Changed in gearmand:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers