updates.
authorPekka Riikonen <priikone@silcnet.org>
Tue, 3 Apr 2001 16:40:57 +0000 (16:40 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Tue, 3 Apr 2001 16:40:57 +0000 (16:40 +0000)
lib/silccore/idcache.c
lib/silccore/silcsockconn.c

index 5d8d793c145afe72d416880ac9cdf12694cdd217..c7c618571d46afdd99a216d1a78fdbc3e20a148a 100644 (file)
@@ -204,8 +204,10 @@ int silc_idcache_find_by_data(SilcIDCache cache, unsigned char *data,
       silc_idcache_list_add(list, &(cache->cache[i]));
   }
 
-  if (!silc_idcache_list_count(list))
+  if (!silc_idcache_list_count(list)) {
+    silc_idcache_list_free(list);
     return FALSE;
+  }
 
   if (ret)
     *ret = list;
@@ -295,8 +297,10 @@ int silc_idcache_find_by_data_loose(SilcIDCache cache, unsigned char *data,
     }
   }
     
-  if (!silc_idcache_list_count(list))
+  if (!silc_idcache_list_count(list)) {
+    silc_idcache_list_free(list);
     return FALSE;
+  }
 
   if (ret)
     *ret = list;
@@ -332,8 +336,10 @@ int silc_idcache_find_by_id(SilcIDCache cache, void *id, SilcIdType type,
        silc_idcache_list_add(list, &(cache->cache[i]));
   }
 
-  if (!silc_idcache_list_count(list))
+  if (!silc_idcache_list_count(list)) {
+    silc_idcache_list_free(list);
     return FALSE;
+  }
 
   if (ret)
     *ret = list;
index 3b5af11863b2af47aedecd6286bb3352a63c2469..4de42da006d20dc997f8a3577633b97d4bcc8f4a 100644 (file)
@@ -106,16 +106,22 @@ void silc_socket_set_heartbeat(SilcSocketConnection sock,
                               SilcSocketConnectionHBCb hb_callback,
                               void *timeout_queue)
 {
-  SilcSocketConnectionHB hb = silc_calloc(1, sizeof(*hb));
-
-  hb->heartbeat = heartbeat;
-  hb->hb_context = hb_context;
-  hb->hb_callback = hb_callback;
-  hb->timeout_queue = timeout_queue;
-  hb->sock = sock;
-  hb->hb_task = silc_task_register(timeout_queue, sock->sock, 
-                                  silc_socket_heartbeat,
-                                  (void *)hb, heartbeat, 0,
-                                  SILC_TASK_TIMEOUT,
-                                  SILC_TASK_PRI_LOW);
+
+  if (sock->hb) {
+    silc_task_unregister(sock->hb->timeout_queue, sock->hb->hb_task);
+    silc_free(sock->hb->hb_context);
+    silc_free(sock->hb);
+  }
+
+  sock->hb = silc_calloc(1, sizeof(*sock->hb));
+  sock->hb->heartbeat = heartbeat;
+  sock->hb->hb_context = hb_context;
+  sock->hb->hb_callback = hb_callback;
+  sock->hb->timeout_queue = timeout_queue;
+  sock->hb->sock = sock;
+  sock->hb->hb_task = silc_task_register(timeout_queue, sock->sock,
+                                         silc_socket_heartbeat,
+                                         (void *)sock->hb, heartbeat, 0,
+                                         SILC_TASK_TIMEOUT,
+                                         SILC_TASK_PRI_LOW);
 }