~mm-yuhu/gearmand/server-funcs

« back to all changes in this revision

Viewing changes to libgearman-server/job.c

  • Committer: Brian Aker
  • Date: 2010-02-11 00:09:22 UTC
  • mfrom: (319.1.2 gearmand-newtrunk)
  • Revision ID: brian@gaz-20100211000922-o1f10hm9zf57leeg
Merging

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
static uint32_t _server_job_hash(const char *key, size_t key_size);
30
30
 
31
31
/**
 
32
 * Appends a worker onto the end of a list of workers.
 
33
 */
 
34
static inline void _server_con_worker_list_append(gearman_server_worker_st *list,
 
35
                                                  gearman_server_worker_st *worker);
 
36
 
 
37
/**
32
38
 * Get a server job structure from the unique ID. If data_size is non-zero,
33
39
 * then unique points to the workload data and not a real unique key.
34
40
 */
333
339
  return NULL;
334
340
}
335
341
 
 
342
static inline void _server_con_worker_list_append(gearman_server_worker_st *list,
 
343
                                                  gearman_server_worker_st *worker)
 
344
{
 
345
  worker->con_prev= NULL;
 
346
  worker->con_next= list;
 
347
  while (worker->con_next != NULL)
 
348
  {
 
349
    worker->con_prev= worker->con_next;
 
350
    worker->con_next= worker->con_next->con_next;
 
351
  }
 
352
  if (worker->con_prev)
 
353
    worker->con_prev->con_next= worker;
 
354
}
 
355
 
336
356
gearman_server_job_st *
337
357
gearman_server_job_take(gearman_server_con_st *server_con)
338
358
{
350
370
  if (server_worker == NULL)
351
371
    return NULL;
352
372
 
 
373
  if (server_con->thread->server->options & GEARMAN_SERVER_RR_ORDER)
 
374
  {
 
375
    GEARMAN_LIST_DEL(server_con->worker, server_worker, con_)
 
376
    _server_con_worker_list_append(server_con->worker_list, server_worker);
 
377
    ++server_con->worker_count;
 
378
    if (server_con->worker_list == NULL) {
 
379
      server_con->worker_list= server_worker;
 
380
    }
 
381
  }
 
382
 
353
383
  for (priority= GEARMAN_JOB_PRIORITY_HIGH;
354
384
       priority != GEARMAN_JOB_PRIORITY_MAX; priority++)
355
385
  {