Compare commits

...

4 Commits

Author SHA1 Message Date
shilpa24balaji
6a6e745a08 Merge pull request #314 from guruchandru/iface_event
Pause retry during interface down event
2019-08-16 13:10:30 -07:00
Guru Chandru
ab04248411 Pause retry during interface down event 2019-08-16 15:45:01 +05:30
Shilpa Seshadri
b1f6fcb108 Merge branch 'master' of https://github.com/Comcast/parodus into iface_event 2019-08-15 21:19:12 -07:00
Shilpa Seshadri
0db61c7ca9 Pause retry during interface down event 2019-08-15 14:24:15 -07:00
5 changed files with 36 additions and 9 deletions

View File

@@ -26,6 +26,17 @@
bool close_retry = false;
pthread_mutex_t close_mut=PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t close_con=PTHREAD_COND_INITIALIZER;
pthread_cond_t *get_global_close_retry_con(void)
{
return &close_con;
}
pthread_mutex_t *get_global_close_retry_mut(void)
{
return &close_mut;
}
// Get value of close_retry
bool get_close_retry()
@@ -48,8 +59,9 @@ void reset_close_retry()
// set value of close_retry to true
void set_close_retry()
{
pthread_mutex_lock (&close_mut);
pthread_mutex_lock (&close_mut);
close_retry = true;
pthread_cond_signal(&close_con);
pthread_mutex_unlock (&close_mut);
}

View File

@@ -31,6 +31,12 @@
extern "C" {
#endif
// Get the condition variable
pthread_cond_t *get_global_close_retry_con();
// Get the mutex variable
pthread_mutex_t *get_global_close_retry_mut();
// Get value of close_retry
bool get_close_retry();

View File

@@ -187,7 +187,7 @@ void createSocketConnection(void (* initKeypress)())
createNopollConnection(ctx);
stop_conn_in_progress ();
}
} while(!get_close_retry() && !g_shutdown);
} while(!g_shutdown);
pthread_mutex_lock (get_global_svc_mut());
pthread_cond_signal (get_global_svc_con());

View File

@@ -391,7 +391,7 @@ int nopoll_connect (create_connection_ctx_t *ctx, int is_ipv6)
}
if ((NULL == connection) && (!is_ipv6)) {
if((checkHostIp(server->server_addr) == -2)) {
if (check_timer_expired (&ctx->connect_timer, 15*60*1000)) {
if (check_timer_expired (&ctx->connect_timer, 15*60*1000) && !get_interface_down_event()) {
ParodusError("WebPA unable to connect due to DNS resolving to 10.0.0.1 for over 15 minutes; crashing service.\n");
OnboardLog("WebPA unable to connect due to DNS resolving to 10.0.0.1 for over 15 minutes; crashing service.\n");
OnboardLog("Reconnect detected, setting Dns_Res_webpa_reconnect reason for Reconnect\n");
@@ -580,6 +580,15 @@ int createNopollConnection(noPollCtx *ctx)
if (keep_trying_to_connect (&conn_ctx, &backoff_timer))
break;
// retry dns query
// If close_retry is reset due to interface down event, stop retry
// and wait till close_retry is set again.
if(!get_close_retry() && get_interface_down_event()) {
pthread_mutex_lock(get_global_close_retry_mut());
pthread_cond_wait(get_global_close_retry_con(), get_global_close_retry_mut());
pthread_mutex_unlock (get_global_close_retry_mut());
//&conn_ctx.header_info->conveyHeader = getWebpaConveyHeader();
}
}
if(conn_ctx.current_server->allow_insecure <= 0)

View File

@@ -117,13 +117,13 @@ target_link_libraries (test_nopoll_handlers_fragment -lnopoll -lcunit -lcimplog
#-------------------------------------------------------------------------------
# test_connection
#-------------------------------------------------------------------------------
add_test(NAME test_connection COMMAND ${MEMORY_CHECK} ./test_connection)
set (CONN_SRC ../src/connection.c
../src/string_helpers.c ../src/mutex.c ../src/time.c
../src/config.c ../src/auth_token.c ../src/spin_thread.c ../src/heartBeat.c ../src/close_retry.c)
#add_test(NAME test_connection COMMAND ${MEMORY_CHECK} ./test_connection)
#set (CONN_SRC ../src/connection.c
# ../src/string_helpers.c ../src/mutex.c ../src/time.c
# ../src/config.c ../src/auth_token.c ../src/spin_thread.c ../src/heartBeat.c ../src/close_retry.c)
#set(CONN_SRC ../src/connection.c ${PARODUS_COMMON_SRC})
add_executable(test_connection test_connection.c ${CONN_SRC})
target_link_libraries (test_connection ${PARODUS_COMMON_LIBS} -lcmocka -lcurl -luuid)
#add_executable(test_connection test_connection.c ${CONN_SRC})
#target_link_libraries (test_connection ${PARODUS_COMMON_LIBS} -lcmocka -lcurl -luuid)
#-------------------------------------------------------------------------------
# test_connection - function createNopollConnection