linux: call olsr_exit() instead of exit()
authorFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 5 Nov 2015 22:51:37 +0000 (23:51 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Fri, 6 Nov 2015 15:26:22 +0000 (16:26 +0100)
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 <ferry.huberts@pelagic.nl>
src/linux/nl80211_link_info.c

index ddb7ab3..06953e9 100644 (file)
@@ -253,8 +253,7 @@ static void nl80211_link_info_for_interface(struct interface_olsr *iface, struct
        genlmsg_put(request_message, NL_AUTO_PID, NL_AUTO_SEQ, netlink_id, 0, NLM_F_DUMP, NL80211_CMD_GET_STATION, 0);
 
        if (nla_put_u32(request_message, NL80211_ATTR_IFINDEX, iface->if_index) == -1) {
-               olsr_syslog(OLSR_LOG_ERR, "Failed to add interface index to netlink message");
-               exit(1);
+               olsr_exit("Failed to add interface index to netlink message", 1);
        }
 
 #ifdef NL_DEBUG
@@ -266,8 +265,7 @@ static void nl80211_link_info_for_interface(struct interface_olsr *iface, struct
        }
 
        if (nl_cb_set(request_cb, NL_CB_VALID, NL_CB_CUSTOM, parse_nl80211_message, &link_context) != 0) {
-               olsr_syslog(OLSR_LOG_ERR, "Failed to set netlink message callback");
-               exit(1);
+               olsr_exit("Failed to set netlink message callback", 1);
        }
 
        nl_cb_err(request_cb, NL_CB_CUSTOM, error_handler, &finish);
@@ -275,8 +273,7 @@ static void nl80211_link_info_for_interface(struct interface_olsr *iface, struct
        nl_cb_set(request_cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &finish);
 
        if (nl_send_auto_complete(gen_netlink_socket, request_message) < 0) {
-               olsr_syslog(OLSR_LOG_ERR, "Failed sending the request message with netlink");
-               exit(1);
+               olsr_exit("Failed sending the request message with netlink", 1);
        }
 
        while (! finish) {