[Olsr-dev] [PATCH v1 03/23] dyngw: call olsr_exit() instead of exit()

Ferry Huberts (spam-protected)
Fri Nov 6 16:28:55 CET 2015


From: Ferry Huberts <(spam-protected)>

olsr_exit tries to do proper shutdown that cleans up data structures
by raise()ing the SIGTERM signal. This signal then causes olsr_shutdown
to be invoked (only when the signal handler is setup), which will do
the cleanup of the data structures.

According to the man page of raise():
  If the signal causes a handler to be called, raise() will return
  only after the signal handler has returned.

And since olsr_exit() invokes exit() after raise()ing the signal, there
is no harm in calling it.

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 lib/dyn_gw/src/olsrd_dyn_gw.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/lib/dyn_gw/src/olsrd_dyn_gw.c b/lib/dyn_gw/src/olsrd_dyn_gw.c
index eb6d13b..89d453d 100644
--- a/lib/dyn_gw/src/olsrd_dyn_gw.c
+++ b/lib/dyn_gw/src/olsrd_dyn_gw.c
@@ -581,9 +581,7 @@ add_to_ping_list(const char *ping_address, struct ping_list *the_ping_list)
 {
   struct ping_list *new = calloc(1, sizeof(struct ping_list));
   if (!new) {
-    fprintf(stderr, "DYN GW: Out of memory!\n");
-    olsr_syslog(OLSR_LOG_ERR, "DYN GW: Out of memory!\n");
-    exit(0);
+    olsr_exit("DYN GW: Out of memory", 0);
   }
   new->ping_address = strdup(ping_address);
   new->next = the_ping_list;
@@ -605,9 +603,7 @@ add_to_hna_list(struct hna_list *list_root, union olsr_ip_addr *hna_addr, uint8_
 {
   struct hna_list *new = calloc(1, sizeof(struct hna_list));
   if (new == NULL) {
-    fprintf(stderr, "DYN GW: Out of memory!\n");
-    olsr_syslog(OLSR_LOG_ERR, "DYN GW: Out of memory!\n");
-    exit(0);
+    olsr_exit("DYN GW: Out of memory", 0);
   }
 
   new->hna_addr.v4 = hna_addr->v4;
@@ -630,9 +626,7 @@ add_to_hna_group(struct hna_group *list_root)
 {
   struct hna_group *new = calloc(1, sizeof(struct hna_group));
   if (new == NULL) {
-    fprintf(stderr, "DYN GW: Out of memory!\n");
-    olsr_syslog(OLSR_LOG_ERR, "DYN GW: Out of memory!\n");
-    exit(0);
+    olsr_exit("DYN GW: Out of memory", 0);
   }
 	
   new->next =  list_root;
-- 
2.5.0




More information about the Olsr-dev mailing list