Compare commits

..

6 Commits

Author SHA1 Message Date
Shilpa Seshadri
d52c4c2a43 Add logs to print the extra headers 2020-03-19 16:57:37 -07:00
shilpa24balaji
9cfc734c51 Merge pull request #331 from rajnishdey/errMsgUpdate
Change Info log level from error log level for "received temporary re…
2019-11-18 10:51:06 -08:00
Rajnish
153add9bec Change Info log level from error log level for "received temporary redirection response". 2019-11-18 11:28:43 -05:00
shilpa24balaji
7679fdaf4a Merge pull request #327 from bill1600/ifcdown
update backoff delay and interface down logic
2019-11-15 12:27:41 -08:00
Bill Williams
1c09a80493 fix condition test in wait_while_interface_down 2019-11-14 15:31:28 -08:00
Bill Williams
bfad8ed44b fix deadlock in wait_while_interface_down 2019-11-14 10:56:47 -08:00
2 changed files with 15 additions and 13 deletions

View File

@@ -169,11 +169,10 @@ void createSocketConnection(void (* initKeypress)())
seshat_registered = __registerWithSeshat();
}
// If interface down event is set, wait till interface is up again.
if (get_interface_down_event ())
if (0 != wait_while_interface_down ())
break;
if(get_close_retry())
{
ParodusInfo("close_retry is %d, hence closing the connection and retrying\n", get_close_retry());

View File

@@ -509,7 +509,7 @@ int wait_connection_ready (create_connection_ctx_t *ctx)
if(wait_status == 307 || wait_status == 302 || wait_status == 303) // only when there is a http redirect
{
char *redirect_ptr = redirectURL;
ParodusError("Received temporary redirection response message %s\n", redirectURL);
ParodusInfo("Received temporary redirection response message %s\n", redirectURL);
// Extract server Address and port from the redirectURL
if (strncmp (redirect_ptr, "Redirect:", 9) == 0)
redirect_ptr += 9;
@@ -610,7 +610,6 @@ int keep_trying_to_connect (create_connection_ctx_t *ctx,
if (rtn == CONN_WAIT_ACTION_RETRY) // if redirected or build_headers
continue;
// If interface down event is set, stop retry
// and wait till interface is up again.
if(get_interface_down_event()) {
@@ -626,7 +625,6 @@ int keep_trying_to_connect (create_connection_ctx_t *ctx,
!= BACKOFF_DELAY_TAKEN) // shutdown or cond wait error
return false;
}
if (rtn == CONN_WAIT_RETRY_DNS)
return false; //find_server again
// else retry
@@ -644,17 +642,15 @@ int wait_while_interface_down()
set_global_conn(NULL);
while (get_interface_down_event ()) {
pthread_mutex_lock(get_interface_down_mut());
rtn = pthread_cond_wait(get_interface_down_con(), get_interface_down_mut());
pthread_mutex_unlock (get_interface_down_mut());
pthread_mutex_unlock (get_interface_down_mut());
if (rtn != 0)
ParodusError("Error on pthread_cond_wait (%d) in wait_while_interface_down\n", rtn);
if ((rtn != 0) || g_shutdown)
ParodusError
("Error on pthread_cond_wait (%d) in wait_while_interface_down\n", rtn);
if ((rtn != 0) || g_shutdown) {
return -1;
}
}
return 0;
}
@@ -700,7 +696,6 @@ int createNopollConnection(noPollCtx *ctx)
set_current_server (&conn_ctx);
if (keep_trying_to_connect (&conn_ctx, &backoff_timer))
break;
// retry dns query
}
@@ -750,6 +745,10 @@ int createNopollConnection(noPollCtx *ctx)
static char* build_extra_headers( const char *auth, const char *device_id,
const char *user_agent, const char *convey )
{
ParodusInfo("auth token: %s\n", (NULL != auth) ? auth: "");
ParodusInfo("device_id: %s\n", device_id);
ParodusInfo("user_agent: %s\n", user_agent);
ParodusInfo("convey: %s\n", convey);
return nopoll_strdup_printf(
"%s%s"
"\r\nX-WebPA-Device-Name: %s"
@@ -789,6 +788,10 @@ static noPollConnOpts * createConnOpts (char * extra_headers, bool secure)
}
nopoll_conn_opts_set_interface (opts,get_parodus_cfg()->webpa_interface_used);
nopoll_conn_opts_set_extra_headers (opts,extra_headers);
ParodusInfo("nopoll_conn_opts_set_extra_headers, len %d, value: %s\n", strlen(extra_headers), extra_headers);
FILE *fp = fopen("/tmp/parodus_extra_headers.txt", "w");
fprintf(fp, "%s", extra_headers);
fclose(fp);
return opts;
}