mirror of
https://github.com/outbackdingo/parodus.git
synced 2026-01-27 10:20:04 +00:00
Merge pull request #349 from bill1600/siglog
fix shutdown close msg to agree with splunk log
This commit is contained in:
@@ -179,7 +179,7 @@ void createSocketConnection(void (* initKeypress)())
|
||||
if(get_close_retry())
|
||||
{
|
||||
ParodusInfo("close_retry is %d, hence closing the connection and retrying\n", get_close_retry());
|
||||
close_and_unref_connection(get_global_conn());
|
||||
close_and_unref_connection(get_global_conn(), false);
|
||||
set_global_conn(NULL);
|
||||
|
||||
if(get_parodus_cfg()->cloud_disconnect !=NULL)
|
||||
@@ -220,8 +220,7 @@ void createSocketConnection(void (* initKeypress)())
|
||||
deleteAllClients ();
|
||||
|
||||
ParodusInfo ("reconnect reason at close %s\n", get_global_reconnect_reason());
|
||||
ParodusInfo ("shutdown reason at close %s\n", get_global_shutdown_reason());
|
||||
close_and_unref_connection(get_global_conn());
|
||||
close_and_unref_connection(get_global_conn(), true);
|
||||
nopoll_ctx_unref(ctx);
|
||||
nopoll_cleanup_library();
|
||||
curl_global_cleanup();
|
||||
|
||||
@@ -620,7 +620,7 @@ int connect_and_wait (create_connection_ctx_t *ctx)
|
||||
} // nopoll_connected
|
||||
|
||||
if (nopoll_connected) {
|
||||
close_and_unref_connection(get_global_conn());
|
||||
close_and_unref_connection(get_global_conn(), false);
|
||||
set_global_conn(NULL);
|
||||
}
|
||||
|
||||
@@ -685,7 +685,7 @@ int wait_while_interface_down()
|
||||
int rtn;
|
||||
|
||||
ParodusError("Interface is down, hence waiting until its up\n");
|
||||
close_and_unref_connection (get_global_conn());
|
||||
close_and_unref_connection (get_global_conn(), false);
|
||||
set_global_conn(NULL);
|
||||
|
||||
while (get_interface_down_event ()) {
|
||||
@@ -847,21 +847,24 @@ static noPollConnOpts * createConnOpts (char * extra_headers, bool secure)
|
||||
return opts;
|
||||
}
|
||||
|
||||
static void close_conn ( noPollConn *conn, const char *specified_reason)
|
||||
static void close_conn ( noPollConn *conn, bool is_shutting_down)
|
||||
{
|
||||
const char *effective_reason = specified_reason;
|
||||
const char *effective_reason = get_global_shutdown_reason();
|
||||
|
||||
if (NULL == effective_reason) {
|
||||
effective_reason = SHUTDOWN_REASON_SYSTEM_RESTART;
|
||||
}
|
||||
else if (strcmp (effective_reason, SHUTDOWN_REASON_SIGTERM) == 0) {
|
||||
char *sigterm_reason;
|
||||
if (readFromFile (get_parodus_cfg()->close_reason_file, &sigterm_reason) &&
|
||||
char *reason_file = get_parodus_cfg()->close_reason_file;
|
||||
if ((NULL != reason_file) && readFromFile (reason_file, &sigterm_reason) &&
|
||||
(strlen(sigterm_reason) != 0))
|
||||
{
|
||||
nopoll_conn_close_ext(conn, CloseNormalClosure, sigterm_reason,
|
||||
strlen (sigterm_reason));
|
||||
ParodusInfo ("Closed by SIGTERM, reason: %s\n", sigterm_reason);
|
||||
if (is_shutting_down)
|
||||
ParodusInfo ("shutdown reason at close %s\n", sigterm_reason);
|
||||
free (sigterm_reason);
|
||||
return;
|
||||
}
|
||||
@@ -871,12 +874,14 @@ static void close_conn ( noPollConn *conn, const char *specified_reason)
|
||||
}
|
||||
nopoll_conn_close_ext(conn, CloseNormalClosure, effective_reason,
|
||||
strlen (effective_reason));
|
||||
if (is_shutting_down)
|
||||
ParodusInfo ("shutdown reason at close %s\n", effective_reason);
|
||||
}
|
||||
|
||||
void close_and_unref_connection(noPollConn *conn)
|
||||
void close_and_unref_connection(noPollConn *conn, bool is_shutting_down)
|
||||
{
|
||||
if (conn) {
|
||||
close_conn (conn, get_global_shutdown_reason ());
|
||||
close_conn (conn, is_shutting_down);
|
||||
get_parodus_cfg()->cloud_status = CLOUD_STATUS_OFFLINE;
|
||||
ParodusInfo("cloud_status set as %s after connection close\n", get_parodus_cfg()->cloud_status);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ int createNopollConnection(noPollCtx *, server_list_t *);
|
||||
/**
|
||||
* @brief Interface to terminate WebSocket client connections and clean up resources.
|
||||
*/
|
||||
void close_and_unref_connection(noPollConn *);
|
||||
void close_and_unref_connection(noPollConn *conn, bool is_shutting_down);
|
||||
|
||||
noPollConn *get_global_conn(void);
|
||||
void set_global_conn(noPollConn *);
|
||||
|
||||
@@ -190,9 +190,9 @@ void set_global_reconnect_status(bool status)
|
||||
function_called();
|
||||
}
|
||||
|
||||
void close_and_unref_connection(noPollConn *conn)
|
||||
void close_and_unref_connection(noPollConn *conn, bool is_shutting_down)
|
||||
{
|
||||
UNUSED(conn);
|
||||
UNUSED(conn); UNUSED(is_shutting_down);
|
||||
function_called();
|
||||
}
|
||||
|
||||
|
||||
@@ -268,7 +268,7 @@ void test_set_global_reconnect_reason()
|
||||
|
||||
void test_closeConnection()
|
||||
{
|
||||
close_and_unref_connection(get_global_conn());
|
||||
close_and_unref_connection(get_global_conn(), false);
|
||||
}
|
||||
|
||||
void test_server_is_null()
|
||||
|
||||
Reference in New Issue
Block a user