Hi,
I was trying to figure out why some ruby code wasn't working properly
and I was reading though the source code of gearmand, when I noticed
this in
libgearman-server/server.c
/* Worker requests. */
case GEARMAN_COMMAND_CAN_DO:
if (gearman_server_worker_add(server_con, (char *)(packet->arg
[0]),
packet->arg_size[0], 0) == NULL)
Following the code to
libgearman-server/worker.c
gearman_server_worker_st *
gearman_server_worker_add(gearman_server_con_st *con, const char
*function_name,
size_t function_name_size, uint32_t timeout)
{
gearman_server_worker_st *worker;
gearman_server_function_st *function;
function= gearman_server_function_get(con->thread->server,
function_name, function_name_size);
if (function == NULL)
return NULL;
worker= gearman_server_worker_create(con, function, NULL);
## D. If the above gearman_server_function_get works, but the
## gearman_server_worker_create fails, the code returns NULL
immediately.
## But no one release the memory for the local variable function,
which was malloc'd in
## File: libgearman-server\function.c ~ line 41
## function->function_name= malloc(function_name_size + 1);
if (worker == NULL)
return NULL;
-daniel
-Eric