Merge pull request #1376 from rubenk/amqp-fix-buffer-size
authorRuben Kerkhof <ruben@tilaa.nl>
Sat, 28 Nov 2015 20:43:17 +0000 (21:43 +0100)
committerRuben Kerkhof <ruben@tilaa.nl>
Sat, 28 Nov 2015 20:43:17 +0000 (21:43 +0100)
amqp: use the right buffer size for sstrncpy

src/mqtt.c
src/powerdns.c
src/write_redis.c

index 7003fcc..c7581e9 100644 (file)
@@ -221,6 +221,7 @@ static void on_message (
     if (payload == NULL)
     {
         ERROR ("mqtt plugin: malloc for payload buffer failed.");
+        sfree (vl.values);
         return;
     }
     memmove (payload, msg->payload, msg->payloadlen);
index 1050e7f..0400f3d 100644 (file)
@@ -145,7 +145,7 @@ user-msec             number of CPU milliseconds spent in 'user' mode
 
 const char* const default_server_fields[] = /* {{{ */
 {
-  "latency"
+  "latency",
   "packetcache-hit",
   "packetcache-miss",
   "packetcache-size",
index 1eb082f..4bfcc73 100644 (file)
@@ -83,10 +83,11 @@ static int wr_write (const data_set_t *ds, /* {{{ */
   value_size = sizeof (value);
   value_ptr = &value[0];
   status = format_values (value_ptr, value_size, ds, vl, node->store_rates);
-  pthread_mutex_lock (&node->lock);
   if (status != 0)
     return (status);
 
+  pthread_mutex_lock (&node->lock);
+
   if (node->conn == NULL)
   {
     node->conn = redisConnectWithTimeout ((char *)node->host, node->port, node->timeout);