Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
22743e49
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看板
未验证
提交
22743e49
编写于
4月 21, 2022
作者:
dengyihao
提交者:
GitHub
4月 21, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11721 from taosdata/feature/authImp
enh(rpc):add auth
上级
be1a2c69
eefb0a20
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
74 addition
and
38 deletion
+74
-38
include/common/tmsg.h
include/common/tmsg.h
+8
-0
include/libs/transport/trpc.h
include/libs/transport/trpc.h
+12
-8
source/common/src/tmsg.c
source/common/src/tmsg.c
+21
-0
source/libs/transport/inc/transportInt.h
source/libs/transport/inc/transportInt.h
+7
-6
source/libs/transport/src/trans.c
source/libs/transport/src/trans.c
+5
-5
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+20
-11
source/libs/transport/src/transSrv.c
source/libs/transport/src/transSrv.c
+1
-8
未找到文件。
include/common/tmsg.h
浏览文件 @
22743e49
...
...
@@ -326,6 +326,13 @@ int32_t tDecodeSEpSet(SCoder* pDecoder, SEpSet* pEp);
int32_t
taosEncodeSEpSet
(
void
**
buf
,
const
SEpSet
*
pEp
);
void
*
taosDecodeSEpSet
(
const
void
*
buf
,
SEpSet
*
pEp
);
typedef
struct
{
SEpSet
epSet
;
}
SMEpSet
;
int32_t
tSerializeSMEpSet
(
void
*
buf
,
int32_t
bufLen
,
SMEpSet
*
pReq
);
int32_t
tDeserializeSMEpSet
(
void
*
buf
,
int32_t
buflen
,
SMEpSet
*
pReq
);
typedef
struct
{
int8_t
connType
;
int32_t
pid
;
...
...
@@ -2725,6 +2732,7 @@ static FORCE_INLINE void* tDecodeSMqCMGetSubEpRsp(void* buf, SMqCMGetSubEpRsp* p
}
return
buf
;
}
#pragma pack(pop)
#ifdef __cplusplus
...
...
include/libs/transport/trpc.h
浏览文件 @
22743e49
...
...
@@ -54,12 +54,13 @@ typedef struct {
uint16_t
clientPort
;
SRpcMsg
rpcMsg
;
int32_t
rspLen
;
void
*
pRsp
;
void
*
pNode
;
void
*
pRsp
;
void
*
pNode
;
}
SNodeMsg
;
typedef
void
(
*
RpcCfp
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
);
typedef
int
(
*
RpcAfp
)(
void
*
parent
,
char
*
tableId
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
typedef
int
(
*
RpcRfp
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
);
typedef
struct
SRpcInit
{
uint16_t
localPort
;
// local port
...
...
@@ -80,22 +81,25 @@ typedef struct SRpcInit {
RpcCfp
cfp
;
// call back to retrieve the client auth info, for server app only
RpcAfp
afp
;;
RpcAfp
afp
;
// user defined retry func
RpcRfp
rfp
;
void
*
parent
;
}
SRpcInit
;
typedef
struct
{
void
*
val
;
void
*
val
;
int32_t
(
*
clone
)(
void
*
src
,
void
**
dst
);
void
(
*
freeFunc
)(
const
void
*
arg
);
void
(
*
freeFunc
)(
const
void
*
arg
);
}
SRpcCtxVal
;
typedef
struct
{
int32_t
msgType
;
void
*
val
;
int32_t
msgType
;
void
*
val
;
int32_t
(
*
clone
)(
void
*
src
,
void
**
dst
);
void
(
*
freeFunc
)(
const
void
*
arg
);
void
(
*
freeFunc
)(
const
void
*
arg
);
}
SRpcBrokenlinkVal
;
typedef
struct
{
...
...
source/common/src/tmsg.c
浏览文件 @
22743e49
...
...
@@ -844,6 +844,27 @@ void tFreeSMAltertbReq(SMAltertbReq *pReq) {
taosArrayDestroy
(
pReq
->
pFields
);
pReq
->
pFields
=
NULL
;
}
int32_t
tSerializeSMEpSet
(
void
*
buf
,
int32_t
bufLen
,
SMEpSet
*
pReq
)
{
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeSEpSet
(
&
encoder
,
&
pReq
->
epSet
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tCoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSMEpSet
(
void
*
buf
,
int32_t
bufLen
,
SMEpSet
*
pReq
)
{
SCoder
decoder
=
{
0
};
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeSEpSet
(
&
decoder
,
&
pReq
->
epSet
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
}
int32_t
tSerializeSMCreateSmaReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateSmaReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
...
...
source/libs/transport/inc/transportInt.h
浏览文件 @
22743e49
...
...
@@ -63,13 +63,14 @@ typedef struct {
void
(
*
cfp
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
);
int
(
*
afp
)(
void
*
parent
,
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
int
(
*
retry
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
);
int32_t
refCount
;
void
*
parent
;
void
*
idPool
;
// handle to ID pool
void
*
tmrCtrl
;
// handle to timer
SHashObj
*
hash
;
// handle returned by hash utility
void
*
tcphandle
;
// returned handle from TCP initialization
int32_t
refCount
;
void
*
parent
;
void
*
idPool
;
// handle to ID pool
void
*
tmrCtrl
;
// handle to timer
SHashObj
*
hash
;
// handle returned by hash utility
void
*
tcphandle
;
// returned handle from TCP initialization
TdThreadMutex
mutex
;
}
SRpcInfo
;
...
...
source/libs/transport/src/trans.c
浏览文件 @
22743e49
...
...
@@ -39,6 +39,7 @@ void* rpcOpen(const SRpcInit* pInit) {
// register callback handle
pRpc
->
cfp
=
pInit
->
cfp
;
pRpc
->
afp
=
pInit
->
afp
;
pRpc
->
retry
=
pInit
->
rfp
;
if
(
pInit
->
connType
==
TAOS_CONN_SERVER
)
{
pRpc
->
numOfThreads
=
pInit
->
numOfThreads
>
TSDB_MAX_RPC_THREADS
?
TSDB_MAX_RPC_THREADS
:
pInit
->
numOfThreads
;
...
...
@@ -100,11 +101,10 @@ void rpcSendRedirectRsp(void* thandle, const SEpSet* pEpSet) {
SRpcMsg
rpcMsg
;
memset
(
&
rpcMsg
,
0
,
sizeof
(
rpcMsg
));
rpcMsg
.
contLen
=
sizeof
(
SEpSet
);
rpcMsg
.
pCont
=
rpcMallocCont
(
rpcMsg
.
contLen
);
if
(
rpcMsg
.
pCont
==
NULL
)
return
;
memcpy
(
rpcMsg
.
pCont
,
pEpSet
,
sizeof
(
SEpSet
));
SMEpSet
msg
=
{.
epSet
=
*
pEpSet
};
int32_t
len
=
tSerializeSMEpSet
(
NULL
,
0
,
&
msg
);
rpcMsg
.
pCont
=
rpcMallocCont
(
len
);
tSerializeSMEpSet
(
rpcMsg
.
pCont
,
len
,
&
msg
);
rpcMsg
.
code
=
TSDB_CODE_RPC_REDIRECT
;
rpcMsg
.
handle
=
thandle
;
...
...
source/libs/transport/src/transCli.c
浏览文件 @
22743e49
...
...
@@ -31,12 +31,8 @@ typedef struct SCliConn {
int
hThrdIdx
;
STransCtx
ctx
;
bool
broken
;
// link broken or not
ConnStatus
status
;
//
int
release
;
// 1: release
// spi configure
char
spi
;
char
secured
;
bool
broken
;
// link broken or not
ConnStatus
status
;
//
char
*
ip
;
uint32_t
port
;
...
...
@@ -44,7 +40,6 @@ typedef struct SCliConn {
// debug and log info
struct
sockaddr_in
addr
;
struct
sockaddr_in
locaddr
;
}
SCliConn
;
typedef
struct
SCliMsg
{
...
...
@@ -102,6 +97,8 @@ static void cliSendCb(uv_write_t* req, int status);
static
void
cliConnCb
(
uv_connect_t
*
req
,
int
status
);
static
void
cliAsyncCb
(
uv_async_t
*
handle
);
static
void
cliAppCb
(
SCliConn
*
pConn
,
STransMsg
*
pMsg
);
static
SCliConn
*
cliCreateConn
(
SCliThrdObj
*
thrd
);
static
void
cliDestroyConn
(
SCliConn
*
pConn
,
bool
clear
/*clear tcp handle or not*/
);
static
void
cliDestroy
(
uv_handle_t
*
handle
);
...
...
@@ -303,8 +300,6 @@ void cliHandleResp(SCliConn* conn) {
TMSG_INFO
(
pHead
->
msgType
),
taosInetNtoa
(
conn
->
addr
.
sin_addr
),
ntohs
(
conn
->
addr
.
sin_port
),
taosInetNtoa
(
conn
->
locaddr
.
sin_addr
),
ntohs
(
conn
->
locaddr
.
sin_port
),
transMsg
.
contLen
);
conn
->
secured
=
pHead
->
secured
;
if
(
pCtx
==
NULL
&&
CONN_NO_PERSIST_BY_APP
(
conn
))
{
tTrace
(
"except, server continue send while cli ignore it"
);
// transUnrefCliHandle(conn);
...
...
@@ -318,7 +313,8 @@ void cliHandleResp(SCliConn* conn) {
if
(
pCtx
==
NULL
||
pCtx
->
pSem
==
NULL
)
{
tTrace
(
"%s cli conn %p handle resp"
,
pTransInst
->
label
,
conn
);
(
pTransInst
->
cfp
)(
pTransInst
->
parent
,
&
transMsg
,
NULL
);
cliAppCb
(
conn
,
&
transMsg
);
//(pTransInst->cfp)(pTransInst->parent, &transMsg, NULL);
}
else
{
tTrace
(
"%s cli conn(sync) %p handle resp"
,
pTransInst
->
label
,
conn
);
memcpy
((
char
*
)
pCtx
->
pRsp
,
(
char
*
)
&
transMsg
,
sizeof
(
transMsg
));
...
...
@@ -384,7 +380,8 @@ void cliHandleExcept(SCliConn* pConn) {
once
=
true
;
continue
;
}
(
pTransInst
->
cfp
)(
pTransInst
->
parent
,
&
transMsg
,
NULL
);
cliAppCb
(
pConn
,
&
transMsg
);
//(pTransInst->cfp)(pTransInst->parent, &transMsg, NULL);
}
else
{
tTrace
(
"%s cli conn(sync) %p handle except"
,
pTransInst
->
label
,
pConn
);
memcpy
((
char
*
)(
pCtx
->
pRsp
),
(
char
*
)(
&
transMsg
),
sizeof
(
transMsg
));
...
...
@@ -884,6 +881,18 @@ int cliRBChoseIdx(STrans* pTransInst) {
}
return
index
%
pTransInst
->
numOfThreads
;
}
void
cliAppCb
(
SCliConn
*
pConn
,
STransMsg
*
transMsg
)
{
SCliThrdObj
*
pThrd
=
pConn
->
hostThrd
;
STrans
*
pTransInst
=
pThrd
->
pTransInst
;
if
(
transMsg
->
code
==
TSDB_CODE_RPC_REDIRECT
&&
pTransInst
->
retry
!=
NULL
)
{
SMEpSet
emsg
=
{
0
};
tDeserializeSMEpSet
(
transMsg
->
pCont
,
transMsg
->
contLen
,
&
emsg
);
pTransInst
->
retry
(
pTransInst
,
transMsg
,
&
(
emsg
.
epSet
));
}
else
{
pTransInst
->
cfp
(
pTransInst
->
parent
,
transMsg
,
NULL
);
}
}
void
transCloseClient
(
void
*
arg
)
{
SCliObj
*
cli
=
arg
;
...
...
source/libs/transport/src/transSrv.c
浏览文件 @
22743e49
...
...
@@ -30,7 +30,6 @@ typedef struct SSrvConn {
uv_timer_t
pTimer
;
queue
queue
;
int
ref
;
int
persist
;
// persist connection or not
SConnBuffer
readBuf
;
// read buf,
int
inType
;
...
...
@@ -692,8 +691,6 @@ static void uvDestroyConn(uv_handle_t* handle) {
if
(
thrd
->
quit
&&
QUEUE_IS_EMPTY
(
&
thrd
->
conn
))
{
tTrace
(
"work thread quit"
);
uv_walk
(
thrd
->
loop
,
uvWalkCb
,
NULL
);
// uv_loop_close(thrd->loop);
// uv_stop(thrd->loop);
}
}
...
...
@@ -756,8 +753,6 @@ void uvHandleQuit(SSrvMsg* msg, SWorkThrdObj* thrd) {
thrd
->
quit
=
true
;
if
(
QUEUE_IS_EMPTY
(
&
thrd
->
conn
))
{
uv_walk
(
thrd
->
loop
,
uvWalkCb
,
NULL
);
// uv_loop_close(thrd->loop);
// uv_stop(thrd->loop);
}
else
{
destroyAllConn
(
thrd
);
}
...
...
@@ -851,10 +846,8 @@ void transRefSrvHandle(void* handle) {
if
(
handle
==
NULL
)
{
return
;
}
SSrvConn
*
conn
=
handle
;
int
ref
=
T_REF_INC
((
SSrvConn
*
)
handle
);
UNUSED
(
ref
);
tDebug
(
"server conn %p ref count: %d"
,
handle
,
ref
);
}
void
transUnrefSrvHandle
(
void
*
handle
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录