Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9a5db032
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
9a5db032
编写于
10月 09, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
opt log time
上级
1af09ec9
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
36 addition
and
10 deletion
+36
-10
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+33
-9
source/os/src/osTime.c
source/os/src/osTime.c
+3
-1
未找到文件。
source/libs/transport/src/transCli.c
浏览文件 @
9a5db032
...
@@ -79,6 +79,7 @@ typedef struct SCliThrd {
...
@@ -79,6 +79,7 @@ typedef struct SCliThrd {
uint64_t
nextTimeout
;
// next timeout
uint64_t
nextTimeout
;
// next timeout
void
*
pTransInst
;
//
void
*
pTransInst
;
//
SHashObj
*
fqdn2ipCache
;
SCvtAddr
cvtAddr
;
SCvtAddr
cvtAddr
;
SCliMsg
*
stopMsg
;
SCliMsg
*
stopMsg
;
...
@@ -135,6 +136,9 @@ static FORCE_INLINE void cliMayCvtFqdnToIp(SEpSet* pEpSet, SCvtAddr* pCvtAddr);
...
@@ -135,6 +136,9 @@ static FORCE_INLINE void cliMayCvtFqdnToIp(SEpSet* pEpSet, SCvtAddr* pCvtAddr);
static
FORCE_INLINE
int32_t
cliBuildExceptResp
(
SCliMsg
*
pMsg
,
STransMsg
*
resp
);
static
FORCE_INLINE
int32_t
cliBuildExceptResp
(
SCliMsg
*
pMsg
,
STransMsg
*
resp
);
static
FORCE_INLINE
uint32_t
cliGetIpFromFqdnCache
(
SHashObj
*
cache
,
char
*
fqdn
);
static
FORCE_INLINE
void
cliUpdateFqdnCache
(
SHashObj
*
cache
,
char
*
fqdn
);
// process data read from server, add decompress etc later
// process data read from server, add decompress etc later
static
void
cliHandleResp
(
SCliConn
*
conn
);
static
void
cliHandleResp
(
SCliConn
*
conn
);
// handle except about conn
// handle except about conn
...
@@ -154,7 +158,7 @@ static FORCE_INLINE int cliRBChoseIdx(STrans* pTransInst);
...
@@ -154,7 +158,7 @@ static FORCE_INLINE int cliRBChoseIdx(STrans* pTransInst);
static
FORCE_INLINE
void
transDestroyConnCtx
(
STransConnCtx
*
ctx
);
static
FORCE_INLINE
void
transDestroyConnCtx
(
STransConnCtx
*
ctx
);
// thread obj
// thread obj
static
SCliThrd
*
createThrdObj
();
static
SCliThrd
*
createThrdObj
(
void
*
trans
);
static
void
destroyThrdObj
(
SCliThrd
*
pThrd
);
static
void
destroyThrdObj
(
SCliThrd
*
pThrd
);
static
void
cliWalkCb
(
uv_handle_t
*
handle
,
void
*
arg
);
static
void
cliWalkCb
(
uv_handle_t
*
handle
,
void
*
arg
);
...
@@ -930,6 +934,21 @@ FORCE_INLINE int32_t cliBuildExceptResp(SCliMsg* pMsg, STransMsg* pResp) {
...
@@ -930,6 +934,21 @@ FORCE_INLINE int32_t cliBuildExceptResp(SCliMsg* pMsg, STransMsg* pResp) {
return
0
;
return
0
;
}
}
static
FORCE_INLINE
uint32_t
cliGetIpFromFqdnCache
(
SHashObj
*
cache
,
char
*
fqdn
)
{
uint32_t
addr
=
0
;
uint32_t
*
v
=
taosHashGet
(
cache
,
fqdn
,
strlen
(
fqdn
));
if
(
v
==
NULL
)
{
addr
=
taosGetIpv4FromFqdn
(
fqdn
);
taosHashPut
(
cache
,
fqdn
,
strlen
(
fqdn
),
&
addr
,
sizeof
(
addr
));
}
else
{
addr
=
*
v
;
}
return
addr
;
}
static
FORCE_INLINE
void
cliUpdateFqdnCache
(
SHashObj
*
cache
,
char
*
fqdn
)
{
// impl later
return
;
}
void
cliHandleReq
(
SCliMsg
*
pMsg
,
SCliThrd
*
pThrd
)
{
void
cliHandleReq
(
SCliMsg
*
pMsg
,
SCliThrd
*
pThrd
)
{
STrans
*
pTransInst
=
pThrd
->
pTransInst
;
STrans
*
pTransInst
=
pThrd
->
pTransInst
;
...
@@ -985,7 +1004,8 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
...
@@ -985,7 +1004,8 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
struct
sockaddr_in
addr
;
struct
sockaddr_in
addr
;
addr
.
sin_family
=
AF_INET
;
addr
.
sin_family
=
AF_INET
;
addr
.
sin_addr
.
s_addr
=
taosGetIpv4FromFqdn
(
conn
->
ip
);
addr
.
sin_addr
.
s_addr
=
cliGetIpFromFqdnCache
(
pThrd
->
fqdn2ipCache
,
conn
->
ip
);
addr
.
sin_port
=
(
uint16_t
)
htons
((
uint16_t
)
conn
->
port
);
addr
.
sin_port
=
(
uint16_t
)
htons
((
uint16_t
)
conn
->
port
);
tTrace
(
"%s conn %p try to connect to %s:%d"
,
pTransInst
->
label
,
conn
,
conn
->
ip
,
conn
->
port
);
tTrace
(
"%s conn %p try to connect to %s:%d"
,
pTransInst
->
label
,
conn
,
conn
->
ip
,
conn
->
port
);
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
);
...
@@ -1132,10 +1152,7 @@ void* transInitClient(uint32_t ip, uint32_t port, char* label, int numOfThreads,
...
@@ -1132,10 +1152,7 @@ void* transInitClient(uint32_t ip, uint32_t port, char* label, int numOfThreads,
cli
->
pThreadObj
=
(
SCliThrd
**
)
taosMemoryCalloc
(
cli
->
numOfThreads
,
sizeof
(
SCliThrd
*
));
cli
->
pThreadObj
=
(
SCliThrd
**
)
taosMemoryCalloc
(
cli
->
numOfThreads
,
sizeof
(
SCliThrd
*
));
for
(
int
i
=
0
;
i
<
cli
->
numOfThreads
;
i
++
)
{
for
(
int
i
=
0
;
i
<
cli
->
numOfThreads
;
i
++
)
{
SCliThrd
*
pThrd
=
createThrdObj
();
SCliThrd
*
pThrd
=
createThrdObj
(
shandle
);
pThrd
->
nextTimeout
=
taosGetTimestampMs
()
+
CONN_PERSIST_TIME
(
pTransInst
->
idleTime
);
pThrd
->
pTransInst
=
shandle
;
int
err
=
taosThreadCreate
(
&
pThrd
->
thread
,
NULL
,
cliWorkThread
,
(
void
*
)(
pThrd
));
int
err
=
taosThreadCreate
(
&
pThrd
->
thread
,
NULL
,
cliWorkThread
,
(
void
*
)(
pThrd
));
if
(
err
==
0
)
{
if
(
err
==
0
)
{
tDebug
(
"success to create tranport-cli thread:%d"
,
i
);
tDebug
(
"success to create tranport-cli thread:%d"
,
i
);
...
@@ -1164,7 +1181,9 @@ static FORCE_INLINE void destroyCmsg(void* arg) {
...
@@ -1164,7 +1181,9 @@ static FORCE_INLINE void destroyCmsg(void* arg) {
taosMemoryFree
(
pMsg
);
taosMemoryFree
(
pMsg
);
}
}
static
SCliThrd
*
createThrdObj
()
{
static
SCliThrd
*
createThrdObj
(
void
*
trans
)
{
STrans
*
pTransInst
=
trans
;
SCliThrd
*
pThrd
=
(
SCliThrd
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SCliThrd
));
SCliThrd
*
pThrd
=
(
SCliThrd
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SCliThrd
));
QUEUE_INIT
(
&
pThrd
->
msg
);
QUEUE_INIT
(
&
pThrd
->
msg
);
...
@@ -1193,6 +1212,10 @@ static SCliThrd* createThrdObj() {
...
@@ -1193,6 +1212,10 @@ static SCliThrd* createThrdObj() {
transDQCreate
(
pThrd
->
loop
,
&
pThrd
->
timeoutQueue
);
transDQCreate
(
pThrd
->
loop
,
&
pThrd
->
timeoutQueue
);
pThrd
->
nextTimeout
=
taosGetTimestampMs
()
+
CONN_PERSIST_TIME
(
pTransInst
->
idleTime
);
pThrd
->
pTransInst
=
trans
;
pThrd
->
fqdn2ipCache
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
pThrd
->
quit
=
false
;
pThrd
->
quit
=
false
;
return
pThrd
;
return
pThrd
;
}
}
...
@@ -1217,6 +1240,7 @@ static void destroyThrdObj(SCliThrd* pThrd) {
...
@@ -1217,6 +1240,7 @@ static void destroyThrdObj(SCliThrd* pThrd) {
taosArrayDestroy
(
pThrd
->
timerList
);
taosArrayDestroy
(
pThrd
->
timerList
);
taosMemoryFree
(
pThrd
->
prepare
);
taosMemoryFree
(
pThrd
->
prepare
);
taosMemoryFree
(
pThrd
->
loop
);
taosMemoryFree
(
pThrd
->
loop
);
taosHashCleanup
(
pThrd
->
fqdn2ipCache
);
taosMemoryFree
(
pThrd
);
taosMemoryFree
(
pThrd
);
}
}
...
...
source/os/src/osTime.c
浏览文件 @
9a5db032
...
@@ -494,7 +494,7 @@ struct tm *taosLocalTimeNolock(struct tm *result, const time_t *timep, time_t tz
...
@@ -494,7 +494,7 @@ struct tm *taosLocalTimeNolock(struct tm *result, const time_t *timep, time_t tz
}
else
{
}
else
{
localtime_s
(
result
,
timep
);
localtime_s
(
result
,
timep
);
}
}
#el
se
#el
if defined(LINUX)
time_t
secsMin
=
60
,
secsHour
=
3600
,
secsDay
=
3600
*
24
;
time_t
secsMin
=
60
,
secsHour
=
3600
,
secsDay
=
3600
*
24
;
time_t
t
=
*
timep
;
time_t
t
=
*
timep
;
...
@@ -536,6 +536,8 @@ struct tm *taosLocalTimeNolock(struct tm *result, const time_t *timep, time_t tz
...
@@ -536,6 +536,8 @@ struct tm *taosLocalTimeNolock(struct tm *result, const time_t *timep, time_t tz
result
->
tm_mday
=
days
+
1
;
/* Add 1 since our 'days' is zero-based. */
result
->
tm_mday
=
days
+
1
;
/* Add 1 since our 'days' is zero-based. */
result
->
tm_year
-=
1900
;
/* Surprisingly tm_year is year-1900. */
result
->
tm_year
-=
1900
;
/* Surprisingly tm_year is year-1900. */
#else
localtime_r
(
timep
,
result
);
#endif
#endif
return
result
;
return
result
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录