|
@@ -182,10 +182,11 @@ connection_releaserecvbuffer(UA_Connection *connection,
|
|
|
|
|
|
static UA_StatusCode
|
|
|
connection_write(UA_Connection *connection, UA_ByteString *buf) {
|
|
|
- if (connection->state == UA_CONNECTION_CLOSED) {
|
|
|
+ if(connection->state == UA_CONNECTION_CLOSED) {
|
|
|
UA_ByteString_deleteMembers(buf);
|
|
|
return UA_STATUSCODE_BADCONNECTIONCLOSED;
|
|
|
}
|
|
|
+
|
|
|
/* Prevent OS signals when sending to a closed socket */
|
|
|
int flags = 0;
|
|
|
#ifdef MSG_NOSIGNAL
|
|
@@ -218,8 +219,9 @@ connection_write(UA_Connection *connection, UA_ByteString *buf) {
|
|
|
static UA_StatusCode
|
|
|
connection_recv(UA_Connection *connection, UA_ByteString *response,
|
|
|
UA_UInt32 timeout) {
|
|
|
- if (connection->state == UA_CONNECTION_CLOSED)
|
|
|
+ if(connection->state == UA_CONNECTION_CLOSED)
|
|
|
return UA_STATUSCODE_BADCONNECTIONCLOSED;
|
|
|
+
|
|
|
/* Listen on the socket for the given timeout until a message arrives */
|
|
|
if(timeout > 0) {
|
|
|
fd_set fdset;
|
|
@@ -235,8 +237,13 @@ connection_recv(UA_Connection *connection, UA_ByteString *response,
|
|
|
if(resultsize == 0)
|
|
|
return UA_STATUSCODE_GOODNONCRITICALTIMEOUT;
|
|
|
|
|
|
- /* Error occurred */
|
|
|
- if (resultsize == -1) {
|
|
|
+ if(resultsize == -1) {
|
|
|
+ /* The call to select was interrupted manually. Act as if it timed
|
|
|
+ * out */
|
|
|
+ if(errno == EINTR)
|
|
|
+ return UA_STATUSCODE_GOODNONCRITICALTIMEOUT;
|
|
|
+
|
|
|
+ /* The error cannot be recovered. Close the connection. */
|
|
|
connection->close(connection);
|
|
|
return UA_STATUSCODE_BADCONNECTIONCLOSED;
|
|
|
}
|
|
@@ -878,8 +885,8 @@ UA_ClientConnectionTCP(UA_ConnectionConfig conf,
|
|
|
ClientNetworkLayerTCP_close(&connection);
|
|
|
UA_LOG_SOCKET_ERRNO_WRAP(
|
|
|
UA_LOG_WARNING(logger, UA_LOGCATEGORY_NETWORK,
|
|
|
- "Connection to %s failed with error: %s",
|
|
|
- endpointUrl, errno_str));
|
|
|
+ "Connection to %s failed with error: %s",
|
|
|
+ endpointUrl, errno_str));
|
|
|
freeaddrinfo(server);
|
|
|
return connection;
|
|
|
}
|