Code

patches: Added postgresql_writer_memleak.dpatch.
authorSebastian Harl <sh@teamix.net>
Thu, 29 Nov 2012 08:09:22 +0000 (09:09 +0100)
committerSebastian Harl <sh@teamix.net>
Thu, 29 Nov 2012 08:09:22 +0000 (09:09 +0100)
… fixing a memory leak in the PostgreSQL writer implementation.

debian/changelog
debian/patches/00list
debian/patches/myplugin_includes.dpatch [changed mode: 0644->0755]
debian/patches/postgresql_writer_memleak.dpatch [new file with mode: 0755]

index f7d674b6671fd1482b963ebcb31b2334707d61e8..69e3433c12a3bc0c20f7a8f7194aeee972fb201f 100644 (file)
@@ -1,3 +1,11 @@
+collectd (5.2.0-2) UNRELEASED; urgency=low
+
+  * debian/patches:
+    - Added postgresql_writer_memleak.dpatch fixing a memory leak in the
+      PostgreSQL writer implementation.
+
+ -- Sebastian Harl <tokkee@debian.org>  Thu, 29 Nov 2012 09:08:21 +0100
+
 collectd (5.2.0-1) experimental; urgency=low
 
   * New upstream release:
index 23aacf62e043c084fffcce668440b01881337668..c3bdb36ac03223c8f9055d27ec36f8bafcc14ad9 100644 (file)
@@ -2,3 +2,4 @@ rrd_filter_path.dpatch
 collection_conf_path.dpatch
 myplugin_includes.dpatch
 bts559801_plugin_find_fix.dpatch
+postgresql_writer_memleak.dpatch
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/debian/patches/postgresql_writer_memleak.dpatch b/debian/patches/postgresql_writer_memleak.dpatch
new file mode 100755 (executable)
index 0000000..78bfd76
--- /dev/null
@@ -0,0 +1,40 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## postgresql_writer_memleak.dpatch by Sebastian Harl <sh@tokkee.org>
+##
+## DP: postgresql plugin: Fixed a memory leak occurring on every write.
+
+@DPATCH@
+
+diff a/src/postgresql.c b/src/postgresql.c
+--- a/src/postgresql.c
++++ b/src/postgresql.c
+@@ -900,10 +900,10 @@ static int c_psql_write (const data_set_t *ds, const value_list_t *vl,
+               if ((PGRES_COMMAND_OK != PQresultStatus (res))
+                               && (PGRES_TUPLES_OK != PQresultStatus (res))) {
++                      PQclear (res);
++
+                       if ((CONNECTION_OK != PQstatus (db->conn))
+                                       && (0 == c_psql_check_connection (db))) {
+-                              PQclear (res);
+-
+                               /* try again */
+                               res = PQexecParams (db->conn, writer->statement,
+                                               STATIC_ARRAY_SIZE (params), NULL,
+@@ -912,6 +912,7 @@ static int c_psql_write (const data_set_t *ds, const value_list_t *vl,
+                               if ((PGRES_COMMAND_OK == PQresultStatus (res))
+                                               || (PGRES_TUPLES_OK == PQresultStatus (res))) {
++                                      PQclear (res);
+                                       success = 1;
+                                       continue;
+                               }
+@@ -932,6 +933,8 @@ static int c_psql_write (const data_set_t *ds, const value_list_t *vl,
+                       pthread_mutex_unlock (&db->db_lock);
+                       return -1;
+               }
++
++              PQclear (res);
+               success = 1;
+       }