From: Florian Forster Date: Wed, 29 Feb 2012 22:11:26 +0000 (+0100) Subject: write_mongodb plugin: Actually implement the "Timeout" option. X-Git-Tag: collectd-5.1.0~14 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=0239d8d5379de3ea5b0fd995c4773ec5a302efd6;p=collectd.git write_mongodb plugin: Actually implement the "Timeout" option. Change-Id: I8eb1bc53a15cd301d663e55a5ea71e46013f04c5 --- diff --git a/src/write_mongodb.c b/src/write_mongodb.c index 3b17f8c8..f61d6224 100644 --- a/src/write_mongodb.c +++ b/src/write_mongodb.c @@ -125,9 +125,17 @@ static int wm_write (const data_set_t *ds, /* {{{ */ mongo_destroy(node->conn); pthread_mutex_unlock (&node->lock); return (-1); - } else { - node->connected = 1; } + + if (node->timeout > 0) { + status = mongo_set_op_timeout (node->conn, node->timeout); + if (status != MONGO_OK) { + WARNING ("write_mongodb plugin: mongo_set_op_timeout(%i) failed: %s", + node->timeout, node->conn->errstr); + } + } + + node->connected = 1; } /* Assert if the connection has been established */ @@ -182,9 +190,6 @@ static int wm_config_node (oconfig_item_t *ci) /* {{{ */ return (ENOMEM); memset (node, 0, sizeof (*node)); node->host = NULL; - node->port = 0; - node->timeout = 1000; - node->connected = 0; node->store_rates = 1; pthread_mutex_init (&node->lock, /* attr = */ NULL);