[hipl-commit] [tiny] Rev 3665: Fixed bug in heartbeat module.

  • From: Tim Just <tim.just@xxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Fri, 12 Mar 2010 17:51:39 +0200

Committer: Tim Just <tim.just@xxxxxxxxxxxxxx>
Date: Fri Mar 12 16:45:15 2010 +0100
Revision: 3665
Revision-id: tim.just@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: tiny

Log:
  Fixed bug in heartbeat module.
  
  The file descriptor for the icmp socket was registered before the socket
  was created. Because the icmp file descriptor variable was initialized with 
  0, stdin was registered instead. This caused a very strange behaviour at a 
  push of a key.
  
  Now the heartbeat module is functioning.

Modified:
  M  modules/heartbeat/hipd/heartbeat.c

=== modified file 'modules/heartbeat/hipd/heartbeat.c'
--- modules/heartbeat/hipd/heartbeat.c  2010-03-11 16:12:41 +0000
+++ modules/heartbeat/hipd/heartbeat.c  2010-03-12 15:45:15 +0000
@@ -11,7 +11,7 @@
 
 #define HIP_HEARTBEAT_INTERVAL 20
 
-int hip_icmp_sock     = 0;
+int hip_icmp_sock;
 int heartbeat_counter = HIP_HEARTBEAT_INTERVAL;
 
 /**
@@ -308,13 +308,6 @@
     struct icmp6_filter filter;
     int *icmpsockfd = &hip_icmp_sock;
 
-    HIP_IFEL(lmod_register_module("heartbeat"),
-             -1,
-             "Error on registering HEATBEAT module.\n");
-
-    hip_register_maint_function(&hip_heartbeat_maintenance, 10000);
-    hip_register_socket(hip_icmp_sock, &hip_heartbeat_handle_icmp_sock, 30000);
-
     *icmpsockfd       = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
     hip_set_cloexec_flag(*icmpsockfd, 1);
     HIP_IFEL(*icmpsockfd <= 0, 1, "ICMPv6 socket creation failed\n");
@@ -329,6 +322,14 @@
     err = setsockopt(*icmpsockfd, IPPROTO_IPV6, IPV6_2292PKTINFO, &on, 
sizeof(on));
     HIP_IFEL(err, -1, "setsockopt icmp IPV6_RECVPKTINFO failed\n");
 
+    HIP_IFEL(lmod_register_module("heartbeat"),
+             -1,
+             "Error on registering HEATBEAT module.\n");
+
+    hip_register_socket(hip_icmp_sock, &hip_heartbeat_handle_icmp_sock, 30000);
+
+    hip_register_maint_function(&hip_heartbeat_maintenance, 10000);
+
 out_err:
     return err;
 }

Other related posts:

  • » [hipl-commit] [tiny] Rev 3665: Fixed bug in heartbeat module. - Tim Just