remove unnecessary debug

This commit is contained in:
wlyu 2022-03-31 14:03:27 +08:00
parent ec3939ff91
commit 267aacc9a3
2 changed files with 3 additions and 135 deletions

View File

@ -31,8 +31,9 @@ History:
1. Date: 2021-12-15 1. Date: 2021-12-15
Author: AIIT XUOS Lab Author: AIIT XUOS Lab
Modification: Modification:
1. added debug 1. added debug information for locate
2. fixed bug to free twice when receiveResponse timeout 2. avoid calling client NEW at same time
3. fixed the bug of free twice when receiveResponse timeout
*************************************************/ *************************************************/
#ifndef UA_DYNAMIC_LINKING_EXPORT #ifndef UA_DYNAMIC_LINKING_EXPORT
@ -7496,9 +7497,6 @@ Array_encodeBinary(const void *src, size_t length, const UA_DataType *type, Ctx
} }
UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED); UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
ua_debug1("ua: [%s] src %p len %d %d type %p <%d> <%d> %p ret %d\n", __func__,
src, length, signed_length, *type, type->typeKind, type->overlayable, ctx, ret);
return ret; return ret;
} }
@ -8343,24 +8341,9 @@ encodeBinaryStruct(const void *src, const UA_DataType *type, Ctx *ctx) {
if(mt->typeKind > UA_DATATYPEKINDS) if(mt->typeKind > UA_DATATYPEKINDS)
{ {
ua_debug("ua: [%s] %d type %d %p ptr %p failed\n", __func__, i, mt->typeKind, m->memberType, ptr);
return ret; return ret;
} }
ua_debug1("ua: [%s] > %d < %d mt %p %d %d dep %d msg %p %p:<%x> <%d> isArry %d ret %d\n", __func__,
i,
type->membersSize,
mt,
mt->typeKind,
mt->memSize,
ctx->depth,
ptr,
src,
((UA_TcpMessageHeader *)src)->messageTypeAndChunkType,
((UA_TcpMessageHeader *)src)->messageSize,
m->isArray,
ret);
/* Array. Buffer-exchange is done inside Array_encodeBinary if required. */ /* Array. Buffer-exchange is done inside Array_encodeBinary if required. */
if(m->isArray) { if(m->isArray) {
const size_t length = *((const size_t*)ptr); const size_t length = *((const size_t*)ptr);
@ -8375,20 +8358,6 @@ encodeBinaryStruct(const void *src, const UA_DataType *type, Ctx *ctx) {
ret = encodeWithExchangeBuffer((const void*)ptr, mt, ctx); ret = encodeWithExchangeBuffer((const void*)ptr, mt, ctx);
UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED); UA_assert(ret != UA_STATUSCODE_BADENCODINGLIMITSEXCEEDED);
ua_debug1("ua: [%s] >> %d < %d mt %p %d %d dep %d msg %p %p:<%x> <%d> isArry %d ret %d\n", __func__,
i,
type->membersSize,
mt,
mt->typeKind,
mt->memSize,
ctx->depth,
ptr,
src,
((UA_TcpMessageHeader *)src)->messageTypeAndChunkType,
((UA_TcpMessageHeader *)src)->messageSize,
m->isArray,
ret);
ptr += mt->memSize; ptr += mt->memSize;
} }
@ -8627,68 +8596,23 @@ decodeBinaryStructure(void *dst, const UA_DataType *type, Ctx *ctx) {
if(mt->typeKind >= UA_DATATYPEKINDS) if(mt->typeKind >= UA_DATATYPEKINDS)
{ {
ua_debug1("ua: [%s] fail %d < %d mt %p %d %d dep %d msg %p %p:<%x> <%d>\n", __func__,
i,
membersSize,
mt,
mt->typeKind,
mt->memSize,
ctx->depth,
ptr,
dst,
((UA_TcpMessageHeader *)dst)->messageTypeAndChunkType,
((UA_TcpMessageHeader *)dst)->messageSize);
return ret; return ret;
} }
ua_debug1("ua: [%s] > %d < %d mt %p %d %d dep %d msg %p %p:<%x> <%d> isArry %d ret %d\n", __func__,
i,
membersSize,
mt,
mt->typeKind,
mt->memSize,
ctx->depth,
ptr,
dst,
((UA_TcpMessageHeader *)dst)->messageTypeAndChunkType,
((UA_TcpMessageHeader *)dst)->messageSize,
m->isArray,
ret);
/* Array */ /* Array */
if(m->isArray) { if(m->isArray) {
size_t *length = (size_t*)ptr; size_t *length = (size_t*)ptr;
ptr += sizeof(size_t); ptr += sizeof(size_t);
ret = Array_decodeBinary((void *UA_RESTRICT *UA_RESTRICT)ptr, length, mt , ctx); ret = Array_decodeBinary((void *UA_RESTRICT *UA_RESTRICT)ptr, length, mt , ctx);
ptr += sizeof(void*); ptr += sizeof(void*);
ua_debug1("ua: [%s] %d ret %d ptr %p len %d\n", __func__, i, ret, ptr, length);
continue; continue;
} }
/* Scalar */ /* Scalar */
ret = decodeBinaryJumpTable[mt->typeKind]((void *UA_RESTRICT)ptr, mt, ctx); ret = decodeBinaryJumpTable[mt->typeKind]((void *UA_RESTRICT)ptr, mt, ctx);
ptr += mt->memSize; ptr += mt->memSize;
ua_debug1("ua: [%s] >> %d < %d dep %d msg %p %p:<%x> <%d> ret %d\n", __func__,
i,
membersSize,
ctx->depth,
ptr,
dst,
((UA_TcpMessageHeader *)dst)->messageTypeAndChunkType,
((UA_TcpMessageHeader *)dst)->messageSize,
ret);
} }
ua_debug1("ua: [%s] >>> dep %d msg %p %p:<%x> <%d> ret %d\n", __func__,
ctx->depth,
ptr,
dst,
((UA_TcpMessageHeader *)dst)->messageTypeAndChunkType,
((UA_TcpMessageHeader *)dst)->messageSize,
ret);
ctx->depth--; ctx->depth--;
return ret; return ret;
} }
@ -8831,17 +8755,8 @@ UA_decodeBinaryInternal(const UA_ByteString *src, size_t *offset,
/* Decode */ /* Decode */
memset(dst, 0, type->memSize); /* Initialize the value */ memset(dst, 0, type->memSize); /* Initialize the value */
ua_debug1("ua: [%s] t %d mem %d len %d off %d pos %d end %d dst %p type %x size %x\n", __func__,
type->typeKind, type->memSize, src->length, *offset, *ctx.pos, *ctx.end,
dst, ((UA_TcpMessageHeader *)dst)->messageTypeAndChunkType,
((UA_TcpMessageHeader *)dst)->messageSize);
status ret = decodeBinaryJumpTable[type->typeKind](dst, type, &ctx); status ret = decodeBinaryJumpTable[type->typeKind](dst, type, &ctx);
ua_debug1("ua: [%s] -> t %d dst %p type %x size %x ret %d\n", __func__,
type->typeKind, dst, ((UA_TcpMessageHeader *)dst)->messageTypeAndChunkType,
((UA_TcpMessageHeader *)dst)->messageSize, ret);
if(UA_LIKELY(ret == UA_STATUSCODE_GOOD)) { if(UA_LIKELY(ret == UA_STATUSCODE_GOOD)) {
/* Set the new offset */ /* Set the new offset */
*offset = (size_t)(ctx.pos - src->data) / sizeof(u8); *offset = (size_t)(ctx.pos - src->data) / sizeof(u8);
@ -8849,16 +8764,8 @@ UA_decodeBinaryInternal(const UA_ByteString *src, size_t *offset,
/* Clean up */ /* Clean up */
UA_clear(dst, type); UA_clear(dst, type);
memset(dst, 0, type->memSize); memset(dst, 0, type->memSize);
ua_debug1("ua: [%s] => t %d dst %p type %x size %x\n", __func__,
type->typeKind, dst, ((UA_TcpMessageHeader *)dst)->messageTypeAndChunkType,
((UA_TcpMessageHeader *)dst)->messageSize);
} }
ua_debug1("ua: [%s] #> off %d %p %p t %d dst %p type %x size %x\n", __func__, *offset,
ctx.pos, src->data,
type->typeKind, dst, ((UA_TcpMessageHeader *)dst)->messageTypeAndChunkType,
((UA_TcpMessageHeader *)dst)->messageSize);
return ret; return ret;
} }
@ -18631,12 +18538,6 @@ processChunks(UA_SecureChannel *channel, void *application,
channel->decryptedChunksCount > channel->config.localMaxChunkCount) || channel->decryptedChunksCount > channel->config.localMaxChunkCount) ||
(channel->config.localMaxMessageSize != 0 && (channel->config.localMaxMessageSize != 0 &&
channel->decryptedChunksLength > channel->config.localMaxMessageSize)) { channel->decryptedChunksLength > channel->config.localMaxMessageSize)) {
ua_print("ua: [%s] count %d max %d len %d mess %d\n",
channel->decryptedChunksCount,
channel->config.localMaxChunkCount,
channel->decryptedChunksLength,
channel->config.localMaxMessageSize
);
return UA_STATUSCODE_BADTCPMESSAGETOOLARGE; return UA_STATUSCODE_BADTCPMESSAGETOOLARGE;
} }
@ -18674,9 +18575,6 @@ extractCompleteChunk(UA_SecureChannel *channel, const UA_ByteString *buffer,
UA_decodeBinaryInternal(buffer, &initial_offset, &hdr, UA_decodeBinaryInternal(buffer, &initial_offset, &hdr,
&UA_TRANSPORT[UA_TRANSPORT_TCPMESSAGEHEADER], NULL); &UA_TRANSPORT[UA_TRANSPORT_TCPMESSAGEHEADER], NULL);
ua_debug1("ua: [%s] res %d buf %p offset %d hdr %d size %d\n", __func__, res, buffer, *offset,
hdr.messageTypeAndChunkType, hdr.messageSize);
UA_assert(res == UA_STATUSCODE_GOOD); UA_assert(res == UA_STATUSCODE_GOOD);
(void)res; /* pacify compilers if assert is ignored */ (void)res; /* pacify compilers if assert is ignored */
UA_MessageType msgType = (UA_MessageType) UA_MessageType msgType = (UA_MessageType)
@ -18689,7 +18587,6 @@ extractCompleteChunk(UA_SecureChannel *channel, const UA_ByteString *buffer,
return UA_STATUSCODE_BADTCPMESSAGETYPEINVALID; return UA_STATUSCODE_BADTCPMESSAGETYPEINVALID;
if(hdr.messageSize > channel->config.recvBufferSize) if(hdr.messageSize > channel->config.recvBufferSize)
{ {
ua_debug1("lw: [%s] msg size %d rec %d\n", __func__, hdr.messageSize, channel->config.recvBufferSize);
return UA_STATUSCODE_BADTCPMESSAGETOOLARGE; return UA_STATUSCODE_BADTCPMESSAGETOOLARGE;
} }
@ -45217,11 +45114,6 @@ connectIterate(UA_Client *client, UA_UInt32 timeout) {
client->connectStatus = client->connectStatus =
client->config.pollConnectionFunc(&client->connection, timeout, client->config.pollConnectionFunc(&client->connection, timeout,
&client->config.logger); &client->config.logger);
ua_debug1("ua: [%s] exit conn %x %d time %d handle %p\n", __func__,
client->connectStatus,
client->connection.state, timeout, client->connection.handle);
return client->connectStatus; return client->connectStatus;
} }
@ -45380,8 +45272,6 @@ initConnect(UA_Client *client) {
(int)client->endpointUrl.length, client->endpointUrl.data); (int)client->endpointUrl.length, client->endpointUrl.data);
client->connectStatus = UA_STATUSCODE_BADCONNECTIONCLOSED; client->connectStatus = UA_STATUSCODE_BADCONNECTIONCLOSED;
closeSecureChannel(client); closeSecureChannel(client);
ua_debug("ua: [%s] connect %d failed timeout %d\n", __func__, client->connection.state,
client->config.timeout);
} }
return client->connectStatus; return client->connectStatus;
@ -45418,8 +45308,6 @@ connectSync(UA_Client *client) {
UA_DateTime now = UA_DateTime_nowMonotonic(); UA_DateTime now = UA_DateTime_nowMonotonic();
UA_DateTime maxDate = now + ((UA_DateTime)client->config.timeout * UA_DATETIME_MSEC); UA_DateTime maxDate = now + ((UA_DateTime)client->config.timeout * UA_DATETIME_MSEC);
ua_debug("ua: [%s] time %d\n", __func__, (UA_DateTime)client->config.timeout);
UA_StatusCode retval = initConnect(client); UA_StatusCode retval = initConnect(client);
if(retval != UA_STATUSCODE_GOOD) if(retval != UA_STATUSCODE_GOOD)
return retval; return retval;
@ -71238,7 +71126,6 @@ ServerNetworkLayerTCP_add(UA_ServerNetworkLayer *nl, ServerNetworkLayerTCP *laye
static UA_StatusCode static UA_StatusCode
addServerSocket(ServerNetworkLayerTCP *layer, struct addrinfo *ai) { addServerSocket(ServerNetworkLayerTCP *layer, struct addrinfo *ai) {
/* Create the server socket */ /* Create the server socket */
ua_print("ua: [%s] %d %d %d\n", __func__, ai->ai_family, ai->ai_socktype, ai->ai_protocol);
UA_SOCKET newsock = UA_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); UA_SOCKET newsock = UA_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if(newsock == UA_INVALID_SOCKET) if(newsock == UA_INVALID_SOCKET)
{ {
@ -71374,18 +71261,12 @@ ServerNetworkLayerTCP_start(UA_ServerNetworkLayer *nl, const UA_Logger *logger,
int retcode = UA_getaddrinfo(customHostname->length ? hostname : NULL, int retcode = UA_getaddrinfo(customHostname->length ? hostname : NULL,
portno, &hints, &res); portno, &hints, &res);
ua_print("ua: [%s] host %s pro %d ret %d\n", __func__, hostname, portno, retcode);
if(retcode != 0) { if(retcode != 0) {
UA_LOG_SOCKET_ERRNO_GAI_WRAP(UA_LOG_WARNING(layer->logger, UA_LOGCATEGORY_NETWORK, UA_LOG_SOCKET_ERRNO_GAI_WRAP(UA_LOG_WARNING(layer->logger, UA_LOGCATEGORY_NETWORK,
"getaddrinfo lookup of %s failed with error %d - %s", hostname, retcode, errno_str)); "getaddrinfo lookup of %s failed with error %d - %s", hostname, retcode, errno_str));
return UA_STATUSCODE_BADINTERNALERROR; return UA_STATUSCODE_BADINTERNALERROR;
} }
ua_print("ua: [%s] res %p fam %d len %d %s\n", __func__, res, res->ai_family,
customHostname->length,
customHostname->data);
/* There might be serveral addrinfos (for different network cards, /* There might be serveral addrinfos (for different network cards,
* IPv4/IPv6). Add a server socket for all of them. */ * IPv4/IPv6). Add a server socket for all of them. */
struct addrinfo *ai = res; struct addrinfo *ai = res;
@ -71676,10 +71557,6 @@ UA_ClientConnectionTCP_poll(UA_Connection *connection, UA_UInt32 timeout,
return UA_STATUSCODE_BADDISCONNECT; return UA_STATUSCODE_BADDISCONNECT;
} }
ua_print("ua: [%s] conn handle %p fam %d sa %d\n", __func__,
connection->handle, tcpConnection->server->ai_family,
tcpConnection->server->ai_addr->sa_family);
/* Get a socket and connect (only once) if not already done in a previous /* Get a socket and connect (only once) if not already done in a previous
* call. On win32, calling connect multiple times is not recommended on * call. On win32, calling connect multiple times is not recommended on
* non-blocking sockets * non-blocking sockets
@ -71701,12 +71578,6 @@ UA_ClientConnectionTCP_poll(UA_Connection *connection, UA_UInt32 timeout,
return UA_STATUSCODE_BADDISCONNECT; return UA_STATUSCODE_BADDISCONNECT;
} }
ua_print("ua: [%s] socket fd %d %p fam %d sa %d\n", __func__,
connection->sockfd,
tcpConnection->server,
tcpConnection->server->ai_family,
tcpConnection->server->ai_addr->sa_family);
/* Non blocking connect to be able to timeout */ /* Non blocking connect to be able to timeout */
if(UA_socket_set_nonblocking(connection->sockfd) != UA_STATUSCODE_GOOD) { if(UA_socket_set_nonblocking(connection->sockfd) != UA_STATUSCODE_GOOD) {
UA_LOG_WARNING(logger, UA_LOGCATEGORY_NETWORK, UA_LOG_WARNING(logger, UA_LOGCATEGORY_NETWORK,
@ -71732,7 +71603,6 @@ UA_ClientConnectionTCP_poll(UA_Connection *connection, UA_UInt32 timeout,
connection->state = UA_CONNECTIONSTATE_ESTABLISHED; connection->state = UA_CONNECTIONSTATE_ESTABLISHED;
return UA_STATUSCODE_GOOD; return UA_STATUSCODE_GOOD;
} }
ua_print("ua: [%s] connected failed %d\n", __func__, error);
/* The connection failed */ /* The connection failed */
if((UA_ERRNO != UA_ERR_CONNECTION_PROGRESS)) { if((UA_ERRNO != UA_ERR_CONNECTION_PROGRESS)) {

View File

@ -43,9 +43,7 @@ typedef struct UaParam
#define ua_print //KPrintf #define ua_print //KPrintf
#define ua_notice KPrintf #define ua_notice KPrintf
#define ua_debug //KPrintf
#define ua_error KPrintf #define ua_error KPrintf
#define ua_debug1
extern const char *opc_server_url; extern const char *opc_server_url;
extern char test_ua_ip[]; extern char test_ua_ip[];