浏览代码

fix two bugs that came up in the lua bindings

Julius Pfrommer 9 年之前
父节点
当前提交
aac67ee516
共有 2 个文件被更改,包括 5 次插入3 次删除
  1. 4 2
      examples/networklayer_tcp.c
  2. 1 1
      src/ua_types.c

+ 4 - 2
examples/networklayer_tcp.c

@@ -92,8 +92,10 @@ socket_recv(UA_Connection *connection, UA_ByteString *response, UA_UInt32 timeou
 
     if(timeout > 0) {
         /* currently, only the client uses timeouts */
-        struct timeval tmptv = {0, timeout * 1000};
-        if(0 != setsockopt(connection->sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tmptv, sizeof(struct timeval))) {
+        int timeout_usec = timeout * 1000;
+        struct timeval tmptv = {timeout_usec / 1000000, timeout_usec % 1000000};
+        int ret = setsockopt(connection->sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tmptv, sizeof(struct timeval));
+        if(0 != ret) {
             UA_ByteString_deleteMembers(response);
             socket_close(connection);
             return UA_STATUSCODE_BADCONNECTIONCLOSED;

+ 1 - 1
src/ua_types.c

@@ -286,7 +286,7 @@ ExtensionObject_copy(UA_ExtensionObject const *src, UA_ExtensionObject *dst, con
 static void Variant_deletemembers(UA_Variant *p, const UA_DataType *_) {
     if(p->storageType != UA_VARIANT_DATA)
         return;
-    if(p->data >= UA_EMPTY_ARRAY_SENTINEL) {
+    if(p->data > UA_EMPTY_ARRAY_SENTINEL) {
         if(p->arrayLength == 0)
             p->arrayLength = 1;
         UA_Array_delete(p->data, p->arrayLength, p->type);