“beca52b61b3efd061dfff4e65407aa746c955f3d”上不存在“fs/rootfs/los_rootfs.c”
提交 5d7372c2 编写于 作者: dengyihao's avatar dengyihao

update ip str

上级 e7e627d6
...@@ -208,6 +208,27 @@ static void rpcUnlockConn(SRpcConn *pConn); ...@@ -208,6 +208,27 @@ static void rpcUnlockConn(SRpcConn *pConn);
static void rpcAddRef(SRpcInfo *pRpc); static void rpcAddRef(SRpcInfo *pRpc);
static void rpcDecRef(SRpcInfo *pRpc); static void rpcDecRef(SRpcInfo *pRpc);
static int ip2str(uint32_t ip, char *buf, int len) {
if (buf == NULL || len < 16) {
return -1;
}
uint8_t aByte = 0;
int offset = 0;
for (int i = 0; i < 4; i++) {
aByte = (ip & 0x000000FF);
offset += sprintf(&buf[offset], "%d", aByte);
if (3 == i) {
buf[offset] = '\0';
} else {
buf[offset++] = '.';
}
ip = ip >> 8;
}
return 0;
}
static bool rpcGenUID(uint32_t *first, uint32_t *second) { static bool rpcGenUID(uint32_t *first, uint32_t *second) {
static uint64_t hashId = 0; static uint64_t hashId = 0;
static uint32_t tranId = 0; static uint32_t tranId = 0;
...@@ -609,6 +630,9 @@ static SRpcConn *rpcOpenConn(SRpcInfo *pRpc, char *peerFqdn, uint16_t peerPort, ...@@ -609,6 +630,9 @@ static SRpcConn *rpcOpenConn(SRpcInfo *pRpc, char *peerFqdn, uint16_t peerPort,
return NULL; return NULL;
} }
char buf[32] = {0};
ip2str(peerIp, buf, sizeof(buf));
pConn = rpcAllocateClientConn(pRpc); pConn = rpcAllocateClientConn(pRpc);
if (pConn) { if (pConn) {
...@@ -622,7 +646,7 @@ static SRpcConn *rpcOpenConn(SRpcInfo *pRpc, char *peerFqdn, uint16_t peerPort, ...@@ -622,7 +646,7 @@ static SRpcConn *rpcOpenConn(SRpcInfo *pRpc, char *peerFqdn, uint16_t peerPort,
void *shandle = (connType & RPC_CONN_TCP) ? pRpc->tcphandle : pRpc->udphandle; void *shandle = (connType & RPC_CONN_TCP) ? pRpc->tcphandle : pRpc->udphandle;
pConn->chandle = (*taosOpenConn[connType])(shandle, pConn, pConn->peerIp, pConn->peerPort); pConn->chandle = (*taosOpenConn[connType])(shandle, pConn, pConn->peerIp, pConn->peerPort);
if (pConn->chandle == NULL) { if (pConn->chandle == NULL) {
tError("failed to connect to:0x%x:%d", pConn->peerIp, pConn->peerPort); tError("failed to connect to:%s:%d", buf, pConn->peerPort);
terrno = TSDB_CODE_RPC_NETWORK_UNAVAIL; terrno = TSDB_CODE_RPC_NETWORK_UNAVAIL;
rpcCloseConn(pConn); rpcCloseConn(pConn);
...@@ -1189,14 +1213,17 @@ static void *rpcProcessMsgFromPeer(SRecvInfo *pRecv) { ...@@ -1189,14 +1213,17 @@ static void *rpcProcessMsgFromPeer(SRecvInfo *pRecv) {
return pConn; return pConn;
} }
char buf[32] = {0};
ip2str(pRecv->ip, buf, sizeof(buf));
if (pHead->msgType >= 1 && pHead->msgType < TSDB_MSG_TYPE_MAX) { if (pHead->msgType >= 1 && pHead->msgType < TSDB_MSG_TYPE_MAX) {
tDebug("%s %p %p, %s received from 0x%x:%hu, parse code:0x%x len:%d sig:0x%08x:0x%08x:%d code:0x%x", pRpc->label, tDebug("%s %p %p, %s received from %s:%hu, parse code:0x%x len:%d sig:0x%08x:0x%08x:%d code:0x%x", pRpc->label,
pConn, (void *)pHead->ahandle, taosMsg[pHead->msgType], pRecv->ip, pRecv->port, terrno, pRecv->msgLen, pConn, (void *)pHead->ahandle, taosMsg[pHead->msgType], buf, pRecv->port, terrno, pRecv->msgLen,
pHead->sourceId, pHead->destId, pHead->tranId, pHead->code); pHead->sourceId, pHead->destId, pHead->tranId, pHead->code);
} else { } else {
tDebug("%s %p %p, %d received from 0x%x:%hu, parse code:0x%x len:%d sig:0x%08x:0x%08x:%d code:0x%x", pRpc->label, tDebug("%s %p %p, %d received from %s:%hu, parse code:0x%x len:%d sig:0x%08x:0x%08x:%d code:0x%x", pRpc->label,
pConn, (void *)pHead->ahandle, pHead->msgType, pRecv->ip, pRecv->port, terrno, pRecv->msgLen, pConn, (void *)pHead->ahandle, pHead->msgType, buf, pRecv->port, terrno, pRecv->msgLen, pHead->sourceId,
pHead->sourceId, pHead->destId, pHead->tranId, pHead->code); pHead->destId, pHead->tranId, pHead->code);
} }
int32_t code = terrno; int32_t code = terrno;
...@@ -1485,13 +1512,16 @@ static bool rpcSendMsgToPeer(SRpcConn *pConn, void *msg, int msgLen) { ...@@ -1485,13 +1512,16 @@ static bool rpcSendMsgToPeer(SRpcConn *pConn, void *msg, int msgLen) {
msgLen = rpcAddAuthPart(pConn, msg, msgLen); msgLen = rpcAddAuthPart(pConn, msg, msgLen);
char buf[32] = {0};
ip2str(pConn->peerIp, buf, sizeof(buf));
if (rpcIsReq(pHead->msgType)) { if (rpcIsReq(pHead->msgType)) {
tDebug("%s, %s is sent to %s:%hu, len:%d sig:0x%08x:0x%08x:%d", pConn->info, taosMsg[pHead->msgType], tDebug("%s, %s is sent to %s:%hu, len:%d sig:0x%08x:0x%08x:%d", pConn->info, taosMsg[pHead->msgType],
pConn->peerFqdn, pConn->peerPort, msgLen, pHead->sourceId, pHead->destId, pHead->tranId); pConn->peerFqdn, pConn->peerPort, msgLen, pHead->sourceId, pHead->destId, pHead->tranId);
} else { } else {
if (pHead->code == 0) pConn->secured = 1; // for success response, set link as secured if (pHead->code == 0) pConn->secured = 1; // for success response, set link as secured
tDebug("%s, %s is sent to 0x%x:%hu, code:0x%x len:%d sig:0x%08x:0x%08x:%d", pConn->info, taosMsg[pHead->msgType], tDebug("%s, %s is sent to %s:%hu, code:0x%x len:%d sig:0x%08x:0x%08x:%d", pConn->info, taosMsg[pHead->msgType], buf,
pConn->peerIp, pConn->peerPort, htonl(pHead->code), msgLen, pHead->sourceId, pHead->destId, pHead->tranId); pConn->peerPort, htonl(pHead->code), msgLen, pHead->sourceId, pHead->destId, pHead->tranId);
} }
// tTrace("connection type is: %d", pConn->connType); // tTrace("connection type is: %d", pConn->connType);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册