浏览代码

Check the connection state in UA_SecureChannel_sendSymmetricMessage

StalderT 7 年之前
父节点
当前提交
891aacf713
共有 1 个文件被更改,包括 5 次插入0 次删除
  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)