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

Ferry Huberts (spam-protected)
Fri Nov 6 16:29:03 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)>
---
 src/plugin_loader.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/plugin_loader.c b/src/plugin_loader.c
index 9b06117..ac4b085 100644
--- a/src/plugin_loader.c
+++ b/src/plugin_loader.c
@@ -70,8 +70,7 @@ olsr_load_plugins(void)
     }
   }
   if (rv != 0) {
-    OLSR_PRINTF(0, "-- PLUGIN LOADING FAILED! --\n");
-    exit(1);
+    olsr_exit("-- PLUGIN LOADING FAILED --", 1);
   }
   OLSR_PRINTF(0, "-- ALL PLUGINS LOADED! --\n\n");
 }
@@ -289,8 +288,9 @@ init_olsr_plugin(struct olsr_plugin *entry)
       OLSR_PRINTF(0, "Registering parameter \"%s\": ", params->key);
       rc = entry->register_param(params->key, params->value);
       if (rc < 0) {
-        fprintf(stderr, "\nFatal error in plugin parameter \"%s\"/\"%s\"\n", params->key, params->value);
-        exit(EXIT_FAILURE);
+        char buf[1024];
+        snprintf(buf, sizeof(buf), "Fatal error in plugin parameter \"%s\"/\"%s\"", params->key, params->value);
+        olsr_exit(buf, EXIT_FAILURE);
       }
       OLSR_PRINTF(0, "%s\n", rc == 0 ? "FAILED" : "OK");
 #endif /* defined SUPPORT_OLD_PLUGIN_VERSIONS && SUPPORT_OLD_PLUGIN_VERSIONS */
-- 
2.5.0




More information about the Olsr-dev mailing list