write_graphite plugin: Don't call close() on invalid file descriptors.
authorFlorian Forster <octo@collectd.org>
Sat, 13 Jul 2013 05:46:20 +0000 (07:46 +0200)
committerFlorian Forster <octo@collectd.org>
Sat, 13 Jul 2013 05:46:20 +0000 (07:46 +0200)
src/write_graphite.c

index aa87896..bde5fb6 100644 (file)
@@ -247,8 +247,11 @@ static void wg_callback_free (void *data)
 
     wg_flush_nolock (/* timeout = */ 0, cb);
 
-    close(cb->sock_fd);
-    cb->sock_fd = -1;
+    if (cb->sock_fd >= 0)
+    {
+        close (cb->sock_fd);
+        cb->sock_fd = -1;
+    }
 
     sfree(cb->node);
     sfree(cb->service);