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

Ferry Huberts (spam-protected)
Fri Nov 6 16:28:58 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/secure/src/olsrd_secure.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/secure/src/olsrd_secure.c b/lib/secure/src/olsrd_secure.c
index 0e3b59c..d7fd031 100644
--- a/lib/secure/src/olsrd_secure.c
+++ b/lib/secure/src/olsrd_secure.c
@@ -179,12 +179,14 @@ secure_plugin_init(void)
   i = read_key_from_file(keyfile);
 
   if (i < 0) {
-    olsr_printf(1, "[ENC]Could not read key from file %s!\nExitting!\n\n", keyfile);
-    exit(1);
+    char buf[1024];
+    snprintf(buf, sizeof(buf), "SECURE: Could not read key from file %s", keyfile);
+    olsr_exit(buf, 1);
   }
   if (i == 0) {
-    olsr_printf(1, "[ENC]There was a problem reading key from file %s. Is the key long enough?\nExitting!\n\n", keyfile);
-    exit(1);
+    char buf[1024];
+    snprintf(buf, sizeof(buf), "SECURE: There was a problem reading key from file %s. Is the key long enough?", keyfile);
+    olsr_exit(buf, 1);
   }
 
   /* Register the packet transform function */
-- 
2.5.0




More information about the Olsr-dev mailing list