From d2d1590329006ddd00f5f79f587f4b2fedb36d68 Mon Sep 17 00:00:00 2001 From: Sadhyama Vengilat Date: Tue, 31 Aug 2021 19:04:26 +0530 Subject: [PATCH] Fix unit tests on conn_interface --- CHANGELOG.md | 1 + src/conn_interface.c | 2 +- tests/test_conn_interface.c | 9 +++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d442ca..3fe1478 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] - Add additional HTTP headers for call to Themis from Convey - Add callback handler for initial cloud connection status change event +- Fix Parodus connection stuck on interface up down received together ## [1.1.4] - on connect retry, requery jwt only if it failed before diff --git a/src/conn_interface.c b/src/conn_interface.c index edb49d9..3a86ac8 100644 --- a/src/conn_interface.c +++ b/src/conn_interface.c @@ -196,7 +196,7 @@ void createSocketConnection(void (* initKeypress)()) createNopollConnection(ctx, &server_list); } //process exit only when g_shutdown is true. - } while(!g_shutdown); + } while(FOREVER() && !g_shutdown); pthread_mutex_lock (get_global_svc_mut()); pthread_cond_signal (get_global_svc_con()); diff --git a/tests/test_conn_interface.c b/tests/test_conn_interface.c index 5433e7c..465bfc5 100644 --- a/tests/test_conn_interface.c +++ b/tests/test_conn_interface.c @@ -44,7 +44,7 @@ pthread_mutex_t svc_mut=PTHREAD_MUTEX_INITIALIZER; pthread_cond_t svc_con=PTHREAD_COND_INITIALIZER; int numLoops; parodusOnPingStatusChangeHandler on_ping_status_change; - + /*----------------------------------------------------------------------------*/ /* Mocks */ /*----------------------------------------------------------------------------*/ @@ -335,6 +335,7 @@ void test_createSocketConnection() void test_createSocketConnection1() { + numLoops =0; noPollCtx *ctx; ParodusCfg cfg; memset(&cfg,0, sizeof(ParodusCfg)); @@ -364,11 +365,11 @@ void test_createSocketConnection1() expect_function_call(nopoll_ctx_unref); expect_function_call(nopoll_cleanup_library); createSocketConnection(NULL); - } void test_PingMissIntervalTime() { + numLoops = 6; noPollCtx *ctx; ParodusCfg cfg; memset(&cfg,0,sizeof(ParodusCfg)); @@ -386,7 +387,6 @@ void test_PingMissIntervalTime() //Max ping timeout is 6 sec cfg.webpa_ping_timeout = 6; set_parodus_cfg(&cfg); - reset_close_retry(); expect_function_call(nopoll_thread_handlers); @@ -422,11 +422,11 @@ void test_PingMissIntervalTime() expect_function_call(nopoll_ctx_unref); expect_function_call(nopoll_cleanup_library); createSocketConnection(NULL); - } void err_createSocketConnection() { + numLoops =0; set_close_retry(); reset_heartBeatTimer(); expect_function_call(nopoll_thread_handlers); @@ -459,6 +459,7 @@ void err_createSocketConnection() void test_createSocketConnection_cloud_disconn() { + numLoops =0; ParodusCfg cfg; memset(&cfg,0,sizeof(ParodusCfg)); cfg.cloud_disconnect = strdup("XPC");