diff --git a/CHANGELOG.md b/CHANGELOG.md index 21c91a3..698e265 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] -- Refactor of connection code (simplification). +- Refactored connection.c and updated corresponding unit tests - Additional `/cloud-status` and `/cloud-disconnect` fields. +- Switched from nanomsg (Release 1.1.2) to NNG (Release v1.0.1) +- Memory leak fixes ## [1.0.1] - 2018-07-18 ### Added @@ -20,8 +22,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Configurable security flag and port. - Default HTTP port to 80 and HTTPS port to 443. - Updates to how `nopoll` is called have been implemented. -- Refactored connection.c and updated corresponding unit tests -- Switched from nanomsg (Release 1.1.2) to NNG (Release v1.0.1) ### Fixed - 64 bit pointer fixes (#144, #145). diff --git a/src/config.c b/src/config.c index d7b701c..e633b7f 100644 --- a/src/config.c +++ b/src/config.c @@ -693,8 +693,8 @@ void setDefaultValuesToCfg(ParodusCfg *cfg) parStrncpy(cfg->webpa_uuid, "1234567-345456546",sizeof(cfg->webpa_uuid)); ParodusPrint("cfg->webpa_uuid is :%s\n", cfg->webpa_uuid); - cfg->crud_config_file = strdup("parodus_cfg.json"); - ParodusPrint("Default crud_config_file is %s\n", cfg->crud_config_file); + cfg->crud_config_file = NULL; + cfg->cloud_status = CLOUD_STATUS_OFFLINE; ParodusInfo("Default cloud_status is %s\n", cfg->cloud_status); } diff --git a/src/conn_interface.c b/src/conn_interface.c index 2efbe14..c0f841c 100644 --- a/src/conn_interface.c +++ b/src/conn_interface.c @@ -51,6 +51,7 @@ /*----------------------------------------------------------------------------*/ /* File Scoped Variables */ /*----------------------------------------------------------------------------*/ +bool g_shutdown = false; /*----------------------------------------------------------------------------*/ /* Function Prototypes */ @@ -168,10 +169,14 @@ void createSocketConnection(void (* initKeypress)()) } createNopollConnection(ctx); } - } while(!get_close_retry()); + } while(!get_close_retry() && !g_shutdown); close_and_unref_connection(get_global_conn()); nopoll_ctx_unref(ctx); nopoll_cleanup_library(); } +void shutdownSocketConnection(void) { + g_shutdown = true; +} + diff --git a/src/conn_interface.h b/src/conn_interface.h index c530f9a..bc39cd5 100644 --- a/src/conn_interface.h +++ b/src/conn_interface.h @@ -45,6 +45,7 @@ extern UpStreamMsg *UpStreamMsgQ; * and creates the intial connection and manages the connection wait, close mechanisms. */ void createSocketConnection(void (* initKeypress)()); +void shutdownSocketConnection(void); #ifdef __cplusplus } diff --git a/src/downstream.c b/src/downstream.c index 54c9cb3..aabb327 100644 --- a/src/downstream.c +++ b/src/downstream.c @@ -75,6 +75,7 @@ void listenerOnMessage(void * msg, size_t msgSize) case WRP_MSG_TYPE__AUTH: { ParodusInfo("Authorization Status received with Status code :%d\n", message->u.auth.status); + wrp_free_struct(message); break; } diff --git a/src/main.c b/src/main.c index 37a63d4..35e7748 100644 --- a/src/main.c +++ b/src/main.c @@ -103,7 +103,7 @@ static void sig_handler(int sig) { signal(SIGINT, sig_handler); /* reset it to this function */ ParodusInfo("SIGINT received!\n"); - exit(0); + shutdownSocketConnection(); } else if ( sig == SIGUSR1 ) { @@ -132,7 +132,7 @@ static void sig_handler(int sig) else { ParodusInfo("Signal %d received!\n", sig); - exit(0); + shutdownSocketConnection(); } }