[PATCH] heartbeat bug fix

Alexander Malysh <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Organization Centrium GmbH
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

here is small patch to get heartbeat work again ...

- -- 
Mit besten Grüßen aus Köln

Dipl.-Ing.
Alexander Malysh
___________________________________

Centrium GmbH
Ehrenstrasse 2
50672 Köln

Fon: +49 (0221) 277 49 150
Fax: +49 (0221) 277 49 109

email: [email protected]
web: http://www.centrium.de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+C3pHnX3e5W+uJ0ERAuktAKDWyw9zxpiYyJ8LS9AVTvXkesVJTwCcC5Wg
5T3VoZr/KpaEph9CeprNw4M=
=gmcd
-----END PGP SIGNATURE-----
heartbeat.diff (text/x-diff, 1.1 KB)
Index: gw/heartbeat.c
===================================================================
RCS file: /home/cvs/gateway/gw/heartbeat.c,v
retrieving revision 1.3
diff -a -u -r1.3 heartbeat.c
--- gw/heartbeat.c	29 May 2002 12:27:21 -0000	1.3
+++ gw/heartbeat.c	26 Dec 2002 22:02:43 -0000
@@ -56,11 +56,12 @@
          * This is not bad unless we send them way too fast.  Make sure
          * our frequency is not more than twice the configured one.
          */
-        if (difftime(last_hb, time(NULL)) < info->freq / 2)
+        if (difftime(time(NULL), last_hb) < info->freq / 2)
             continue;
 
         msg = msg_create(heartbeat);
-        msg->heartbeat.load = info->load_func();
+        if (NULL != info->load_func)
+            msg->heartbeat.load = info->load_func();
         info->send_func(msg);
         last_hb = time(NULL);
     }
@@ -70,6 +71,10 @@
                      hb_load_func_t *load_func)
 {
     struct hb_info *info;
+
+    /* can't start with send_funct NULL */
+    if (send_func == NULL)
+        return -1;
 
     info = gw_malloc(sizeof(*info));
     info->send_func = send_func;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.