From: Florian Forster Date: Sat, 6 Nov 2010 17:39:47 +0000 (+0100) Subject: zeromq plugin: Don't distinguish between "Bind" and "Connect". X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=94e38f7ffde3f6a845533f3b35c15a361adf0a78;p=collectd.git zeromq plugin: Don't distinguish between "Bind" and "Connect". Instead, both, sending and receiving sockets, now use "Endpoint". --- diff --git a/src/zeromq.c b/src/zeromq.c index 5dabc3f9..5958a56e 100644 --- a/src/zeromq.c +++ b/src/zeromq.c @@ -971,7 +971,7 @@ static int cmq_config_socket (oconfig_item_t *ci) /* {{{ */ int type; int status; int i; - int connections_num; + int endpoints_num; void *cmq_socket; type = cmq_config_mode (ci); @@ -1013,74 +1013,59 @@ static int cmq_config_socket (oconfig_item_t *ci) /* {{{ */ } /* Iterate over all children and do all the binds and connects requested. */ - connections_num = 0; + endpoints_num = 0; for (i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; - if (strcasecmp ("Bind", child->key) == 0) + if (strcasecmp ("Endpoint", child->key) == 0) { char *value = NULL; - if ((type == ZMQ_PUB) || (type == ZMQ_PUSH)) - { - ERROR ("zeromq plugin: The \"Bind\" option is not available for " - "publish and push sockets. Try \"Connect\"."); - continue; - } - status = cf_util_get_string (child, &value); if (status != 0) continue; + sfree (value); - status = zmq_bind (cmq_socket, value); - if (status != 0) + if ((type == ZMQ_SUB) || (type == ZMQ_PULL)) { - ERROR ("zeromq plugin: zmq_bind (\"%s\") failed: %s", - value, zmq_strerror (errno)); - continue; + status = zmq_bind (cmq_socket, value); + if (status != 0) + { + ERROR ("zeromq plugin: zmq_bind (\"%s\") failed: %s", + value, zmq_strerror (errno)); + continue; + } } - - connections_num++; - continue; - } /* Bind */ - - if (strcasecmp ("Connect", child->key) == 0) - { - char *value = NULL; - - if ((type == ZMQ_SUB) || (type == ZMQ_PULL)) + else if ((type == ZMQ_PUB) || (type == ZMQ_PUSH)) { - ERROR ("zeromq plugin: The \"Connect\" option is not available for " - "subscribe and pull sockets. Try \"Bind\"."); - continue; + status = zmq_connect (cmq_socket, value); + if (status != 0) + { + ERROR ("zeromq plugin: zmq_connect (\"%s\") failed: %s", + value, zmq_strerror (errno)); + continue; + } } - - status = cf_util_get_string (child, &value); - if (status != 0) - continue; - - status = zmq_connect (cmq_socket, value); - if (status != 0) + else { - ERROR ("zeromq plugin: zmq_connect (\"%s\") failed: %s", - value, zmq_strerror (errno)); - continue; + assert (23 == 42); } - connections_num++; + endpoints_num++; continue; - } /* Connect */ - - ERROR ("zeromq plugin: The \"%s\" config option is now allowed here.", - child->key); + } /* Endpoint */ + else + { + ERROR ("zeromq plugin: The \"%s\" config option is now allowed here.", + child->key); + } } /* for (i = 0; i < ci->children_num; i++) */ - if (connections_num == 0) + if (endpoints_num == 0) { - ERROR ("zeromq plugin: No (valid) \"%s\" options were found in this " - "\"Socket\" block.", - ((type == ZMQ_SUB) || (type == ZMQ_PULL)) ? "Bind" : "Connect"); + ERROR ("zeromq plugin: No (valid) \"Endpoint\" option was found in this " + "\"Socket\" block."); (void) zmq_close (cmq_socket); return (-1); } @@ -1139,11 +1124,11 @@ static int cmq_config_socket (oconfig_item_t *ci) /* {{{ */ * * * - * Connect "tcp://localhost:6666" + * Endpoint "tcp://localhost:6666" * * - * Bind "tcp://eth0:6666" - * Bind "tcp://collectd.example.com:6666" + * Endpoint "tcp://eth0:6666" + * Endpoint "tcp://collectd.example.com:6666" * * */