~mm-yuhu/gearmand/server-funcs

« back to all changes in this revision

Viewing changes to libgearman-server/server.c

  • Committer: Marian Marinov
  • Date: 2010-03-11 12:19:42 UTC
  • Revision ID: mm@yuhu.biz-20100311121942-tnp7hz04d972wtck
Added rmfunc server command

Show diffs side-by-side

added added

removed removed

Lines of Context:
849
849
    if (size < total)
850
850
      snprintf(data + size, total - size, ".\n");
851
851
  }
 
852
  else if (!strcasecmp("rmfunc", (char *)(packet->arg[0])))
 
853
  {
 
854
    if (packet->argc == 1)
 
855
    {
 
856
      snprintf(data, GEARMAN_TEXT_RESPONSE_SIZE, "ERR incomplete_args "
 
857
        "An+incomplete+set+of+arguments+was+sent+to+this+command\n");
 
858
    }
 
859
    else
 
860
    {
 
861
      for (function= server_con->thread->server->function_list;
 
862
           function != NULL; function= function->next)
 
863
      {
 
864
        if (!strcasecmp(function->function_name, (char *)(packet->arg[1])))
 
865
        {
 
866
                 if ( function->worker_count == 0 )
 
867
          {
 
868
            gearman_server_function_free(function);
 
869
            snprintf(data, GEARMAN_TEXT_RESPONSE_SIZE, "OK\n");
 
870
          }
 
871
          else
 
872
          {
 
873
            snprintf(data, GEARMAN_TEXT_RESPONSE_SIZE, "ERR there are still connected workers\n");
 
874
          }
 
875
        }
 
876
      }
 
877
    }
 
878
  }
 
879
 
852
880
  else if (!strcasecmp("maxqueue", (char *)(packet->arg[0])))
853
881
  {
854
882
    if (packet->argc == 1)