Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
75b15760
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看板
提交
75b15760
编写于
4月 03, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-93] add ref to sdb
上级
eb6f21bd
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
217 addition
and
275 deletion
+217
-275
src/inc/mnode.h
src/inc/mnode.h
+3
-3
src/mnode/CMakeLists.txt
src/mnode/CMakeLists.txt
+1
-3
src/mnode/inc/mgmtProfile.h
src/mnode/inc/mgmtProfile.h
+2
-0
src/mnode/inc/mgmtTable.h
src/mnode/inc/mgmtTable.h
+2
-2
src/mnode/inc/mgmtVgroup.h
src/mnode/inc/mgmtVgroup.h
+3
-1
src/mnode/src/mgmtAcct.c
src/mnode/src/mgmtAcct.c
+5
-36
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+22
-21
src/mnode/src/mgmtDnode.c
src/mnode/src/mgmtDnode.c
+1
-0
src/mnode/src/mgmtProfile.c
src/mnode/src/mgmtProfile.c
+42
-4
src/mnode/src/mgmtSdb.c
src/mnode/src/mgmtSdb.c
+2
-2
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+19
-31
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+104
-157
src/mnode/src/mgmtUser.c
src/mnode/src/mgmtUser.c
+2
-4
src/mnode/src/mgmtVgroup.c
src/mnode/src/mgmtVgroup.c
+9
-11
未找到文件。
src/inc/mnode.h
浏览文件 @
75b15760
...
...
@@ -169,7 +169,6 @@ typedef struct _db_obj {
int8_t
reserved
[
15
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
struct
_db_obj
*
prev
,
*
next
;
int32_t
numOfVgroups
;
int32_t
numOfTables
;
int32_t
numOfSuperTables
;
...
...
@@ -222,7 +221,6 @@ typedef struct _acctObj {
int8_t
updateEnd
[
1
];
int32_t
refCount
;
SAcctInfo
acctInfo
;
SDbObj
*
pHead
;
pthread_mutex_t
mutex
;
}
SAcctObj
;
...
...
@@ -252,8 +250,10 @@ typedef struct {
void
*
ahandle
;
void
*
thandle
;
void
*
pCont
;
SDbObj
*
pDb
;
SUserObj
*
pUser
;
SDbObj
*
pDb
;
SVgObj
*
pVgroup
;
STableInfo
*
pTable
;
}
SQueuedMsg
;
int32_t
mgmtInitSystem
();
...
...
src/mnode/CMakeLists.txt
浏览文件 @
75b15760
...
...
@@ -14,6 +14,4 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
ADD_LIBRARY
(
mnode
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
mnode trpc tutil pthread
)
ENDIF
()
ENDIF
()
\ No newline at end of file
src/mnode/inc/mgmtProfile.h
浏览文件 @
75b15760
...
...
@@ -28,6 +28,8 @@ bool mgmtCheckQhandle(uint64_t qhandle);
void
mgmtSaveQhandle
(
void
*
qhandle
);
void
mgmtFreeQhandle
(
void
*
qhandle
);
void
*
mgmtMallocQueuedMsg
(
SRpcMsg
*
rpcMsg
);
void
*
mgmtCloneQueuedMsg
(
SQueuedMsg
*
pSrcMsg
);
void
mgmtFreeQueuedMsg
(
SQueuedMsg
*
pMsg
);
#ifdef __cplusplus
...
...
src/mnode/inc/mgmtTable.h
浏览文件 @
75b15760
...
...
@@ -28,8 +28,8 @@ extern "C" {
int32_t
mgmtInitTables
();
void
mgmtCleanUpTables
();
STableInfo
*
mgmtGetTable
(
char
*
tableId
);
void
mgmtIncTableRef
(
STableInfo
*
pTable
);
void
mgmtDecTableRef
(
STableInfo
*
pTable
);
void
mgmtIncTableRef
(
void
*
pTable
);
void
mgmtDecTableRef
(
void
*
pTable
);
void
mgmtDropAllChildTables
(
SDbObj
*
pDropDb
);
void
mgmtDropAllSuperTables
(
SDbObj
*
pDropDb
);
...
...
src/mnode/inc/mgmtVgroup.h
浏览文件 @
75b15760
...
...
@@ -27,9 +27,11 @@ extern "C" {
int32_t
mgmtInitVgroups
();
void
mgmtCleanUpVgroups
();
SVgObj
*
mgmtGetVgroup
(
int32_t
vgId
);
void
mgmtIncVgroupRef
(
SVgObj
*
pVgroup
);
void
mgmtDecVgroupRef
(
SVgObj
*
pVgroup
);
void
mgmtDropAllVgroups
(
SDbObj
*
pDropDb
);
void
mgmtCreateVgroup
(
SQueuedMsg
*
pMsg
);
void
mgmtCreateVgroup
(
SQueuedMsg
*
pMsg
,
SDbObj
*
pDb
);
void
mgmtDropVgroup
(
SVgObj
*
pVgroup
,
void
*
ahandle
);
void
mgmtAlterVgroup
(
SVgObj
*
pVgroup
,
void
*
ahandle
);
SVgObj
*
mgmtGetAvailableVgroup
(
SDbObj
*
pDb
);
...
...
src/mnode/src/mgmtAcct.c
浏览文件 @
75b15760
...
...
@@ -38,56 +38,25 @@ int32_t acctCheck(SAcctObj *pAcct, EAcctGrantType type) { return TSDB_CODE_SUC
#endif
void
acctAddDb
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pDb
->
next
=
pAcct
->
pHead
;
pDb
->
prev
=
NULL
;
atomic_add_fetch_32
(
&
pAcct
->
acctInfo
.
numOfDbs
,
1
);
pDb
->
pAcct
=
pAcct
;
if
(
pAcct
->
pHead
)
{
pAcct
->
pHead
->
prev
=
pDb
;
}
pAcct
->
pHead
=
pDb
;
pAcct
->
acctInfo
.
numOfDbs
++
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
acctIncRef
(
pAcct
);
}
void
acctRemoveDb
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
pthread_mutex_lock
(
&
pAcct
->
mutex
);
if
(
pDb
->
prev
)
{
pDb
->
prev
->
next
=
pDb
->
next
;
}
if
(
pDb
->
next
)
{
pDb
->
next
->
prev
=
pDb
->
prev
;
}
if
(
pDb
->
prev
==
NULL
)
{
pAcct
->
pHead
=
pDb
->
next
;
}
pAcct
->
acctInfo
.
numOfDbs
--
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
atomic_sub_fetch_32
(
&
pAcct
->
acctInfo
.
numOfDbs
,
1
);
pDb
->
pAcct
=
NULL
;
acctDecRef
(
pAcct
);
}
void
acctAddUser
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pAcct
->
acctInfo
.
numOfUsers
++
;
atomic_add_fetch_32
(
&
pAcct
->
acctInfo
.
numOfUsers
,
1
);
pUser
->
pAcct
=
pAcct
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
acctIncRef
(
pAcct
);
}
void
acctRemoveUser
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pAcct
->
acctInfo
.
numOfUsers
--
;
atomic_sub_fetch_32
(
&
pAcct
->
acctInfo
.
numOfUsers
,
1
);
pUser
->
pAcct
=
NULL
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
acctDecRef
(
pAcct
);
}
\ No newline at end of file
src/mnode/src/mgmtDb.c
浏览文件 @
75b15760
...
...
@@ -32,7 +32,7 @@
#include "mgmtUser.h"
#include "mgmtVgroup.h"
void
*
tsDbSdb
=
NULL
;
static
void
*
tsDbSdb
=
NULL
;
static
int32_t
tsDbUpdateSize
;
static
int32_t
mgmtCreateDb
(
SAcctObj
*
pAcct
,
SCMCreateDbMsg
*
pCreate
);
...
...
@@ -55,8 +55,6 @@ static int32_t mgmtDbActionInsert(SSdbOperDesc *pOper) {
pDb
->
pHead
=
NULL
;
pDb
->
pTail
=
NULL
;
pDb
->
prev
=
NULL
;
pDb
->
next
=
NULL
;
pDb
->
numOfVgroups
=
0
;
pDb
->
numOfTables
=
0
;
pDb
->
numOfSuperTables
=
0
;
...
...
@@ -288,8 +286,9 @@ static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
return
code
;
}
SDbObj
*
pDb
=
(
SDbObj
*
)
sdbGetRow
(
tsDbSdb
,
pCreate
->
db
);
SDbObj
*
pDb
=
mgmtGetDb
(
pCreate
->
db
);
if
(
pDb
!=
NULL
)
{
mgmtDecDbRef
(
pDb
);
return
TSDB_CODE_DB_ALREADY_EXIST
;
}
...
...
@@ -517,16 +516,14 @@ static int32_t mgmtGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn)
}
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
numOfRows
=
pUser
->
pAcct
->
acctInfo
.
numOfDbs
;
pShow
->
pNode
=
pUser
->
pAcct
->
pHead
;
mgmtDecUserRef
(
pUser
);
return
0
;
}
static
char
*
mgmtGetDbStr
(
char
*
src
)
{
char
*
pos
=
strstr
(
src
,
TS_PATH_DELIMITER
);
return
++
pos
;
}
...
...
@@ -539,14 +536,8 @@ static int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *
if
(
pUser
==
NULL
)
return
0
;
while
(
numOfRows
<
rows
)
{
p
Db
=
(
SDbObj
*
)
pShow
->
pNode
;
p
Show
->
pNode
=
sdbFetchRow
(
tsDbSdb
,
pShow
->
pNode
,
(
void
**
)
&
pDb
)
;
if
(
pDb
==
NULL
)
break
;
pShow
->
pNode
=
(
void
*
)
pDb
->
next
;
if
(
mgmtCheckIsMonitorDB
(
pDb
->
name
,
tsMonitorDbName
))
{
if
(
strcmp
(
pUser
->
user
,
"root"
)
!=
0
&&
strcmp
(
pUser
->
user
,
"_root"
)
!=
0
&&
strcmp
(
pUser
->
user
,
"monitor"
)
!=
0
)
{
continue
;
}
}
cols
=
0
;
...
...
@@ -643,25 +634,31 @@ static int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *
cols
++
;
numOfRows
++
;
mgmtDecDbRef
(
pDb
);
}
pShow
->
numOfReads
+=
numOfRows
;
mgmtDecUserRef
(
pUser
);
return
numOfRows
;
}
void
mgmtAddSuperTableIntoDb
(
SDbObj
*
pDb
)
{
atomic_add_fetch_32
(
&
pDb
->
numOfSuperTables
,
1
);
mgmtIncDbRef
(
pDb
);
}
void
mgmtRemoveSuperTableFromDb
(
SDbObj
*
pDb
)
{
atomic_add_fetch_32
(
&
pDb
->
numOfSuperTables
,
-
1
);
mgmtDecDbRef
(
pDb
);
}
void
mgmtAddTableIntoDb
(
SDbObj
*
pDb
)
{
atomic_add_fetch_32
(
&
pDb
->
numOfTables
,
1
);
mgmtIncDbRef
(
pDb
);
}
void
mgmtRemoveTableFromDb
(
SDbObj
*
pDb
)
{
atomic_add_fetch_32
(
&
pDb
->
numOfTables
,
-
1
);
mgmtDecDbRef
(
pDb
);
}
static
int32_t
mgmtSetDbDirty
(
SDbObj
*
pDb
)
{
...
...
@@ -800,15 +797,16 @@ static void mgmtProcessAlterDbMsg(SQueuedMsg *pMsg) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"db:%s, failed to alter, invalid db option"
,
pAlter
->
db
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
code
);
mgmtDecDbRef
(
pDb
);
return
;
}
SQueuedMsg
*
newMsg
=
malloc
(
sizeof
(
SQueuedMsg
));
memcpy
(
newMsg
,
pMsg
,
sizeof
(
SQueuedMsg
));
pMsg
->
pCont
=
NULL
;
SVgObj
*
pVgroup
=
pDb
->
pHead
;
if
(
pVgroup
!=
NULL
)
{
mPrint
(
"vgroup:%d, will be altered"
,
pVgroup
->
vgId
);
SQueuedMsg
*
newMsg
=
malloc
(
sizeof
(
SQueuedMsg
));
memcpy
(
newMsg
,
pMsg
,
sizeof
(
SQueuedMsg
));
memset
(
pMsg
,
0
,
sizeof
(
SQueuedMsg
));
newMsg
->
ahandle
=
pVgroup
;
newMsg
->
expected
=
pVgroup
->
numOfVnodes
;
mgmtAlterVgroup
(
pVgroup
,
newMsg
);
...
...
@@ -817,9 +815,9 @@ static void mgmtProcessAlterDbMsg(SQueuedMsg *pMsg) {
mTrace
(
"db:%s, all vgroups is altered"
,
pDb
->
name
);
mgmtSendSimpleResp
(
new
Msg
->
thandle
,
TSDB_CODE_SUCCESS
);
rpcFreeCont
(
new
Msg
->
pCont
);
free
(
newMsg
);
mgmtSendSimpleResp
(
p
Msg
->
thandle
,
TSDB_CODE_SUCCESS
);
rpcFreeCont
(
p
Msg
->
pCont
);
mgmtDecDbRef
(
pDb
);
}
static
void
mgmtDropDb
(
void
*
handle
,
void
*
tmrId
)
{
...
...
@@ -876,6 +874,7 @@ static void mgmtProcessDropDbMsg(SQueuedMsg *pMsg) {
if
(
mgmtCheckIsMonitorDB
(
pDb
->
name
,
tsMonitorDbName
))
{
mError
(
"db:%s, can't drop monitor database"
,
pDrop
->
db
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_MONITOR_DB_FORBIDDEN
);
mgmtDecDbRef
(
pDb
);
return
;
}
...
...
@@ -883,6 +882,7 @@ static void mgmtProcessDropDbMsg(SQueuedMsg *pMsg) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"db:%s, failed to drop, reason:%s"
,
pDrop
->
db
,
tstrerror
(
code
));
mgmtSendSimpleResp
(
pMsg
->
thandle
,
code
);
mgmtDecDbRef
(
pDb
);
return
;
}
...
...
@@ -919,6 +919,7 @@ void mgmtDropAllDbs(SAcctObj *pAcct) {
mgmtSetDbDirty
(
pDb
);
numOfDbs
++
;
}
mgmtDecDbRef
(
pDb
);
}
mTrace
(
"acct:%s, all dbs is is set dirty"
,
pAcct
->
user
,
numOfDbs
);
...
...
src/mnode/src/mgmtDnode.c
浏览文件 @
75b15760
...
...
@@ -215,6 +215,7 @@ void mgmtProcessDnodeStatusMsg(SRpcMsg *rpcMsg) {
mPrint
(
"dnode:%d, vgroup:%d not exist in mnode, drop it"
,
pDnode
->
dnodeId
,
pDnode
->
vload
[
j
].
vgId
);
mgmtSendDropVnodeMsg
(
pDnode
->
vload
[
j
].
vgId
,
&
ipSet
,
NULL
);
}
mgmtDecVgroupRef
(
pVgroup
);
}
if
(
pDnode
->
status
!=
TSDB_DN_STATUS_READY
)
{
...
...
src/mnode/src/mgmtProfile.c
浏览文件 @
75b15760
...
...
@@ -16,10 +16,13 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosmsg.h"
#include "mgmtDb.h"
#include "mgmtMnode.h"
#include "mgmtProfile.h"
#include "mgmtShell.h"
#include "mgmtTable.h"
#include "mgmtUser.h"
#include "mgmtVgroup.h"
int32_t
mgmtSaveQueryStreamList
(
SCMHeartBeatMsg
*
pHBMsg
);
...
...
@@ -763,12 +766,47 @@ int32_t mgmtInitProfile() {
void
mgmtCleanUpProfile
()
{
}
void
*
mgmtMallocQueuedMsg
(
SRpcMsg
*
rpcMsg
)
{
bool
usePublicIp
=
false
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
rpcMsg
->
handle
,
&
usePublicIp
);
if
(
pUser
==
NULL
)
{
return
NULL
;
}
SQueuedMsg
*
pMsg
=
calloc
(
1
,
sizeof
(
SQueuedMsg
));
pMsg
->
thandle
=
rpcMsg
->
handle
;
pMsg
->
msgType
=
rpcMsg
->
msgType
;
pMsg
->
contLen
=
rpcMsg
->
contLen
;
pMsg
->
pCont
=
rpcMsg
->
pCont
;
pMsg
->
pUser
=
pUser
;
pMsg
->
usePublicIp
=
usePublicIp
;
return
pMsg
;
}
void
mgmtFreeQueuedMsg
(
SQueuedMsg
*
pMsg
)
{
if
(
pMsg
!=
NULL
)
{
if
(
pMsg
->
pCont
!=
NULL
)
{
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
}
rpcFreeCont
(
pMsg
->
pCont
);
if
(
pMsg
->
pUser
)
mgmtDecUserRef
(
pMsg
->
pUser
);
if
(
pMsg
->
pDb
)
mgmtDecDbRef
(
pMsg
->
pDb
);
if
(
pMsg
->
pVgroup
)
mgmtDecVgroupRef
(
pMsg
->
pVgroup
);
if
(
pMsg
->
pTable
)
mgmtDecTableRef
(
pMsg
->
pTable
);
free
(
pMsg
);
}
}
void
*
mgmtCloneQueuedMsg
(
SQueuedMsg
*
pSrcMsg
)
{
SQueuedMsg
*
pDestMsg
=
calloc
(
1
,
sizeof
(
SQueuedMsg
));
pDestMsg
->
thandle
=
pSrcMsg
->
thandle
;
pDestMsg
->
msgType
=
pSrcMsg
->
msgType
;
pDestMsg
->
pCont
=
pSrcMsg
->
pCont
;
pDestMsg
->
contLen
=
pSrcMsg
->
contLen
;
pDestMsg
->
pUser
=
pSrcMsg
->
pUser
;
pDestMsg
->
usePublicIp
=
pSrcMsg
->
usePublicIp
;
pSrcMsg
->
pCont
=
NULL
;
pSrcMsg
->
pUser
=
NULL
;
return
pDestMsg
;
}
\ No newline at end of file
src/mnode/src/mgmtSdb.c
浏览文件 @
75b15760
...
...
@@ -435,7 +435,7 @@ void sdbIncRef(void *handle, void *pRow) {
SSdbTable
*
pTable
=
handle
;
int32_t
*
pRefCount
=
(
int32_t
*
)(
pRow
+
pTable
->
refCountPos
);
atomic_add_fetch_32
(
pRefCount
,
1
);
sdbTrace
(
"
table:%s, add ref:%d to record:%s"
,
pTable
->
tableName
,
*
pRefCount
,
sdbGetkeyStr
(
pTable
,
pRow
)
);
sdbTrace
(
"
add ref to record:%s:%s:%d"
,
pTable
->
tableName
,
sdbGetkeyStr
(
pTable
,
pRow
),
*
pRefCount
);
}
}
...
...
@@ -444,7 +444,7 @@ void sdbDecRef(void *handle, void *pRow) {
SSdbTable
*
pTable
=
handle
;
int32_t
*
pRefCount
=
(
int32_t
*
)(
pRow
+
pTable
->
refCountPos
);
int32_t
refCount
=
atomic_sub_fetch_32
(
pRefCount
,
1
);
sdbTrace
(
"
table:%s, def ref:%d from record:%s"
,
pTable
->
tableName
,
*
pRefCount
,
sdbGetkeyStr
(
pTable
,
pRow
)
);
sdbTrace
(
"
def ref of record:%s:%s:%d"
,
pTable
->
tableName
,
sdbGetkeyStr
(
pTable
,
pRow
),
*
pRefCount
);
if
(
refCount
<=
0
)
{
SSdbOperDesc
oper
=
{.
pObj
=
pRow
};
(
*
pTable
->
destroyFp
)(
&
oper
);
...
...
src/mnode/src/mgmtShell.c
浏览文件 @
75b15760
...
...
@@ -117,9 +117,7 @@ void mgmtAddShellShowRetrieveHandle(uint8_t msgType, SShowRetrieveFp fp) {
void
mgmtProcessTranRequest
(
SSchedMsg
*
sched
)
{
SQueuedMsg
*
queuedMsg
=
sched
->
msg
;
(
*
tsMgmtProcessShellMsgFp
[
queuedMsg
->
msgType
])(
queuedMsg
);
mgmtDecUserRef
(
queuedMsg
->
pUser
);
rpcFreeCont
(
queuedMsg
->
pCont
);
free
(
queuedMsg
);
mgmtFreeQueuedMsg
(
queuedMsg
);
}
void
mgmtAddToShellQueue
(
SQueuedMsg
*
queuedMsg
)
{
...
...
@@ -134,6 +132,12 @@ static void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) {
return
;
}
if
(
mgmtCheckRedirect
(
rpcMsg
->
handle
))
{
// send resp in redirect func
rpcFreeCont
(
rpcMsg
->
pCont
);
return
;
}
if
(
!
mgmtInServerStatus
())
{
mgmtProcessMsgWhileNotReady
(
rpcMsg
);
rpcFreeCont
(
rpcMsg
->
pCont
);
...
...
@@ -142,6 +146,7 @@ static void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) {
if
(
grantCheck
(
TSDB_GRANT_TIME
)
!=
TSDB_CODE_SUCCESS
)
{
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_GRANT_EXPIRED
);
rpcFreeCont
(
rpcMsg
->
pCont
);
return
;
}
...
...
@@ -151,45 +156,28 @@ static void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) {
return
;
}
bool
usePublicIp
=
false
;
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
rpcMsg
->
handle
,
&
usePublicIp
);
if
(
pUser
==
NULL
)
{
SQueuedMsg
*
pMsg
=
mgmtMallocQueuedMsg
(
rpcMsg
);
if
(
pMsg
==
NULL
)
{
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_INVALID_USER
);
rpcFreeCont
(
rpcMsg
->
pCont
);
return
;
}
if
(
mgmtCheckMsgReadOnly
(
rpcMsg
->
msgType
,
rpcMsg
->
pCont
))
{
SQueuedMsg
queuedMsg
=
{
0
};
queuedMsg
.
thandle
=
rpcMsg
->
handle
;
queuedMsg
.
msgType
=
rpcMsg
->
msgType
;
queuedMsg
.
contLen
=
rpcMsg
->
contLen
;
queuedMsg
.
pCont
=
rpcMsg
->
pCont
;
queuedMsg
.
pUser
=
pUser
;
queuedMsg
.
usePublicIp
=
usePublicIp
;
(
*
tsMgmtProcessShellMsgFp
[
rpcMsg
->
msgType
])(
&
queuedMsg
);
mgmtDecUserRef
(
pUser
);
rpcFreeCont
(
rpcMsg
->
pCont
);
(
*
tsMgmtProcessShellMsgFp
[
rpcMsg
->
msgType
])(
pMsg
);
mgmtFreeQueuedMsg
(
pMsg
);
}
else
{
SQueuedMsg
*
queuedMsg
=
calloc
(
1
,
sizeof
(
SQueuedMsg
));
queuedMsg
->
thandle
=
rpcMsg
->
handle
;
queuedMsg
->
msgType
=
rpcMsg
->
msgType
;
queuedMsg
->
contLen
=
rpcMsg
->
contLen
;
queuedMsg
->
pCont
=
rpcMsg
->
pCont
;
queuedMsg
->
pUser
=
pUser
;
queuedMsg
->
usePublicIp
=
usePublicIp
;
mgmtAddToShellQueue
(
queuedMsg
);
if
(
!
pMsg
->
pUser
->
writeAuth
)
{
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_NO_RIGHTS
);
mgmtFreeQueuedMsg
(
pMsg
);
}
else
{
mgmtAddToShellQueue
(
pMsg
);
}
}
}
static
void
mgmtProcessShowMsg
(
SQueuedMsg
*
pMsg
)
{
SCMShowMsg
*
pShowMsg
=
pMsg
->
pCont
;
if
(
pShowMsg
->
type
==
TSDB_MGMT_TABLE_DNODE
||
TSDB_MGMT_TABLE_GRANTS
||
TSDB_MGMT_TABLE_SCORES
)
{
if
(
mgmtCheckRedirect
(
pMsg
->
thandle
))
{
return
;
}
}
if
(
pShowMsg
->
type
>=
TSDB_MGMT_TABLE_MAX
)
{
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_INVALID_MSG_TYPE
);
return
;
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
75b15760
此差异已折叠。
点击以展开。
src/mnode/src/mgmtUser.c
浏览文件 @
75b15760
...
...
@@ -25,7 +25,7 @@
#include "mgmtShell.h"
#include "mgmtUser.h"
static
void
*
tsUserSdb
=
NULL
;
static
void
*
tsUserSdb
=
NULL
;
static
int32_t
tsUserUpdateSize
=
0
;
static
int32_t
mgmtGetUserMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtRetrieveUsers
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
...
...
@@ -44,7 +44,6 @@ static int32_t mgmtUserActionInsert(SSdbOperDesc *pOper) {
if
(
pAcct
!=
NULL
)
{
acctAddUser
(
pAcct
,
pUser
);
acctDecRef
(
pAcct
);
}
else
{
mError
(
"user:%s, acct:%s info not exist in sdb"
,
pUser
->
user
,
pUser
->
acct
);
...
...
@@ -60,7 +59,6 @@ static int32_t mgmtUserActionDelete(SSdbOperDesc *pOper) {
if
(
pAcct
!=
NULL
)
{
acctRemoveUser
(
pAcct
,
pUser
);
acctDecRef
(
pAcct
);
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -426,7 +424,7 @@ static void mgmtProcessAlterUserMsg(SQueuedMsg *pMsg) {
mgmtSendSimpleResp
(
pMsg
->
thandle
,
code
);
}
else
{
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_NO_RIGHTS
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_NO_RIGHTS
);
}
mgmtDecUserRef
(
pUser
);
...
...
src/mnode/src/mgmtVgroup.c
浏览文件 @
75b15760
...
...
@@ -175,6 +175,14 @@ int32_t mgmtInitVgroups() {
return
0
;
}
void
mgmtIncVgroupRef
(
SVgObj
*
pVgroup
)
{
return
sdbIncRef
(
tsVgroupSdb
,
pVgroup
);
}
void
mgmtDecVgroupRef
(
SVgObj
*
pVgroup
)
{
return
sdbDecRef
(
tsVgroupSdb
,
pVgroup
);
}
SVgObj
*
mgmtGetVgroup
(
int32_t
vgId
)
{
return
(
SVgObj
*
)
sdbGetRow
(
tsVgroupSdb
,
&
vgId
);
}
...
...
@@ -183,15 +191,7 @@ SVgObj *mgmtGetAvailableVgroup(SDbObj *pDb) {
return
pDb
->
pHead
;
}
void
mgmtCreateVgroup
(
SQueuedMsg
*
pMsg
)
{
SDbObj
*
pDb
=
pMsg
->
pDb
;
if
(
pDb
==
NULL
)
{
mError
(
"failed to create vgroup, db not found"
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_INVALID_DB
);
mgmtFreeQueuedMsg
(
pMsg
);
return
;
}
void
mgmtCreateVgroup
(
SQueuedMsg
*
pMsg
,
SDbObj
*
pDb
)
{
SVgObj
*
pVgroup
=
(
SVgObj
*
)
calloc
(
1
,
sizeof
(
SVgObj
));
strcpy
(
pVgroup
->
dbName
,
pDb
->
name
);
pVgroup
->
numOfVnodes
=
pDb
->
cfg
.
replications
;
...
...
@@ -548,7 +548,6 @@ static void mgmtProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
SQueuedMsg
*
newMsg
=
calloc
(
1
,
sizeof
(
SQueuedMsg
));
newMsg
->
msgType
=
queueMsg
->
msgType
;
newMsg
->
thandle
=
queueMsg
->
thandle
;
newMsg
->
pDb
=
queueMsg
->
pDb
;
newMsg
->
pUser
=
queueMsg
->
pUser
;
newMsg
->
contLen
=
queueMsg
->
contLen
;
newMsg
->
pCont
=
rpcMallocCont
(
newMsg
->
contLen
);
...
...
@@ -632,7 +631,6 @@ static void mgmtProcessDropVnodeRsp(SRpcMsg *rpcMsg) {
SQueuedMsg
*
newMsg
=
calloc
(
1
,
sizeof
(
SQueuedMsg
));
newMsg
->
msgType
=
queueMsg
->
msgType
;
newMsg
->
thandle
=
queueMsg
->
thandle
;
newMsg
->
pDb
=
queueMsg
->
pDb
;
newMsg
->
pUser
=
queueMsg
->
pUser
;
newMsg
->
contLen
=
queueMsg
->
contLen
;
newMsg
->
pCont
=
rpcMallocCont
(
newMsg
->
contLen
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录