Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c4295e1b
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c4295e1b
编写于
2月 06, 2023
作者:
D
dapan1121
提交者:
GitHub
2月 06, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19779 from taosdata/fix/hostShutDown
fix: no resp when host machine shutdown
上级
8ef83620
121afc60
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
39 addition
and
15 deletion
+39
-15
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+24
-5
source/libs/transport/src/transComm.c
source/libs/transport/src/transComm.c
+4
-0
source/os/src/osSocket.c
source/os/src/osSocket.c
+11
-10
未找到文件。
source/libs/transport/src/transCli.c
浏览文件 @
c4295e1b
...
...
@@ -671,7 +671,7 @@ static SCliConn* cliCreateConn(SCliThrd* pThrd) {
conn
->
stream
=
(
uv_stream_t
*
)
taosMemoryMalloc
(
sizeof
(
uv_tcp_t
));
uv_tcp_init
(
pThrd
->
loop
,
(
uv_tcp_t
*
)(
conn
->
stream
));
conn
->
stream
->
data
=
conn
;
transSetConnOption
((
uv_tcp_t
*
)
conn
->
stream
);
//
transSetConnOption((uv_tcp_t*)conn->stream);
uv_timer_t
*
timer
=
taosArrayGetSize
(
pThrd
->
timerList
)
>
0
?
*
(
uv_timer_t
**
)
taosArrayPop
(
pThrd
->
timerList
)
:
NULL
;
if
(
timer
==
NULL
)
{
...
...
@@ -1067,9 +1067,10 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
STransConnCtx
*
pCtx
=
pMsg
->
ctx
;
cliMayCvtFqdnToIp
(
&
pCtx
->
epSet
,
&
pThrd
->
cvtAddr
);
STraceId
*
trace
=
&
pMsg
->
msg
.
info
.
traceId
;
if
(
!
EPSET_IS_VALID
(
&
pCtx
->
epSet
))
{
t
Error
(
"invalid epset"
);
t
GError
(
"%s, msg %s sent with invalid epset"
,
pTransInst
->
label
,
TMSG_INFO
(
pMsg
->
msg
.
msgType
)
);
destroyCmsg
(
pMsg
);
return
;
}
...
...
@@ -1138,10 +1139,29 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
addr
.
sin_addr
.
s_addr
=
ipaddr
;
addr
.
sin_port
=
(
uint16_t
)
htons
((
uint16_t
)
conn
->
port
);
STraceId
*
trace
=
&
(
pMsg
->
msg
.
info
.
traceId
);
tGTrace
(
"%s conn %p try to connect to %s:%d"
,
pTransInst
->
label
,
conn
,
conn
->
ip
,
conn
->
port
);
int32_t
fd
=
taosCreateSocketWithTimeout
(
TRANS_CONN_TIMEOUT
*
4
);
if
(
fd
==
-
1
)
{
tGError
(
"%s conn %p failed to create socket, reason:%s"
,
transLabel
(
pTransInst
),
conn
,
tstrerror
(
TAOS_SYSTEM_ERROR
(
errno
)));
cliHandleExcept
(
conn
);
errno
=
0
;
return
;
}
int
ret
=
uv_tcp_open
((
uv_tcp_t
*
)
conn
->
stream
,
fd
);
if
(
ret
!=
0
)
{
tGError
(
"%s conn %p failed to set stream, reason:%s"
,
transLabel
(
pTransInst
),
conn
,
uv_err_name
(
ret
));
cliHandleExcept
(
conn
);
return
;
}
ret
=
transSetConnOption
((
uv_tcp_t
*
)
conn
->
stream
);
if
(
ret
!=
0
)
{
tGError
(
"%s conn %p failed to set socket opt, reason:%s"
,
transLabel
(
pTransInst
),
conn
,
uv_err_name
(
ret
));
cliHandleExcept
(
conn
);
return
;
}
int
ret
=
uv_tcp_connect
(
&
conn
->
connReq
,
(
uv_tcp_t
*
)(
conn
->
stream
),
(
const
struct
sockaddr
*
)
&
addr
,
cliConnCb
);
ret
=
uv_tcp_connect
(
&
conn
->
connReq
,
(
uv_tcp_t
*
)(
conn
->
stream
),
(
const
struct
sockaddr
*
)
&
addr
,
cliConnCb
);
if
(
ret
!=
0
)
{
tGError
(
"%s conn %p failed to connect to %s:%d, reason:%s"
,
pTransInst
->
label
,
conn
,
conn
->
ip
,
conn
->
port
,
uv_err_name
(
ret
));
...
...
@@ -1156,7 +1176,6 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
}
uv_timer_start
(
conn
->
timer
,
cliConnTimeout
,
TRANS_CONN_TIMEOUT
,
0
);
}
STraceId
*
trace
=
&
pMsg
->
msg
.
info
.
traceId
;
tGTrace
(
"%s conn %p ready"
,
pTransInst
->
label
,
conn
);
}
static
void
cliAsyncCb
(
uv_async_t
*
handle
)
{
...
...
source/libs/transport/src/transComm.c
浏览文件 @
c4295e1b
...
...
@@ -205,6 +205,10 @@ bool transReadComplete(SConnBuffer* connBuf) {
}
int
transSetConnOption
(
uv_tcp_t
*
stream
)
{
#if defined(WINDOWS) || defined(DARWIN)
#else
uv_tcp_keepalive
(
stream
,
1
,
20
);
#endif
return
uv_tcp_nodelay
(
stream
,
1
);
// int ret = uv_tcp_keepalive(stream, 5, 60);
}
...
...
source/os/src/osSocket.c
浏览文件 @
c4295e1b
...
...
@@ -55,7 +55,7 @@ typedef struct TdSocket {
#endif
int
refId
;
SocketFd
fd
;
}
*
TdSocketPtr
,
TdSocket
;
}
*
TdSocketPtr
,
TdSocket
;
typedef
struct
TdSocketServer
{
#if SOCKET_WITH_LOCK
...
...
@@ -63,7 +63,7 @@ typedef struct TdSocketServer {
#endif
int
refId
;
SocketFd
fd
;
}
*
TdSocketServerPtr
,
TdSocketServer
;
}
*
TdSocketServerPtr
,
TdSocketServer
;
typedef
struct
TdEpoll
{
#if SOCKET_WITH_LOCK
...
...
@@ -71,7 +71,7 @@ typedef struct TdEpoll {
#endif
int
refId
;
EpollFd
fd
;
}
*
TdEpollPtr
,
TdEpoll
;
}
*
TdEpollPtr
,
TdEpoll
;
#if 0
int32_t taosSendto(TdSocketPtr pSocket, void *buf, int len, unsigned int flags, const struct sockaddr *dest_addr,
...
...
@@ -1005,7 +1005,7 @@ int32_t taosGetFqdn(char *fqdn) {
// immediately
// hints.ai_family = AF_INET;
strcpy
(
fqdn
,
hostname
);
strcpy
(
fqdn
+
strlen
(
hostname
),
".local"
);
strcpy
(
fqdn
+
strlen
(
hostname
),
".local"
);
#else // __APPLE__
struct
addrinfo
hints
=
{
0
};
struct
addrinfo
*
result
=
NULL
;
...
...
@@ -1060,7 +1060,7 @@ int32_t taosCreateSocketWithTimeout(uint32_t timeout) {
#if defined(WINDOWS)
SOCKET
fd
;
#else
int
fd
;
int
fd
;
#endif
if
((
fd
=
socket
(
PF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
))
==
INVALID_SOCKET
)
{
return
-
1
;
...
...
@@ -1071,11 +1071,12 @@ int32_t taosCreateSocketWithTimeout(uint32_t timeout) {
return
-
1
;
}
#elif defined(_TD_DARWIN_64)
uint32_t
conn_timeout_ms
=
timeout
*
1000
;
if
(
0
!=
setsockopt
(
fd
,
IPPROTO_TCP
,
TCP_CONNECTIONTIMEOUT
,
(
char
*
)
&
conn_timeout_ms
,
sizeof
(
conn_timeout_ms
)))
{
taosCloseSocketNoCheck1
(
fd
);
return
-
1
;
}
// invalid config
// uint32_t conn_timeout_ms = timeout * 1000;
// if (0 != setsockopt(fd, IPPROTO_TCP, TCP_CONNECTIONTIMEOUT, (char *)&conn_timeout_ms, sizeof(conn_timeout_ms))) {
// taosCloseSocketNoCheck1(fd);
// return -1;
//}
#else // Linux like systems
uint32_t
conn_timeout_ms
=
timeout
*
1000
;
if
(
0
!=
setsockopt
(
fd
,
IPPROTO_TCP
,
TCP_USER_TIMEOUT
,
(
char
*
)
&
conn_timeout_ms
,
sizeof
(
conn_timeout_ms
)))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录