~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/gearman_udf/function_map.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-07-30 02:39:13 UTC
  • mto: (1115.3.11 captain)
  • mto: This revision was merged to the branch mainline in revision 1121.
  • Revision ID: osullivan.padraig@gmail.com-20090730023913-o2zuocp32l6btnc2
Removing references to MY_BITMAP throughout the code base and updating calls
to MyBitmap in various places to use the new interface.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
bool GearmanFunctionMap::add(string function, string servers)
46
46
{
47
47
  map<string, gearman_client_st>::iterator x;
48
 
  gearman_return_t ret;
 
48
  string host;
 
49
  string port;
 
50
  size_t begin_pos= 0;
 
51
  size_t end_pos;
 
52
  size_t port_pos;
49
53
 
50
54
  pthread_mutex_lock(&lock);
51
55
 
59
63
    }
60
64
  }
61
65
 
62
 
  gearman_client_remove_servers(&(functionMap[function]));
63
 
  ret= gearman_client_add_servers(&(functionMap[function]), servers.c_str());
 
66
  /* Parse server strings in the format "host[:port][,host[:port]]..." */
 
67
  while (1)
 
68
  {
 
69
    end_pos= servers.find(',', begin_pos);
 
70
    if (end_pos == string::npos)
 
71
      host= servers.substr(begin_pos);
 
72
    else
 
73
      host= servers.substr(begin_pos, end_pos - begin_pos);
 
74
 
 
75
    port_pos= host.find(':');
 
76
    if (port_pos == string::npos)
 
77
      port.clear();
 
78
    else
 
79
    {
 
80
      port= host.substr(port_pos + 1);
 
81
      host[port_pos]= 0;
 
82
    }
 
83
 
 
84
    /* For each host:port pair, add a server to the cloning object. */
 
85
    if (gearman_client_add_server(&(functionMap[function]), host.c_str(),
 
86
                                  port.size() == 0 ?
 
87
                                  0 : atoi(port.c_str())) != GEARMAN_SUCCESS)
 
88
    {
 
89
      pthread_mutex_unlock(&lock);
 
90
      return false;
 
91
    }
 
92
 
 
93
    if (end_pos == string::npos)
 
94
      break;
 
95
 
 
96
    begin_pos= end_pos + 1;
 
97
  }
 
98
 
64
99
  pthread_mutex_unlock(&lock);
65
 
  if (ret != GEARMAN_SUCCESS)
66
 
    return false;
67
 
 
68
100
  return true;
69
101
}
70
102