Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6d7bf5e0
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
未验证
提交
6d7bf5e0
编写于
5月 25, 2022
作者:
dengyihao
提交者:
GitHub
5月 25, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12941 from taosdata/enh/refactorQueryCtx
enh: refactor trans free ctx
上级
9b007908
b0b533e0
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
112 addition
and
100 deletion
+112
-100
include/libs/transport/trpc.h
include/libs/transport/trpc.h
+1
-2
source/libs/scheduler/src/schRemote.c
source/libs/scheduler/src/schRemote.c
+7
-5
source/libs/scheduler/src/schUtil.c
source/libs/scheduler/src/schUtil.c
+2
-4
source/libs/transport/inc/transComm.h
source/libs/transport/inc/transComm.h
+2
-2
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+15
-1
source/libs/transport/src/transComm.c
source/libs/transport/src/transComm.c
+3
-2
source/libs/transport/test/transportTests.cpp
source/libs/transport/test/transportTests.cpp
+76
-76
source/os/src/osSocket.c
source/os/src/osSocket.c
+6
-8
未找到文件。
include/libs/transport/trpc.h
浏览文件 @
6d7bf5e0
...
@@ -89,19 +89,18 @@ typedef struct SRpcInit {
...
@@ -89,19 +89,18 @@ typedef struct SRpcInit {
typedef
struct
{
typedef
struct
{
void
*
val
;
void
*
val
;
int32_t
(
*
clone
)(
void
*
src
,
void
**
dst
);
int32_t
(
*
clone
)(
void
*
src
,
void
**
dst
);
void
(
*
freeFunc
)(
const
void
*
arg
);
}
SRpcCtxVal
;
}
SRpcCtxVal
;
typedef
struct
{
typedef
struct
{
int32_t
msgType
;
int32_t
msgType
;
void
*
val
;
void
*
val
;
int32_t
(
*
clone
)(
void
*
src
,
void
**
dst
);
int32_t
(
*
clone
)(
void
*
src
,
void
**
dst
);
void
(
*
freeFunc
)(
const
void
*
arg
);
}
SRpcBrokenlinkVal
;
}
SRpcBrokenlinkVal
;
typedef
struct
{
typedef
struct
{
SHashObj
*
args
;
SHashObj
*
args
;
SRpcBrokenlinkVal
brokenVal
;
SRpcBrokenlinkVal
brokenVal
;
void
(
*
freeFunc
)(
const
void
*
arg
);
}
SRpcCtx
;
}
SRpcCtx
;
int32_t
rpcInit
();
int32_t
rpcInit
();
...
...
source/libs/scheduler/src/schRemote.c
浏览文件 @
6d7bf5e0
...
@@ -565,8 +565,9 @@ int32_t schMakeHbCallbackParam(SSchJob *pJob, SSchTask *pTask, void **pParam) {
...
@@ -565,8 +565,9 @@ int32_t schMakeHbCallbackParam(SSchJob *pJob, SSchTask *pTask, void **pParam) {
int32_t
schCloneHbRpcCtx
(
SRpcCtx
*
pSrc
,
SRpcCtx
*
pDst
)
{
int32_t
schCloneHbRpcCtx
(
SRpcCtx
*
pSrc
,
SRpcCtx
*
pDst
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
memcpy
(
&
pDst
->
brokenVal
,
&
pSrc
->
brokenVal
,
sizeof
(
pSrc
->
brokenVal
));
memcpy
(
pDst
,
pSrc
,
sizeof
(
SRpcCtx
));
pDst
->
brokenVal
.
val
=
NULL
;
pDst
->
brokenVal
.
val
=
NULL
;
pDst
->
args
=
NULL
;
SCH_ERR_RET
(
schCloneSMsgSendInfo
(
pSrc
->
brokenVal
.
val
,
&
pDst
->
brokenVal
.
val
));
SCH_ERR_RET
(
schCloneSMsgSendInfo
(
pSrc
->
brokenVal
.
val
,
&
pDst
->
brokenVal
.
val
));
...
@@ -589,7 +590,7 @@ int32_t schCloneHbRpcCtx(SRpcCtx *pSrc, SRpcCtx *pDst) {
...
@@ -589,7 +590,7 @@ int32_t schCloneHbRpcCtx(SRpcCtx *pSrc, SRpcCtx *pDst) {
if
(
taosHashPut
(
pDst
->
args
,
msgType
,
sizeof
(
*
msgType
),
&
dst
,
sizeof
(
dst
)))
{
if
(
taosHashPut
(
pDst
->
args
,
msgType
,
sizeof
(
*
msgType
),
&
dst
,
sizeof
(
dst
)))
{
qError
(
"taosHashPut msg %d to rpcCtx failed"
,
*
msgType
);
qError
(
"taosHashPut msg %d to rpcCtx failed"
,
*
msgType
);
(
*
dst
.
freeFunc
)(
dst
.
val
);
(
*
pSrc
->
freeFunc
)(
dst
.
val
);
SCH_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
SCH_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
}
...
@@ -643,13 +644,14 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
...
@@ -643,13 +644,14 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
pMsgSendInfo
->
param
=
param
;
pMsgSendInfo
->
param
=
param
;
pMsgSendInfo
->
fp
=
fp
;
pMsgSendInfo
->
fp
=
fp
;
SRpcCtxVal
ctxVal
=
{.
val
=
pMsgSendInfo
,
.
clone
=
schCloneSMsgSendInfo
,
.
freeFunc
=
schFreeRpcCtxVal
};
SRpcCtxVal
ctxVal
=
{.
val
=
pMsgSendInfo
,
.
clone
=
schCloneSMsgSendInfo
};
if
(
taosHashPut
(
pCtx
->
args
,
&
msgType
,
sizeof
(
msgType
),
&
ctxVal
,
sizeof
(
ctxVal
)))
{
if
(
taosHashPut
(
pCtx
->
args
,
&
msgType
,
sizeof
(
msgType
),
&
ctxVal
,
sizeof
(
ctxVal
)))
{
SCH_TASK_ELOG
(
"taosHashPut msg %d to rpcCtx failed"
,
msgType
);
SCH_TASK_ELOG
(
"taosHashPut msg %d to rpcCtx failed"
,
msgType
);
SCH_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
SCH_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
}
SCH_ERR_JRET
(
schMakeBrokenLinkVal
(
pJob
,
pTask
,
&
pCtx
->
brokenVal
,
true
));
SCH_ERR_JRET
(
schMakeBrokenLinkVal
(
pJob
,
pTask
,
&
pCtx
->
brokenVal
,
true
));
pCtx
->
freeFunc
=
schFreeRpcCtxVal
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -911,7 +913,6 @@ int32_t schMakeBrokenLinkVal(SSchJob *pJob, SSchTask *pTask, SRpcBrokenlinkVal *
...
@@ -911,7 +913,6 @@ int32_t schMakeBrokenLinkVal(SSchJob *pJob, SSchTask *pTask, SRpcBrokenlinkVal *
brokenVal
->
msgType
=
msgType
;
brokenVal
->
msgType
=
msgType
;
brokenVal
->
val
=
pMsgSendInfo
;
brokenVal
->
val
=
pMsgSendInfo
;
brokenVal
->
clone
=
schCloneSMsgSendInfo
;
brokenVal
->
clone
=
schCloneSMsgSendInfo
;
brokenVal
->
freeFunc
=
schFreeRpcCtxVal
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -938,7 +939,7 @@ int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
...
@@ -938,7 +939,7 @@ int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
SCH_ERR_JRET
(
schGenerateCallBackInfo
(
pJob
,
pTask
,
TDMT_VND_EXPLAIN
,
&
pExplainMsgSendInfo
));
SCH_ERR_JRET
(
schGenerateCallBackInfo
(
pJob
,
pTask
,
TDMT_VND_EXPLAIN
,
&
pExplainMsgSendInfo
));
int32_t
msgType
=
TDMT_VND_RES_READY_RSP
;
int32_t
msgType
=
TDMT_VND_RES_READY_RSP
;
SRpcCtxVal
ctxVal
=
{.
val
=
pReadyMsgSendInfo
,
.
clone
=
schCloneSMsgSendInfo
,
.
freeFunc
=
schFreeRpcCtxVal
};
SRpcCtxVal
ctxVal
=
{.
val
=
pReadyMsgSendInfo
,
.
clone
=
schCloneSMsgSendInfo
};
if
(
taosHashPut
(
pCtx
->
args
,
&
msgType
,
sizeof
(
msgType
),
&
ctxVal
,
sizeof
(
ctxVal
)))
{
if
(
taosHashPut
(
pCtx
->
args
,
&
msgType
,
sizeof
(
msgType
),
&
ctxVal
,
sizeof
(
ctxVal
)))
{
SCH_TASK_ELOG
(
"taosHashPut msg %d to rpcCtx failed"
,
msgType
);
SCH_TASK_ELOG
(
"taosHashPut msg %d to rpcCtx failed"
,
msgType
);
SCH_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
SCH_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
...
@@ -952,6 +953,7 @@ int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
...
@@ -952,6 +953,7 @@ int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
}
}
SCH_ERR_JRET
(
schMakeBrokenLinkVal
(
pJob
,
pTask
,
&
pCtx
->
brokenVal
,
false
));
SCH_ERR_JRET
(
schMakeBrokenLinkVal
(
pJob
,
pTask
,
&
pCtx
->
brokenVal
,
false
));
pCtx
->
freeFunc
=
schFreeRpcCtxVal
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/scheduler/src/schUtil.c
浏览文件 @
6d7bf5e0
...
@@ -77,16 +77,14 @@ void schFreeRpcCtx(SRpcCtx *pCtx) {
...
@@ -77,16 +77,14 @@ void schFreeRpcCtx(SRpcCtx *pCtx) {
while
(
pIter
)
{
while
(
pIter
)
{
SRpcCtxVal
*
ctxVal
=
(
SRpcCtxVal
*
)
pIter
;
SRpcCtxVal
*
ctxVal
=
(
SRpcCtxVal
*
)
pIter
;
(
*
ctxVal
->
freeFunc
)(
ctxVal
->
val
);
(
*
pCtx
->
freeFunc
)(
ctxVal
->
val
);
pIter
=
taosHashIterate
(
pCtx
->
args
,
pIter
);
pIter
=
taosHashIterate
(
pCtx
->
args
,
pIter
);
}
}
taosHashCleanup
(
pCtx
->
args
);
taosHashCleanup
(
pCtx
->
args
);
if
(
pCtx
->
brokenVal
.
freeFunc
)
{
(
*
pCtx
->
freeFunc
)(
pCtx
->
brokenVal
.
val
);
(
*
pCtx
->
brokenVal
.
freeFunc
)(
pCtx
->
brokenVal
.
val
);
}
}
}
source/libs/transport/inc/transComm.h
浏览文件 @
6d7bf5e0
source/libs/transport/src/transCli.c
浏览文件 @
6d7bf5e0
...
@@ -131,6 +131,19 @@ static void destroyThrdObj(SCliThrdObj* pThrd);
...
@@ -131,6 +131,19 @@ static void destroyThrdObj(SCliThrdObj* pThrd);
static
void
cliWalkCb
(
uv_handle_t
*
handle
,
void
*
arg
);
static
void
cliWalkCb
(
uv_handle_t
*
handle
,
void
*
arg
);
static
void
cliReleaseUnfinishedMsg
(
SCliConn
*
conn
)
{
SCliMsg
*
pMsg
=
NULL
;
for
(
int
i
=
0
;
i
<
transQueueSize
(
&
conn
->
cliMsgs
);
i
++
)
{
pMsg
=
transQueueGet
(
&
conn
->
cliMsgs
,
i
);
if
(
pMsg
!=
NULL
&&
pMsg
->
ctx
!=
NULL
)
{
if
(
conn
->
ctx
.
freeFunc
!=
NULL
)
{
conn
->
ctx
.
freeFunc
(
pMsg
->
ctx
->
ahandle
);
}
}
destroyCmsg
(
pMsg
);
}
}
#define CLI_RELEASE_UV(loop) \
#define CLI_RELEASE_UV(loop) \
do { \
do { \
uv_walk(loop, cliWalkCb, NULL); \
uv_walk(loop, cliWalkCb, NULL); \
...
@@ -161,6 +174,7 @@ static void cliWalkCb(uv_handle_t* handle, void* arg);
...
@@ -161,6 +174,7 @@ static void cliWalkCb(uv_handle_t* handle, void* arg);
transUnrefCliHandle(conn); \
transUnrefCliHandle(conn); \
} \
} \
destroyCmsg(pMsg); \
destroyCmsg(pMsg); \
cliReleaseUnfinishedMsg(conn); \
addConnToPool(((SCliThrdObj*)conn->hostThrd)->pool, conn); \
addConnToPool(((SCliThrdObj*)conn->hostThrd)->pool, conn); \
return; \
return; \
} \
} \
...
@@ -465,8 +479,8 @@ static void addConnToPool(void* pool, SCliConn* conn) {
...
@@ -465,8 +479,8 @@ static void addConnToPool(void* pool, SCliConn* conn) {
STrans
*
pTransInst
=
((
SCliThrdObj
*
)
conn
->
hostThrd
)
->
pTransInst
;
STrans
*
pTransInst
=
((
SCliThrdObj
*
)
conn
->
hostThrd
)
->
pTransInst
;
conn
->
expireTime
=
taosGetTimestampMs
()
+
CONN_PERSIST_TIME
(
pTransInst
->
idleTime
);
conn
->
expireTime
=
taosGetTimestampMs
()
+
CONN_PERSIST_TIME
(
pTransInst
->
idleTime
);
transCtxCleanup
(
&
conn
->
ctx
);
transQueueClear
(
&
conn
->
cliMsgs
);
transQueueClear
(
&
conn
->
cliMsgs
);
transCtxCleanup
(
&
conn
->
ctx
);
conn
->
status
=
ConnInPool
;
conn
->
status
=
ConnInPool
;
char
key
[
128
]
=
{
0
};
char
key
[
128
]
=
{
0
};
...
...
source/libs/transport/src/transComm.c
浏览文件 @
6d7bf5e0
...
@@ -233,7 +233,7 @@ void transCtxCleanup(STransCtx* ctx) {
...
@@ -233,7 +233,7 @@ void transCtxCleanup(STransCtx* ctx) {
STransCtxVal
*
iter
=
taosHashIterate
(
ctx
->
args
,
NULL
);
STransCtxVal
*
iter
=
taosHashIterate
(
ctx
->
args
,
NULL
);
while
(
iter
)
{
while
(
iter
)
{
iter
->
freeFunc
(
iter
->
val
);
ctx
->
freeFunc
(
iter
->
val
);
iter
=
taosHashIterate
(
ctx
->
args
,
iter
);
iter
=
taosHashIterate
(
ctx
->
args
,
iter
);
}
}
...
@@ -245,6 +245,7 @@ void transCtxMerge(STransCtx* dst, STransCtx* src) {
...
@@ -245,6 +245,7 @@ void transCtxMerge(STransCtx* dst, STransCtx* src) {
if
(
dst
->
args
==
NULL
)
{
if
(
dst
->
args
==
NULL
)
{
dst
->
args
=
src
->
args
;
dst
->
args
=
src
->
args
;
dst
->
brokenVal
=
src
->
brokenVal
;
dst
->
brokenVal
=
src
->
brokenVal
;
dst
->
freeFunc
=
src
->
freeFunc
;
src
->
args
=
NULL
;
src
->
args
=
NULL
;
return
;
return
;
}
}
...
@@ -257,7 +258,7 @@ void transCtxMerge(STransCtx* dst, STransCtx* src) {
...
@@ -257,7 +258,7 @@ void transCtxMerge(STransCtx* dst, STransCtx* src) {
STransCtxVal
*
dVal
=
taosHashGet
(
dst
->
args
,
key
,
klen
);
STransCtxVal
*
dVal
=
taosHashGet
(
dst
->
args
,
key
,
klen
);
if
(
dVal
)
{
if
(
dVal
)
{
d
Val
->
freeFunc
(
dVal
->
val
);
d
st
->
freeFunc
(
dVal
->
val
);
}
}
taosHashPut
(
dst
->
args
,
key
,
klen
,
sVal
,
sizeof
(
*
sVal
));
taosHashPut
(
dst
->
args
,
key
,
klen
,
sVal
,
sizeof
(
*
sVal
));
iter
=
taosHashIterate
(
src
->
args
,
iter
);
iter
=
taosHashIterate
(
src
->
args
,
iter
);
...
...
source/libs/transport/test/transportTests.cpp
浏览文件 @
6d7bf5e0
...
@@ -156,80 +156,80 @@ int32_t cloneVal(void *src, void **dst) {
...
@@ -156,80 +156,80 @@ int32_t cloneVal(void *src, void **dst) {
memcpy
(
*
dst
,
src
,
sz
);
memcpy
(
*
dst
,
src
,
sz
);
return
0
;
return
0
;
}
}
TEST_F
(
TransCtxEnv
,
mergeTest
)
{
//
TEST_F(TransCtxEnv, mergeTest) {
int
key
=
1
;
//
int key = 1;
{
//
{
STransCtx
*
src
=
(
STransCtx
*
)
taosMemoryCalloc
(
1
,
sizeof
(
STransCtx
));
//
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
transCtxInit
(
src
);
//
transCtxInit(src);
{
//
{
STransCtxVal
val1
=
{
NULL
,
NULL
,
(
void
(
*
)(
const
void
*
))
taosMemoryFree
};
//
STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree};
val1
.
val
=
taosMemoryMalloc
(
12
);
//
val1.val = taosMemoryMalloc(12);
//
taosHashPut
(
src
->
args
,
&
key
,
sizeof
(
key
),
&
val1
,
sizeof
(
val1
));
//
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
key
++
;
//
key++;
}
//
}
{
//
{
STransCtxVal
val1
=
{
NULL
,
NULL
,
(
void
(
*
)(
const
void
*
))
taosMemoryFree
};
//
STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree};
val1
.
val
=
taosMemoryMalloc
(
12
);
//
val1.val = taosMemoryMalloc(12);
taosHashPut
(
src
->
args
,
&
key
,
sizeof
(
key
),
&
val1
,
sizeof
(
val1
));
//
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
key
++
;
//
key++;
}
//
}
transCtxMerge
(
ctx
,
src
);
//
transCtxMerge(ctx, src);
taosMemoryFree
(
src
);
//
taosMemoryFree(src);
}
//
}
EXPECT_EQ
(
2
,
taosHashGetSize
(
ctx
->
args
));
//
EXPECT_EQ(2, taosHashGetSize(ctx->args));
{
//
{
STransCtx
*
src
=
(
STransCtx
*
)
taosMemoryCalloc
(
1
,
sizeof
(
STransCtx
));
//
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
transCtxInit
(
src
);
//
transCtxInit(src);
{
//
{
STransCtxVal
val1
=
{
NULL
,
NULL
,
(
void
(
*
)(
const
void
*
))
taosMemoryFree
};
//
STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree};
val1
.
val
=
taosMemoryMalloc
(
12
);
//
val1.val = taosMemoryMalloc(12);
//
taosHashPut
(
src
->
args
,
&
key
,
sizeof
(
key
),
&
val1
,
sizeof
(
val1
));
//
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
key
++
;
//
key++;
}
//
}
{
//
{
STransCtxVal
val1
=
{
NULL
,
NULL
,
(
void
(
*
)(
const
void
*
))
taosMemoryFree
};
//
STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree};
val1
.
val
=
taosMemoryMalloc
(
12
);
//
val1.val = taosMemoryMalloc(12);
taosHashPut
(
src
->
args
,
&
key
,
sizeof
(
key
),
&
val1
,
sizeof
(
val1
));
//
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
key
++
;
//
key++;
}
//
}
transCtxMerge
(
ctx
,
src
);
//
transCtxMerge(ctx, src);
taosMemoryFree
(
src
);
//
taosMemoryFree(src);
}
//
}
std
::
string
val
(
"Hello"
);
//
std::string val("Hello");
EXPECT_EQ
(
4
,
taosHashGetSize
(
ctx
->
args
));
//
EXPECT_EQ(4, taosHashGetSize(ctx->args));
{
//
{
key
=
1
;
//
key = 1;
STransCtx
*
src
=
(
STransCtx
*
)
taosMemoryCalloc
(
1
,
sizeof
(
STransCtx
));
//
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
transCtxInit
(
src
);
//
transCtxInit(src);
{
//
{
STransCtxVal
val1
=
{
NULL
,
NULL
,
(
void
(
*
)(
const
void
*
))
taosMemoryFree
};
//
STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree};
val1
.
val
=
taosMemoryCalloc
(
1
,
11
);
//
val1.val = taosMemoryCalloc(1, 11);
val1
.
clone
=
cloneVal
;
//
val1.clone = cloneVal;
memcpy
(
val1
.
val
,
val
.
c_str
(),
val
.
size
());
//
memcpy(val1.val, val.c_str(), val.size());
//
taosHashPut
(
src
->
args
,
&
key
,
sizeof
(
key
),
&
val1
,
sizeof
(
val1
));
//
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
key
++
;
//
key++;
}
//
}
{
//
{
STransCtxVal
val1
=
{
NULL
,
NULL
,
(
void
(
*
)(
const
void
*
))
taosMemoryFree
};
//
STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree};
val1
.
val
=
taosMemoryCalloc
(
1
,
11
);
//
val1.val = taosMemoryCalloc(1, 11);
val1
.
clone
=
cloneVal
;
//
val1.clone = cloneVal;
memcpy
(
val1
.
val
,
val
.
c_str
(),
val
.
size
());
//
memcpy(val1.val, val.c_str(), val.size());
taosHashPut
(
src
->
args
,
&
key
,
sizeof
(
key
),
&
val1
,
sizeof
(
val1
));
//
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
key
++
;
//
key++;
}
//
}
transCtxMerge
(
ctx
,
src
);
//
transCtxMerge(ctx, src);
taosMemoryFree
(
src
);
//
taosMemoryFree(src);
}
//
}
EXPECT_EQ
(
4
,
taosHashGetSize
(
ctx
->
args
));
//
EXPECT_EQ(4, taosHashGetSize(ctx->args));
//
char
*
skey
=
(
char
*
)
transCtxDumpVal
(
ctx
,
1
);
//
char *skey = (char *)transCtxDumpVal(ctx, 1);
EXPECT_EQ
(
0
,
strcmp
(
skey
,
val
.
c_str
()));
//
EXPECT_EQ(0, strcmp(skey, val.c_str()));
taosMemoryFree
(
skey
);
//
taosMemoryFree(skey);
//
skey
=
(
char
*
)
transCtxDumpVal
(
ctx
,
2
);
//
skey = (char *)transCtxDumpVal(ctx, 2);
EXPECT_EQ
(
0
,
strcmp
(
skey
,
val
.
c_str
()));
//
EXPECT_EQ(0, strcmp(skey, val.c_str()));
}
//
}
#endif
#endif
source/os/src/osSocket.c
浏览文件 @
6d7bf5e0
...
@@ -892,7 +892,7 @@ uint32_t taosGetIpv4FromFqdn(const char *fqdn) {
...
@@ -892,7 +892,7 @@ uint32_t taosGetIpv4FromFqdn(const char *fqdn) {
int
iResult
;
int
iResult
;
iResult
=
WSAStartup
(
MAKEWORD
(
2
,
2
),
&
wsaData
);
iResult
=
WSAStartup
(
MAKEWORD
(
2
,
2
),
&
wsaData
);
if
(
iResult
!=
0
)
{
if
(
iResult
!=
0
)
{
printf
(
"WSAStartup failed: %d
\n
"
,
iResult
);
//
printf("WSAStartup failed: %d\n", iResult);
return
1
;
return
1
;
}
}
#endif
#endif
...
@@ -928,7 +928,7 @@ int32_t taosGetFqdn(char *fqdn) {
...
@@ -928,7 +928,7 @@ int32_t taosGetFqdn(char *fqdn) {
char
hostname
[
1024
];
char
hostname
[
1024
];
hostname
[
1023
]
=
'\0'
;
hostname
[
1023
]
=
'\0'
;
if
(
gethostname
(
hostname
,
1023
)
==
-
1
)
{
if
(
gethostname
(
hostname
,
1023
)
==
-
1
)
{
printf
(
"failed to get hostname, reason:%s"
,
strerror
(
errno
));
//
printf("failed to get hostname, reason:%s", strerror(errno));
assert
(
0
);
assert
(
0
);
return
-
1
;
return
-
1
;
}
}
...
@@ -946,7 +946,7 @@ int32_t taosGetFqdn(char *fqdn) {
...
@@ -946,7 +946,7 @@ int32_t taosGetFqdn(char *fqdn) {
#endif // __APPLE__
#endif // __APPLE__
int32_t
ret
=
getaddrinfo
(
hostname
,
NULL
,
&
hints
,
&
result
);
int32_t
ret
=
getaddrinfo
(
hostname
,
NULL
,
&
hints
,
&
result
);
if
(
!
result
)
{
if
(
!
result
)
{
printf
(
"failed to get fqdn, code:%d, reason:%s"
,
ret
,
gai_strerror
(
ret
));
//
printf("failed to get fqdn, code:%d, reason:%s", ret, gai_strerror(ret));
assert
(
0
);
assert
(
0
);
return
-
1
;
return
-
1
;
}
}
...
@@ -993,9 +993,7 @@ void tinet_ntoa(char *ipstr, uint32_t ip) {
...
@@ -993,9 +993,7 @@ void tinet_ntoa(char *ipstr, uint32_t ip) {
sprintf
(
ipstr
,
"%d.%d.%d.%d"
,
ip
&
0xFF
,
(
ip
>>
8
)
&
0xFF
,
(
ip
>>
16
)
&
0xFF
,
ip
>>
24
);
sprintf
(
ipstr
,
"%d.%d.%d.%d"
,
ip
&
0xFF
,
(
ip
>>
8
)
&
0xFF
,
(
ip
>>
16
)
&
0xFF
,
ip
>>
24
);
}
}
void
taosIgnSIGPIPE
()
{
void
taosIgnSIGPIPE
()
{
signal
(
SIGPIPE
,
SIG_IGN
);
}
signal
(
SIGPIPE
,
SIG_IGN
);
}
void
taosSetMaskSIGPIPE
()
{
void
taosSetMaskSIGPIPE
()
{
#ifdef WINDOWS
#ifdef WINDOWS
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录