From 0239d8d5379de3ea5b0fd995c4773ec5a302efd6 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 29 Feb 2012 23:11:26 +0100 Subject: [PATCH] write_mongodb plugin: Actually implement the "Timeout" option. Change-Id: I8eb1bc53a15cd301d663e55a5ea71e46013f04c5 --- src/write_mongodb.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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); -- 2.30.2