+ }
+
+ if ((node->db != NULL) && (node->user != NULL) && (node->passwd != NULL))
+ {
+ status = mongo_cmd_authenticate (node->conn,
+ node->db, node->user, node->passwd);
+ if (status != MONGO_OK)
+ {
+ ERROR ("write_mongodb plugin: Authenticating to [%s]%i for database "
+ "\"%s\" as user \"%s\" failed.",
+ (node->host != NULL) ? node->host : "localhost",
+ (node->port != 0) ? node->port : MONGO_DEFAULT_PORT,
+ node->db, node->user);
+ mongo_destroy (node->conn);
+ pthread_mutex_unlock (&node->lock);
+ return (-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);
+ }