add nn_close to nn_shutdown

This commit is contained in:
Bill Williams
2019-03-04 15:28:00 -08:00
parent 4085c56ed6
commit 1b71082e77
3 changed files with 15 additions and 2 deletions

View File

@@ -32,6 +32,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

View File

@@ -251,8 +251,10 @@ void *processUpstreamMessage()
parStrncpy(temp->url,msg->u.reg.url, sizeof(temp->url));
if(nn_shutdown(temp->sock, 0) < 0)
{
ParodusError ("Failed to shutdown\n");
ParodusError ("nn_shutdown socket=%d err=%d\n",
temp->sock, errno);
}
nn_close (temp->sock);
temp->sock = nn_socket(AF_SP,NN_PUSH );
if(temp->sock >= 0)
@@ -270,7 +272,7 @@ void *processUpstreamMessage()
}
else
{
ParodusInfo("Client registered before. Sending acknowledgement \n");
ParodusInfo("Client registered before. Sending ack on socket %d\n", temp->sock);
status =sendAuthStatus(temp);
if(status == 0)

View File

@@ -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);
@@ -447,6 +454,7 @@ void test_processUpstreamMessageRegMsg()
will_return(nn_shutdown, 1);
expect_function_call(nn_shutdown);
expect_function_call(nn_close);
will_return(nn_socket, 1);
expect_function_call(nn_socket);
@@ -606,12 +614,14 @@ void err_processUpstreamMessageRegMsg()
will_return(nn_shutdown, -1);
expect_function_call(nn_shutdown);
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);
expect_function_call(nn_close);
will_return(nn_socket, 1);
expect_function_call(nn_socket);