mirror of
https://github.com/outbackdingo/parodus.git
synced 2026-01-27 18:20:04 +00:00
Compare commits
8 Commits
nopoll_pol
...
3.4_p3xb3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
117db39c64 | ||
|
|
0ac7605a3b | ||
|
|
e03b795989 | ||
|
|
950954ee4d | ||
|
|
a2909de3ca | ||
|
|
1fd9cccaac | ||
|
|
561113fe0a | ||
|
|
1bc804f445 |
@@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
- Fixed main loop to keep calling svc_alive_task during a cloud disconnect and retry
|
||||
- change svc alive back to a separate thread. Shut it down with pthread_cond_timedwait
|
||||
- Refactored Upsteam RETRIEVE flow
|
||||
- Fix re-registration to call nn_shutdown and nn_close, so we don't lose a socket.
|
||||
|
||||
## [1.0.1] - 2018-07-18
|
||||
### Added
|
||||
|
||||
@@ -76,7 +76,11 @@ int addToList( wrp_msg_t **msg)
|
||||
if(rc < 0)
|
||||
{
|
||||
ParodusError ("Unable to connect socket (errno=%d, %s)\n",errno, strerror(errno));
|
||||
nn_close (sock);
|
||||
if (nn_close (sock) < 0)
|
||||
{
|
||||
ParodusError ("nn_close socket=%d (err=%d, %s)\n",
|
||||
sock, errno, strerror(errno));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
@@ -87,6 +91,7 @@ int addToList( wrp_msg_t **msg)
|
||||
{
|
||||
memset( new_node, 0, sizeof( reg_list_item_t ) );
|
||||
new_node->sock = sock;
|
||||
new_node->endpoint = rc;
|
||||
ParodusPrint("new_node->sock is %d\n", new_node->sock);
|
||||
|
||||
|
||||
@@ -219,6 +224,16 @@ int deleteFromList(char* service_name)
|
||||
}
|
||||
|
||||
ParodusPrint("Deleting the node\n");
|
||||
if(nn_shutdown(curr_node->sock, curr_node->endpoint) < 0)
|
||||
{
|
||||
ParodusError ("nn_shutdown socket=%d endpt=%d, err=%d\n",
|
||||
curr_node->sock, curr_node->endpoint, errno);
|
||||
}
|
||||
if (nn_close (curr_node->sock) < 0)
|
||||
{
|
||||
ParodusError ("nn_close socket=%d err=%d\n",
|
||||
curr_node->sock, errno);
|
||||
}
|
||||
free( curr_node );
|
||||
curr_node = NULL;
|
||||
ParodusInfo("Deleted successfully and returning..\n");
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
typedef struct reg_list_item
|
||||
{
|
||||
int sock;
|
||||
int endpoint;
|
||||
char service_name[32];
|
||||
char url[100];
|
||||
struct reg_list_item *next;
|
||||
|
||||
@@ -615,6 +615,7 @@ void createNewAuthToken(char *newToken, size_t len)
|
||||
{
|
||||
//Call create script
|
||||
char output[12] = {'\0'};
|
||||
memset (newToken, 0, len);
|
||||
execute_token_script(output,get_parodus_cfg()->token_acquisition_script,sizeof(output),get_parodus_cfg()->hw_mac,get_parodus_cfg()->hw_serial_number);
|
||||
if (strlen(output)>0 && strcmp(output,"SUCCESS")==0)
|
||||
{
|
||||
@@ -636,7 +637,7 @@ void getAuthToken(ParodusCfg *cfg)
|
||||
{
|
||||
//local var to update cfg->webpa_auth_token only in success case
|
||||
char output[4069] = {'\0'} ;
|
||||
|
||||
memset (cfg->webpa_auth_token, 0, sizeof(cfg->webpa_auth_token));
|
||||
if( strlen(cfg->token_read_script) !=0 && strlen(cfg->token_acquisition_script) !=0)
|
||||
{
|
||||
execute_token_script(output,cfg->token_read_script,sizeof(output),cfg->hw_mac,cfg->hw_serial_number);
|
||||
|
||||
@@ -114,8 +114,9 @@ void *serviceAliveTask()
|
||||
byte = 0;
|
||||
if(ret == 0)
|
||||
{
|
||||
ParodusPrint("Deletion from list is success, doing resync with head\n");
|
||||
release_global_node ();
|
||||
temp= get_global_node();
|
||||
ParodusInfo("Deletion from list is success, doing resync with head\n");
|
||||
ret = -1;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -190,6 +190,16 @@ void *handle_upstream()
|
||||
ParodusError("failure in allocation for message\n");
|
||||
}
|
||||
}
|
||||
if(nn_shutdown(sock, bind) < 0)
|
||||
{
|
||||
ParodusError ("nn_shutdown bind socket=%d endpt=%d, err=%d\n",
|
||||
sock, bind, errno);
|
||||
}
|
||||
if (nn_close (sock) < 0)
|
||||
{
|
||||
ParodusError ("nn_close bind socket=%d err=%d\n",
|
||||
sock, errno);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -234,7 +244,7 @@ void *processUpstreamMessage()
|
||||
if(rv > 0)
|
||||
{
|
||||
msgType = msg->msg_type;
|
||||
if(msgType == 9)
|
||||
if(msgType == WRP_MSG_TYPE__SVC_REGISTRATION)
|
||||
{
|
||||
ParodusInfo("\n Nanomsg client Registration for Upstream\n");
|
||||
//Extract serviceName and url & store it in a linked list for reg_clients
|
||||
@@ -249,9 +259,15 @@ void *processUpstreamMessage()
|
||||
{
|
||||
ParodusInfo("match found, client is already registered\n");
|
||||
parStrncpy(temp->url,msg->u.reg.url, sizeof(temp->url));
|
||||
if(nn_shutdown(temp->sock, 0) < 0)
|
||||
if(nn_shutdown(temp->sock, temp->endpoint) < 0)
|
||||
{
|
||||
ParodusError ("Failed to shutdown\n");
|
||||
ParodusError ("nn_shutdown socket=%d endpt=%d, err=%d\n",
|
||||
temp->sock, temp->endpoint, errno);
|
||||
}
|
||||
if (nn_close (temp->sock) < 0)
|
||||
{
|
||||
ParodusError ("nn_close socket=%d err=%d\n",
|
||||
temp->sock, errno);
|
||||
}
|
||||
|
||||
temp->sock = nn_socket(AF_SP,NN_PUSH );
|
||||
@@ -270,7 +286,8 @@ void *processUpstreamMessage()
|
||||
}
|
||||
else
|
||||
{
|
||||
ParodusInfo("Client registered before. Sending acknowledgement \n");
|
||||
temp->endpoint = rc;
|
||||
ParodusInfo("Client registered before. Sending ack on socket %d\n", temp->sock);
|
||||
status =sendAuthStatus(temp);
|
||||
|
||||
if(status == 0)
|
||||
@@ -400,9 +417,8 @@ void *processUpstreamMessage()
|
||||
{
|
||||
ParodusError("Failed to get device_id\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else if (WRP_MSG_TYPE__SVC_ALIVE != msgType) {
|
||||
/* Don't reply to service alive message */
|
||||
sendUpstreamMsgToServer(&message->msg, message->len);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,6 +215,13 @@ int nn_shutdown (int s, int how)
|
||||
return (int)mock();
|
||||
}
|
||||
|
||||
int nn_close (int s)
|
||||
{
|
||||
UNUSED(s);
|
||||
function_called();
|
||||
return (int)mock();
|
||||
}
|
||||
|
||||
int nn_setsockopt (int s, int level, int option, const void *optval, size_t optvallen)
|
||||
{
|
||||
UNUSED(s); UNUSED(level); UNUSED(option); UNUSED(optval); UNUSED(optvallen);
|
||||
@@ -266,6 +273,10 @@ void test_handleUpstreamNull()
|
||||
expect_function_call(nn_bind);
|
||||
will_return(nn_recv, 12);
|
||||
expect_function_call(nn_recv);
|
||||
will_return(nn_shutdown, 0);
|
||||
expect_function_call(nn_shutdown);
|
||||
will_return(nn_close, 0);
|
||||
expect_function_call(nn_close);
|
||||
handle_upstream();
|
||||
}
|
||||
|
||||
@@ -287,6 +298,10 @@ void test_handle_upstream()
|
||||
expect_function_call(nn_bind);
|
||||
will_return(nn_recv, 12);
|
||||
expect_function_call(nn_recv);
|
||||
will_return(nn_shutdown, 0);
|
||||
expect_function_call(nn_shutdown);
|
||||
will_return(nn_close, 0);
|
||||
expect_function_call(nn_close);
|
||||
handle_upstream();
|
||||
free(UpStreamMsgQ->next);
|
||||
free(UpStreamMsgQ);
|
||||
@@ -448,6 +463,9 @@ void test_processUpstreamMessageRegMsg()
|
||||
will_return(nn_shutdown, 1);
|
||||
expect_function_call(nn_shutdown);
|
||||
|
||||
will_return(nn_close, 0);
|
||||
expect_function_call(nn_close);
|
||||
|
||||
will_return(nn_socket, 1);
|
||||
expect_function_call(nn_socket);
|
||||
|
||||
@@ -607,12 +625,18 @@ void err_processUpstreamMessageRegMsg()
|
||||
will_return(nn_shutdown, -1);
|
||||
expect_function_call(nn_shutdown);
|
||||
|
||||
will_return(nn_close, 0);
|
||||
expect_function_call(nn_close);
|
||||
|
||||
will_return(nn_socket, -1);
|
||||
expect_function_call(nn_socket);
|
||||
|
||||
will_return(nn_shutdown, 1);
|
||||
expect_function_call(nn_shutdown);
|
||||
|
||||
will_return(nn_close, 0);
|
||||
expect_function_call(nn_close);
|
||||
|
||||
will_return(nn_socket, 1);
|
||||
expect_function_call(nn_socket);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user