Skip to content

Commit

Permalink
Merge pull request #445 from sadhyama/metapack
Browse files Browse the repository at this point in the history
Pack metadata before cloud status set as online to fix upstream msg send failure
  • Loading branch information
sadhyama committed Jan 22, 2024
2 parents 0ebe5d2 + 0957b0a commit 896a61e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/conn_interface.c
Expand Up @@ -110,7 +110,6 @@ void createSocketConnection(void (* initKeypress)())
OnboardLog("Unrecovered error, terminating the process\n");
abort();
}
packMetaData();

UpStreamMsgQ = NULL;
StartThread(handle_upstream, &upstream_tid);
Expand Down
2 changes: 2 additions & 0 deletions src/connection.c
Expand Up @@ -32,6 +32,7 @@
#include "ParodusInternal.h"
#include "heartBeat.h"
#include "close_retry.h"
#include "upstream.h"
/*----------------------------------------------------------------------------*/
/* Macros */
/*----------------------------------------------------------------------------*/
Expand Down Expand Up @@ -831,6 +832,7 @@ int createNopollConnection(noPollCtx *ctx, server_list_t *server_list)
ParodusPrint("LastReasonStatus reset after successful connection\n");
setMessageHandlers();
stop_conn_in_progress ();
packMetaData();
ParodusPrint("set cloud_status\n");
set_cloud_status(CLOUD_STATUS_ONLINE);
ParodusInfo("cloud_status set as %s after successful connection\n", get_cloud_status());
Expand Down
2 changes: 1 addition & 1 deletion src/upstream.c
Expand Up @@ -103,7 +103,7 @@ void packMetaData()

if (metaPackSize > 0)
{
ParodusPrint("metadata encoding is successful with size %zu\n", metaPackSize);
ParodusInfo("metadata encoding is successful with size %zu\n", metaPackSize);
}
else
{
Expand Down
6 changes: 1 addition & 5 deletions tests/test_conn_interface.c
Expand Up @@ -88,6 +88,7 @@ void clear_metadata()

void free_server_list (server_list_t *server_list)
{
UNUSED(server_list);
return;
}

Expand Down Expand Up @@ -344,7 +345,6 @@ void test_createSocketConnection()
expect_function_call(nopoll_log_set_handler);
will_return(createNopollConnection, nopoll_true);
expect_function_call(createNopollConnection);
expect_function_call(packMetaData);

expect_function_calls(StartThread, 5);
expect_function_call(initKeypress);
Expand Down Expand Up @@ -381,7 +381,6 @@ void test_createSocketConnection1()
expect_function_call(nopoll_log_set_handler);
will_return(createNopollConnection, nopoll_true);
expect_function_call(createNopollConnection);
expect_function_call(packMetaData);

expect_function_calls(StartThread, 5);
will_return(nopoll_loop_wait, 1);
Expand Down Expand Up @@ -429,7 +428,6 @@ void test_PingMissIntervalTime()
expect_function_call(nopoll_log_set_handler);
will_return(createNopollConnection, nopoll_true);
expect_function_call(createNopollConnection);
expect_function_call(packMetaData);

expect_function_calls(StartThread, 5);
//Increment ping interval time to 1 sec for each nopoll_loop_wait call
Expand Down Expand Up @@ -470,7 +468,6 @@ void err_createSocketConnection()
expect_function_call(nopoll_log_set_handler);
will_return(createNopollConnection, nopoll_true);
expect_function_call(createNopollConnection);
expect_function_call(packMetaData);

expect_function_calls(StartThread, 5);
will_return(nopoll_loop_wait, 1);
Expand Down Expand Up @@ -508,7 +505,6 @@ void test_createSocketConnection_cloud_disconn()
expect_function_call(nopoll_log_set_handler);
will_return(createNopollConnection, nopoll_true);
expect_function_call(createNopollConnection);
expect_function_call(packMetaData);

expect_function_calls(StartThread, 5);
will_return(nopoll_loop_wait, 1);
Expand Down
5 changes: 5 additions & 0 deletions tests/test_connection.c
Expand Up @@ -121,6 +121,11 @@ int readFromFile(const char *file_name, char **data)
return 1;
}

void packMetaData()
{
return;
}

noPollConn * nopoll_conn_new_opts (noPollCtx * ctx, noPollConnOpts * opts, const char * host_ip, const char * host_port, const char * host_name,const char * get_url,const char * protocols, const char * origin)
{
UNUSED(host_port); UNUSED(host_name); UNUSED(get_url); UNUSED(protocols);
Expand Down

0 comments on commit 896a61e

Please sign in to comment.