Browse Source

adapted tests to revised logic of closing

Leon Urbas 10 years ago
parent
commit
d8701f7d3b
2 changed files with 5 additions and 8 deletions
  1. 4 7
      examples/networklayer.c
  2. 1 1
      tests/check_stack.c

+ 4 - 7
examples/networklayer.c

@@ -156,7 +156,6 @@ void* NL_TCP_reader(NL_Connection *c) {
 	UA_TL_Connection_getLocalConfig(c->connection, &localBuffers);
 	UA_alloc((void**)&(readBuffer.data),localBuffers.recvBufferSize);
 
-
 	UA_TL_Connection_getState(c->connection, &connectionState);
 	if (connectionState  != CONNECTIONSTATE_CLOSE) {
 		DBG_VERBOSE(printf("NL_TCP_reader - enter read\n"));
@@ -171,8 +170,10 @@ void* NL_TCP_reader(NL_Connection *c) {
 		DBG_VERBOSE(printf("NL_TCP_reader - src={%*.s}, ",c->connection.remoteEndpointUrl.length,c->connection.remoteEndpointUrl.data));
 		DBG(UA_ByteString_printx("NL_TCP_reader - received=",&readBuffer));
 
-		if (readBuffer.length  > 0) {
-
+		if (errno != 0) {
+			perror("NL_TCP_reader - ERROR reading from socket1");
+			UA_TL_Connection_setState(c->connection, CONNECTIONSTATE_CLOSE);
+		} else if (readBuffer.length  > 0) {
 #ifdef DEBUG
 #include "ua_transport_binary_secure.h"
 			UA_UInt32 pos = 0;
@@ -186,11 +187,7 @@ void* NL_TCP_reader(NL_Connection *c) {
 				UA_NodeId_printf("NL_TCP_reader - Service Type\n",&serviceRequestType);
 			}
 #endif
-
 			TL_Process((c->connection),&readBuffer);
-		} else {
-			perror("NL_TCP_reader - ERROR reading from socket1");
-			UA_TL_Connection_setState(c->connection, CONNECTIONSTATE_CLOSE);
 		}
 	}
 

+ 1 - 1
tests/check_stack.c

@@ -417,7 +417,7 @@ START_TEST(validOpeningCloseSequence) {
 	indicateMsg(handle, &message_003);
 	UA_TL_Connection_getState(stackTestFixture_getFixture(handle)->connection, &connectionState);
 	// then
-	ck_assert_int_eq(connectionState, CONNECTIONSTATE_CLOSED);
+	ck_assert_int_eq(connectionState, CONNECTIONSTATE_CLOSE);
 
 	// finally
 	stackTestFixture_delete(handle);