Memory leak fixes

This commit is contained in:
Shilpa Seshadri
2018-10-05 16:20:18 -07:00
parent ce0c43d894
commit 1addffdeb0
6 changed files with 15 additions and 8 deletions

View File

@@ -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).

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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
}

View File

@@ -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;
}

View File

@@ -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();
}
}