Parcourir la source

Check the connection state in UA_SecureChannel_sendSymmetricMessage

StalderT il y a 7 ans
Parent
commit
891aacf713
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 5 0
      src/ua_securechannel.c

+ 5 - 0
src/ua_securechannel.c

@@ -643,6 +643,11 @@ UA_StatusCode
 UA_SecureChannel_sendSymmetricMessage(UA_SecureChannel *channel, UA_UInt32 requestId,
                                       UA_MessageType messageType, void *payload,
                                       const UA_DataType *payloadType) {
+    if(channel->connection) {
+        if (channel->connection->state == UA_CONNECTION_CLOSED)
+            return UA_STATUSCODE_BADCONNECTIONCLOSED;
+    }
+
     UA_MessageContext mc;
     UA_StatusCode retval = UA_MessageContext_begin(&mc, channel, requestId, messageType);
     if(retval != UA_STATUSCODE_GOOD)