[pisa-src] r1260 - trunk/libpisa/conmgr.c

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Wed, 21 Oct 2009 16:45:34 +0200

Author: tjansen
Date: Wed Oct 21 16:45:34 2009
New Revision: 1260

Log:
Fixed a memleak in conmgr.

If a connection times out and is readded afterwards, the client calls
pisa_conmgr_connected a second time for the same connection. This leads to
adding the connection a second time to the IPv4 hash without removing the old
hash entry. As HASH_ADD internally uses malloc, this memory is lost on the
second call.

Fixed by removing the entry from the IPv4 hash, if it's already in it and
readding the entry afterwards.

Modified:
   trunk/libpisa/conmgr.c

Modified: trunk/libpisa/conmgr.c
==============================================================================
--- trunk/libpisa/conmgr.c      Wed Oct 21 16:15:11 2009        (r1259)
+++ trunk/libpisa/conmgr.c      Wed Oct 21 16:45:34 2009        (r1260)
@@ -85,6 +85,8 @@
        entry->data_port = data_port;
 
        if (client_ipv4 != NULL) {
+               if (entry->hh_ipv4.hashv != 0)
+                       HASH_DELETE(hh_ipv4, conlist->hash_ipv4, entry);
                pisa_ipv4_copy(&entry->ipv4, client_ipv4);
                HASH_ADD(hh_ipv4, conlist->hash_ipv4, ipv4, sizeof(struct 
in_addr), entry);
        } else {

Other related posts:

  • » [pisa-src] r1260 - trunk/libpisa/conmgr.c - Thomas Jansen