Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3df82b4d
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3df82b4d
编写于
7月 23, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feactor debug log
上级
a0e8b11d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
24 deletion
+36
-24
source/libs/transport/inc/transComm.h
source/libs/transport/inc/transComm.h
+2
-0
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+3
-4
source/libs/transport/src/transComm.c
source/libs/transport/src/transComm.c
+7
-0
source/libs/transport/src/transSvr.c
source/libs/transport/src/transSvr.c
+24
-20
未找到文件。
source/libs/transport/inc/transComm.h
浏览文件 @
3df82b4d
...
...
@@ -300,6 +300,8 @@ int transSendResponse(const STransMsg* msg);
int
transRegisterMsg
(
const
STransMsg
*
msg
);
int
transSetDefaultAddr
(
void
*
shandle
,
const
char
*
ip
,
const
char
*
fqdn
);
int
transGetSockDebugInfo
(
struct
sockaddr
*
sockname
,
char
*
dst
);
int64_t
transAllocHandle
();
void
*
transInitServer
(
uint32_t
ip
,
uint32_t
port
,
char
*
label
,
int
numOfThreads
,
void
*
fp
,
void
*
shandle
);
...
...
source/libs/transport/src/transCli.c
浏览文件 @
3df82b4d
...
...
@@ -37,12 +37,11 @@ typedef struct SCliConn {
uint32_t
port
;
SDelayTask
*
task
;
// debug and log info
char
src
[
32
];
char
dst
[
32
];
// struct sockaddr addr;
// struct sockaddr localAddr;
}
SCliConn
;
typedef
struct
SCliMsg
{
...
...
@@ -775,11 +774,11 @@ void cliConnCb(uv_connect_t* req, int status) {
int
addrlen
=
sizeof
(
peername
);
uv_tcp_getpeername
((
uv_tcp_t
*
)
pConn
->
stream
,
&
peername
,
&
addrlen
);
s
ockDebugInfo
(
&
peername
,
pConn
->
dst
);
transGetS
ockDebugInfo
(
&
peername
,
pConn
->
dst
);
addrlen
=
sizeof
(
sockname
);
uv_tcp_getsockname
((
uv_tcp_t
*
)
pConn
->
stream
,
&
sockname
,
&
addrlen
);
s
ockDebugInfo
(
&
sockname
,
pConn
->
src
);
transGetS
ockDebugInfo
(
&
sockname
,
pConn
->
src
);
tTrace
(
"%s conn %p connect to server successfully"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
);
assert
(
pConn
->
stream
==
req
->
handle
);
...
...
source/libs/transport/src/transComm.c
浏览文件 @
3df82b4d
...
...
@@ -102,7 +102,14 @@ void transFreeMsg(void* msg) {
}
taosMemoryFree
((
char
*
)
msg
-
sizeof
(
STransMsgHead
));
}
int
transGetSockDebugInfo
(
struct
sockaddr
*
sockname
,
char
*
dst
)
{
struct
sockaddr_in
addr
=
*
(
struct
sockaddr_in
*
)
sockname
;
char
buf
[
20
]
=
{
0
};
int
r
=
uv_ip4_name
(
&
addr
,
(
char
*
)
buf
,
sizeof
(
buf
));
sprintf
(
dst
,
"%s:%d"
,
buf
,
ntohs
(
addr
.
sin_port
));
return
r
;
}
int
transInitBuffer
(
SConnBuffer
*
buf
)
{
transClearBuffer
(
buf
);
return
0
;
...
...
source/libs/transport/src/transSvr.c
浏览文件 @
3df82b4d
...
...
@@ -43,9 +43,13 @@ typedef struct SSvrConn {
SSvrRegArg
regArg
;
bool
broken
;
// conn broken;
ConnStatus
status
;
struct
sockaddr_in
addr
;
struct
sockaddr_in
localAddr
;
ConnStatus
status
;
uint32_t
clientIp
;
uint16_t
port
;
char
src
[
32
];
char
dst
[
32
];
int64_t
refId
;
int
spi
;
...
...
@@ -247,15 +251,11 @@ static void uvHandleReq(SSvrConn* pConn) {
if
(
pConn
->
status
==
ConnNormal
&&
pHead
->
noResp
==
0
)
{
transRefSrvHandle
(
pConn
);
tGTrace
(
"%s conn %p %s received from %s:%d, local info:%s:%d, msg size:%d"
,
transLabel
(
pTransInst
),
pConn
,
TMSG_INFO
(
transMsg
.
msgType
),
taosInetNtoa
(
pConn
->
addr
.
sin_addr
),
ntohs
(
pConn
->
addr
.
sin_port
),
taosInetNtoa
(
pConn
->
localAddr
.
sin_addr
),
ntohs
(
pConn
->
localAddr
.
sin_port
),
transMsg
.
contLen
);
tGTrace
(
"%s conn %p %s received from %s, local info:%s, msg size:%d"
,
transLabel
(
pTransInst
),
pConn
,
TMSG_INFO
(
transMsg
.
msgType
),
pConn
->
dst
,
pConn
->
src
,
transMsg
.
contLen
);
}
else
{
tGTrace
(
"%s conn %p %s received from %s:%d, local info:%s:%d, msg size:%d, resp:%d, code:%d"
,
transLabel
(
pTransInst
),
pConn
,
TMSG_INFO
(
transMsg
.
msgType
),
taosInetNtoa
(
pConn
->
addr
.
sin_addr
),
ntohs
(
pConn
->
addr
.
sin_port
),
taosInetNtoa
(
pConn
->
localAddr
.
sin_addr
),
ntohs
(
pConn
->
localAddr
.
sin_port
),
transMsg
.
contLen
,
pHead
->
noResp
,
transMsg
.
code
);
// no ref here
transLabel
(
pTransInst
),
pConn
,
pConn
->
dst
,
pConn
->
src
,
transMsg
.
contLen
,
pHead
->
noResp
,
transMsg
.
code
);
}
// pHead->noResp = 1,
...
...
@@ -277,14 +277,13 @@ static void uvHandleReq(SSvrConn* pConn) {
// set up conn info
SRpcConnInfo
*
pConnInfo
=
&
(
transMsg
.
info
.
conn
);
pConnInfo
->
clientIp
=
(
uint32_t
)(
pConn
->
addr
.
sin_addr
.
s_addr
)
;
pConnInfo
->
clientPort
=
ntohs
(
pConn
->
addr
.
sin_port
)
;
pConnInfo
->
clientIp
=
pConn
->
clientIp
;
pConnInfo
->
clientPort
=
pConn
->
port
;
tstrncpy
(
pConnInfo
->
user
,
pConn
->
user
,
sizeof
(
pConnInfo
->
user
));
transReleaseExHandle
(
transGetRefMgt
(),
pConn
->
refId
);
(
*
pTransInst
->
cfp
)(
pTransInst
->
parent
,
&
transMsg
,
NULL
);
// uv_timer_start(&pConn->pTimer, uvHandleActivityTimeout, pRpc->idleTime * 10000, 0);
}
void
uvOnRecvCb
(
uv_stream_t
*
cli
,
ssize_t
nread
,
const
uv_buf_t
*
buf
)
{
...
...
@@ -417,9 +416,8 @@ static void uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) {
STrans
*
pTransInst
=
pConn
->
pTransInst
;
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
tGTrace
(
"%s conn %p %s is sent to %s:%d, local info:%s:%d, msglen:%d"
,
transLabel
(
pTransInst
),
pConn
,
TMSG_INFO
(
pHead
->
msgType
),
taosInetNtoa
(
pConn
->
addr
.
sin_addr
),
ntohs
(
pConn
->
addr
.
sin_port
),
taosInetNtoa
(
pConn
->
localAddr
.
sin_addr
),
ntohs
(
pConn
->
localAddr
.
sin_port
),
len
);
tGTrace
(
"%s conn %p %s is sent to %s, local info:%s, msglen:%d"
,
transLabel
(
pTransInst
),
pConn
,
TMSG_INFO
(
pHead
->
msgType
),
pConn
->
dst
,
pConn
->
src
,
len
);
pHead
->
msgLen
=
htonl
(
len
);
wb
->
base
=
msg
;
...
...
@@ -645,20 +643,26 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) {
uv_fileno
((
const
uv_handle_t
*
)
pConn
->
pTcp
,
&
fd
);
tTrace
(
"conn %p created, fd:%d"
,
pConn
,
fd
);
int
addrlen
=
sizeof
(
pConn
->
addr
);
if
(
0
!=
uv_tcp_getpeername
(
pConn
->
pTcp
,
(
struct
sockaddr
*
)
&
pConn
->
addr
,
&
addrlen
))
{
struct
sockaddr
peername
,
sockname
;
int
addrlen
=
sizeof
(
peername
);
if
(
0
!=
uv_tcp_getpeername
(
pConn
->
pTcp
,
(
struct
sockaddr
*
)
&
peername
,
&
addrlen
))
{
tError
(
"conn %p failed to get peer info"
,
pConn
);
transUnrefSrvHandle
(
pConn
);
return
;
}
transGetSockDebugInfo
(
&
peername
,
pConn
->
dst
);
addrlen
=
sizeof
(
pConn
->
localAddr
);
if
(
0
!=
uv_tcp_getsockname
(
pConn
->
pTcp
,
(
struct
sockaddr
*
)
&
pConn
->
localAddr
,
&
addrlen
))
{
addrlen
=
sizeof
(
sockname
);
if
(
0
!=
uv_tcp_getsockname
(
pConn
->
pTcp
,
(
struct
sockaddr
*
)
&
sockname
,
&
addrlen
))
{
tError
(
"conn %p failed to get local info"
,
pConn
);
transUnrefSrvHandle
(
pConn
);
return
;
}
transGetSockDebugInfo
(
&
sockname
,
pConn
->
src
);
struct
sockaddr_in
addr
=
*
(
struct
sockaddr_in
*
)
&
sockname
;
pConn
->
clientIp
=
addr
.
sin_addr
.
s_addr
;
pConn
->
port
=
ntohs
(
addr
.
sin_port
);
uv_read_start
((
uv_stream_t
*
)(
pConn
->
pTcp
),
uvAllocRecvBufferCb
,
uvOnRecvCb
);
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录