Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
fa9a4099
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fa9a4099
编写于
3月 24, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'refact/sync' into refact/slguan
上级
930f4f16
eabc5511
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
169 addition
and
146 deletion
+169
-146
src/dnode/src/dnodeMgmt.c
src/dnode/src/dnodeMgmt.c
+4
-4
src/dnode/src/dnodeRead.c
src/dnode/src/dnodeRead.c
+25
-24
src/dnode/src/dnodeWrite.c
src/dnode/src/dnodeWrite.c
+27
-24
src/rpc/test/rserver.c
src/rpc/test/rserver.c
+22
-10
src/util/inc/tlog.h
src/util/inc/tlog.h
+1
-1
src/util/inc/tqueue.h
src/util/inc/tqueue.h
+17
-10
src/util/src/tqueue.c
src/util/src/tqueue.c
+71
-71
src/util/src/tsocket.c
src/util/src/tsocket.c
+2
-2
未找到文件。
src/dnode/src/dnodeMgmt.c
浏览文件 @
fa9a4099
...
@@ -225,8 +225,8 @@ static int32_t dnodeOpenVnode(int32_t vnode, char *rootDir) {
...
@@ -225,8 +225,8 @@ static int32_t dnodeOpenVnode(int32_t vnode, char *rootDir) {
vnodeObj
.
status
=
TSDB_VN_STATUS_NOT_READY
;
vnodeObj
.
status
=
TSDB_VN_STATUS_NOT_READY
;
vnodeObj
.
refCount
=
1
;
vnodeObj
.
refCount
=
1
;
vnodeObj
.
version
=
0
;
vnodeObj
.
version
=
0
;
vnodeObj
.
wworker
=
dnodeAllocateWriteWorker
();
vnodeObj
.
wworker
=
dnodeAllocateWriteWorker
(
&
vnodeObj
);
vnodeObj
.
rworker
=
dnodeAllocateReadWorker
();
vnodeObj
.
rworker
=
dnodeAllocateReadWorker
(
&
vnodeObj
);
vnodeObj
.
wal
=
NULL
;
vnodeObj
.
wal
=
NULL
;
vnodeObj
.
tsdb
=
pTsdb
;
vnodeObj
.
tsdb
=
pTsdb
;
vnodeObj
.
replica
=
NULL
;
vnodeObj
.
replica
=
NULL
;
...
@@ -314,8 +314,8 @@ static int32_t dnodeCreateVnode(SMDCreateVnodeMsg *pVnodeCfg) {
...
@@ -314,8 +314,8 @@ static int32_t dnodeCreateVnode(SMDCreateVnodeMsg *pVnodeCfg) {
vnodeObj
.
status
=
TSDB_VN_STATUS_NOT_READY
;
vnodeObj
.
status
=
TSDB_VN_STATUS_NOT_READY
;
vnodeObj
.
refCount
=
1
;
vnodeObj
.
refCount
=
1
;
vnodeObj
.
version
=
0
;
vnodeObj
.
version
=
0
;
vnodeObj
.
wworker
=
dnodeAllocateWriteWorker
();
vnodeObj
.
wworker
=
dnodeAllocateWriteWorker
(
&
vnodeObj
);
vnodeObj
.
rworker
=
dnodeAllocateReadWorker
();
vnodeObj
.
rworker
=
dnodeAllocateReadWorker
(
&
vnodeObj
);
vnodeObj
.
wal
=
NULL
;
vnodeObj
.
wal
=
NULL
;
vnodeObj
.
tsdb
=
pTsdb
;
vnodeObj
.
tsdb
=
pTsdb
;
vnodeObj
.
replica
=
NULL
;
vnodeObj
.
replica
=
NULL
;
...
...
src/dnode/src/dnodeRead.c
浏览文件 @
fa9a4099
...
@@ -36,16 +36,15 @@ typedef struct {
...
@@ -36,16 +36,15 @@ typedef struct {
void
*
pCont
;
void
*
pCont
;
int32_t
contLen
;
int32_t
contLen
;
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
void
*
pVnode
;
SRpcContext
*
pRpcContext
;
// RPC message context
SRpcContext
*
pRpcContext
;
// RPC message context
}
SReadMsg
;
}
SReadMsg
;
static
void
*
dnodeProcessReadQueue
(
void
*
param
);
static
void
*
dnodeProcessReadQueue
(
void
*
param
);
static
void
dnodeProcessReadResult
(
SReadMsg
*
pRead
);
static
void
dnodeProcessReadResult
(
void
*
pVnode
,
SReadMsg
*
pRead
);
static
void
dnodeHandleIdleReadWorker
();
static
void
dnodeHandleIdleReadWorker
();
static
void
dnodeProcessQueryMsg
(
SReadMsg
*
pMsg
);
static
void
dnodeProcessQueryMsg
(
void
*
pVnode
,
SReadMsg
*
pMsg
);
static
void
dnodeProcessRetrieveMsg
(
SReadMsg
*
pMsg
);
static
void
dnodeProcessRetrieveMsg
(
void
*
pVnode
,
SReadMsg
*
pMsg
);
static
void
(
*
dnodeProcessReadMsgFp
[
TSDB_MSG_TYPE_MAX
])(
SReadMsg
*
pNode
);
static
void
(
*
dnodeProcessReadMsgFp
[
TSDB_MSG_TYPE_MAX
])(
void
*
pVnode
,
SReadMsg
*
pNode
);
// module global variable
// module global variable
static
taos_qset
readQset
;
static
taos_qset
readQset
;
...
@@ -93,7 +92,7 @@ void dnodeRead(SRpcMsg *pMsg) {
...
@@ -93,7 +92,7 @@ void dnodeRead(SRpcMsg *pMsg) {
while
(
leftLen
>
0
)
{
while
(
leftLen
>
0
)
{
SMsgHead
*
pHead
=
(
SMsgHead
*
)
pCont
;
SMsgHead
*
pHead
=
(
SMsgHead
*
)
pCont
;
pHead
->
vgId
=
1
;
//htonl(pHead->vgId);
pHead
->
vgId
=
1
;
//htonl(pHead->vgId);
pHead
->
contLen
=
pMsg
->
contLen
;
//htonl(pHead->contLen);
pHead
->
contLen
=
pMsg
->
contLen
;
//htonl(pHead->contLen);
void
*
pVnode
=
dnodeGetVnode
(
pHead
->
vgId
);
void
*
pVnode
=
dnodeGetVnode
(
pHead
->
vgId
);
...
@@ -104,22 +103,19 @@ void dnodeRead(SRpcMsg *pMsg) {
...
@@ -104,22 +103,19 @@ void dnodeRead(SRpcMsg *pMsg) {
}
}
// put message into queue
// put message into queue
SReadMsg
readMsg
;
SReadMsg
*
pRead
=
(
SReadMsg
*
)
taosAllocateQitem
(
sizeof
(
SReadMsg
));
readMsg
.
rpcMsg
=
*
pMsg
;
pRead
->
rpcMsg
=
*
pMsg
;
readMsg
.
pCont
=
pCont
;
pRead
->
pCont
=
pCont
;
readMsg
.
contLen
=
pHead
->
contLen
;
pRead
->
contLen
=
pHead
->
contLen
;
readMsg
.
pRpcContext
=
pRpcContext
;
pRead
->
pRpcContext
=
pRpcContext
;
readMsg
.
pVnode
=
pVnode
;
taos_queue
queue
=
dnodeGetVnodeRworker
(
pVnode
);
taos_queue
queue
=
dnodeGetVnodeRworker
(
pVnode
);
taosWriteQitem
(
queue
,
&
readMsg
);
taosWriteQitem
(
queue
,
TAOS_QTYPE_RPC
,
pRead
);
// next vnode
// next vnode
leftLen
-=
pHead
->
contLen
;
leftLen
-=
pHead
->
contLen
;
pCont
-=
pHead
->
contLen
;
pCont
-=
pHead
->
contLen
;
queuedMsgNum
++
;
queuedMsgNum
++
;
dnodeReleaseVnode
(
pVnode
);
}
}
if
(
queuedMsgNum
==
0
)
{
if
(
queuedMsgNum
==
0
)
{
...
@@ -134,11 +130,11 @@ void dnodeRead(SRpcMsg *pMsg) {
...
@@ -134,11 +130,11 @@ void dnodeRead(SRpcMsg *pMsg) {
}
}
}
}
void
*
dnodeAllocateReadWorker
()
{
void
*
dnodeAllocateReadWorker
(
void
*
pVnode
)
{
taos_queue
*
queue
=
taosOpenQueue
(
sizeof
(
SReadMsg
));
taos_queue
*
queue
=
taosOpenQueue
(
sizeof
(
SReadMsg
));
if
(
queue
==
NULL
)
return
NULL
;
if
(
queue
==
NULL
)
return
NULL
;
taosAddIntoQset
(
readQset
,
queue
);
taosAddIntoQset
(
readQset
,
queue
,
pVnode
);
// spawn a thread to process queue
// spawn a thread to process queue
if
(
threads
<
maxThreads
)
{
if
(
threads
<
maxThreads
)
{
...
@@ -163,22 +159,27 @@ void dnodeFreeReadWorker(void *rqueue) {
...
@@ -163,22 +159,27 @@ void dnodeFreeReadWorker(void *rqueue) {
static
void
*
dnodeProcessReadQueue
(
void
*
param
)
{
static
void
*
dnodeProcessReadQueue
(
void
*
param
)
{
taos_qset
qset
=
(
taos_qset
)
param
;
taos_qset
qset
=
(
taos_qset
)
param
;
SReadMsg
readMsg
;
SReadMsg
*
pReadMsg
;
int
type
;
void
*
pVnode
;
while
(
1
)
{
while
(
1
)
{
if
(
taosReadQitemFromQset
(
qset
,
&
readMsg
)
<
=
0
)
{
if
(
taosReadQitemFromQset
(
qset
,
&
type
,
&
pReadMsg
,
&
pVnode
)
=
=
0
)
{
dnodeHandleIdleReadWorker
();
dnodeHandleIdleReadWorker
();
continue
;
continue
;
}
}
terrno
=
0
;
terrno
=
0
;
if
(
dnodeProcessReadMsgFp
[
readMsg
.
rpcMsg
.
msgType
])
{
if
(
dnodeProcessReadMsgFp
[
pReadMsg
->
rpcMsg
.
msgType
])
{
(
*
dnodeProcessReadMsgFp
[
readMsg
.
rpcMsg
.
msgType
])
(
&
r
eadMsg
);
(
*
dnodeProcessReadMsgFp
[
pReadMsg
->
rpcMsg
.
msgType
])
(
pVnode
,
pR
eadMsg
);
}
else
{
}
else
{
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
}
}
dnodeProcessReadResult
(
&
readMsg
);
dnodeProcessReadResult
(
pVnode
,
pReadMsg
);
taosFreeQitem
(
pReadMsg
);
dnodeReleaseVnode
(
pVnode
);
}
}
return
NULL
;
return
NULL
;
...
@@ -196,11 +197,11 @@ static void dnodeHandleIdleReadWorker() {
...
@@ -196,11 +197,11 @@ static void dnodeHandleIdleReadWorker() {
}
}
}
}
static
void
dnodeProcessReadResult
(
SReadMsg
*
pRead
)
{
static
void
dnodeProcessReadResult
(
void
*
pVnode
,
SReadMsg
*
pRead
)
{
SRpcContext
*
pRpcContext
=
pRead
->
pRpcContext
;
SRpcContext
*
pRpcContext
=
pRead
->
pRpcContext
;
int32_t
code
=
0
;
int32_t
code
=
0
;
dnodeReleaseVnode
(
p
Read
->
p
Vnode
);
dnodeReleaseVnode
(
pVnode
);
if
(
pRpcContext
)
{
if
(
pRpcContext
)
{
if
(
terrno
)
{
if
(
terrno
)
{
...
...
src/dnode/src/dnodeWrite.c
浏览文件 @
fa9a4099
...
@@ -35,7 +35,6 @@ typedef struct _write {
...
@@ -35,7 +35,6 @@ typedef struct _write {
void
*
pCont
;
void
*
pCont
;
int32_t
contLen
;
int32_t
contLen
;
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
void
*
pVnode
;
// pointer to vnode
SRpcContext
*
pRpcContext
;
// RPC message context
SRpcContext
*
pRpcContext
;
// RPC message context
}
SWriteMsg
;
}
SWriteMsg
;
...
@@ -51,7 +50,7 @@ typedef struct _thread_obj {
...
@@ -51,7 +50,7 @@ typedef struct _thread_obj {
SWriteWorker
*
writeWorker
;
SWriteWorker
*
writeWorker
;
}
SWriteWorkerPool
;
}
SWriteWorkerPool
;
static
void
(
*
dnodeProcessWriteMsgFp
[
TSDB_MSG_TYPE_MAX
])(
SWriteMsg
*
);
static
void
(
*
dnodeProcessWriteMsgFp
[
TSDB_MSG_TYPE_MAX
])(
void
*
,
SWriteMsg
*
);
static
void
*
dnodeProcessWriteQueue
(
void
*
param
);
static
void
*
dnodeProcessWriteQueue
(
void
*
param
);
static
void
dnodeHandleIdleWorker
(
SWriteWorker
*
pWorker
);
static
void
dnodeHandleIdleWorker
(
SWriteWorker
*
pWorker
);
static
void
dnodeProcessWriteResult
(
SWriteMsg
*
pWrite
);
static
void
dnodeProcessWriteResult
(
SWriteMsg
*
pWrite
);
...
@@ -116,15 +115,14 @@ void dnodeWrite(SRpcMsg *pMsg) {
...
@@ -116,15 +115,14 @@ void dnodeWrite(SRpcMsg *pMsg) {
}
}
// put message into queue
// put message into queue
SWriteMsg
writeMsg
;
SWriteMsg
*
pWrite
=
(
SWriteMsg
*
)
taosAllocateQitem
(
sizeof
(
SWriteMsg
));
writeMsg
.
rpcMsg
=
*
pMsg
;
pWrite
->
rpcMsg
=
*
pMsg
;
writeMsg
.
pCont
=
pCont
;
pWrite
->
pCont
=
pCont
;
writeMsg
.
contLen
=
pHead
->
contLen
;
pWrite
->
contLen
=
pHead
->
contLen
;
writeMsg
.
pRpcContext
=
pRpcContext
;
pWrite
->
pRpcContext
=
pRpcContext
;
writeMsg
.
pVnode
=
pVnode
;
// pVnode shall be saved for usage later
taos_queue
queue
=
dnodeGetVnodeWworker
(
pVnode
);
taos_queue
queue
=
dnodeGetVnodeWworker
(
pVnode
);
taosWriteQitem
(
queue
,
&
writeMsg
);
taosWriteQitem
(
queue
,
TAOS_QTYPE_RPC
,
pWrite
);
// next vnode
// next vnode
leftLen
-=
pHead
->
contLen
;
leftLen
-=
pHead
->
contLen
;
...
@@ -144,16 +142,16 @@ void dnodeWrite(SRpcMsg *pMsg) {
...
@@ -144,16 +142,16 @@ void dnodeWrite(SRpcMsg *pMsg) {
}
}
}
}
void
*
dnodeAllocateWriteWorker
()
{
void
*
dnodeAllocateWriteWorker
(
void
*
pVnode
)
{
SWriteWorker
*
pWorker
=
wWorkerPool
.
writeWorker
+
wWorkerPool
.
nextId
;
SWriteWorker
*
pWorker
=
wWorkerPool
.
writeWorker
+
wWorkerPool
.
nextId
;
taos_queue
*
queue
=
taosOpenQueue
(
sizeof
(
SWriteMsg
)
);
taos_queue
*
queue
=
taosOpenQueue
();
if
(
queue
==
NULL
)
return
NULL
;
if
(
queue
==
NULL
)
return
NULL
;
if
(
pWorker
->
qset
==
NULL
)
{
if
(
pWorker
->
qset
==
NULL
)
{
pWorker
->
qset
=
taosOpenQset
();
pWorker
->
qset
=
taosOpenQset
();
if
(
pWorker
->
qset
==
NULL
)
return
NULL
;
if
(
pWorker
->
qset
==
NULL
)
return
NULL
;
taosAddIntoQset
(
pWorker
->
qset
,
queue
);
taosAddIntoQset
(
pWorker
->
qset
,
queue
,
pVnode
);
wWorkerPool
.
nextId
=
(
wWorkerPool
.
nextId
+
1
)
%
wWorkerPool
.
max
;
wWorkerPool
.
nextId
=
(
wWorkerPool
.
nextId
+
1
)
%
wWorkerPool
.
max
;
pthread_attr_t
thAttr
;
pthread_attr_t
thAttr
;
...
@@ -165,7 +163,7 @@ void *dnodeAllocateWriteWorker() {
...
@@ -165,7 +163,7 @@ void *dnodeAllocateWriteWorker() {
taosCloseQset
(
pWorker
->
qset
);
taosCloseQset
(
pWorker
->
qset
);
}
}
}
else
{
}
else
{
taosAddIntoQset
(
pWorker
->
qset
,
queue
);
taosAddIntoQset
(
pWorker
->
qset
,
queue
,
pVnode
);
wWorkerPool
.
nextId
=
(
wWorkerPool
.
nextId
+
1
)
%
wWorkerPool
.
max
;
wWorkerPool
.
nextId
=
(
wWorkerPool
.
nextId
+
1
)
%
wWorkerPool
.
max
;
}
}
...
@@ -181,11 +179,15 @@ void dnodeFreeWriteWorker(void *wqueue) {
...
@@ -181,11 +179,15 @@ void dnodeFreeWriteWorker(void *wqueue) {
static
void
*
dnodeProcessWriteQueue
(
void
*
param
)
{
static
void
*
dnodeProcessWriteQueue
(
void
*
param
)
{
SWriteWorker
*
pWorker
=
(
SWriteWorker
*
)
param
;
SWriteWorker
*
pWorker
=
(
SWriteWorker
*
)
param
;
taos_qall
qall
;
taos_qall
qall
;
SWriteMsg
w
riteMsg
;
SWriteMsg
*
pW
riteMsg
;
int32_t
numOfMsgs
;
int32_t
numOfMsgs
;
int
type
;
void
*
pVnode
;
qall
=
taosAllocateQall
();
while
(
1
)
{
while
(
1
)
{
numOfMsgs
=
taosReadAllQitemsFromQset
(
pWorker
->
qset
,
&
qall
);
numOfMsgs
=
taosReadAllQitemsFromQset
(
pWorker
->
qset
,
qall
,
&
pVnode
);
if
(
numOfMsgs
<=
0
)
{
if
(
numOfMsgs
<=
0
)
{
dnodeHandleIdleWorker
(
pWorker
);
// thread exit if no queues anymore
dnodeHandleIdleWorker
(
pWorker
);
// thread exit if no queues anymore
continue
;
continue
;
...
@@ -193,7 +195,7 @@ static void *dnodeProcessWriteQueue(void *param) {
...
@@ -193,7 +195,7 @@ static void *dnodeProcessWriteQueue(void *param) {
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
// retrieve all items, and write them into WAL
// retrieve all items, and write them into WAL
taosGetQitem
(
qall
,
&
w
riteMsg
);
taosGetQitem
(
qall
,
&
type
,
&
pW
riteMsg
);
// walWrite(pVnode->whandle, writeMsg.rpcMsg.msgType, writeMsg.pCont, writeMsg.contLen);
// walWrite(pVnode->whandle, writeMsg.rpcMsg.msgType, writeMsg.pCont, writeMsg.contLen);
}
}
...
@@ -204,30 +206,31 @@ static void *dnodeProcessWriteQueue(void *param) {
...
@@ -204,30 +206,31 @@ static void *dnodeProcessWriteQueue(void *param) {
// browse all items, and process them one by one
// browse all items, and process them one by one
taosResetQitems
(
qall
);
taosResetQitems
(
qall
);
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
taosGetQitem
(
qall
,
&
w
riteMsg
);
taosGetQitem
(
qall
,
&
type
,
&
pW
riteMsg
);
terrno
=
0
;
terrno
=
0
;
if
(
dnodeProcessWriteMsgFp
[
writeMsg
.
rpcMsg
.
msgType
])
{
if
(
dnodeProcessWriteMsgFp
[
pWriteMsg
->
rpcMsg
.
msgType
])
{
(
*
dnodeProcessWriteMsgFp
[
writeMsg
.
rpcMsg
.
msgType
])
(
&
w
riteMsg
);
(
*
dnodeProcessWriteMsgFp
[
pWriteMsg
->
rpcMsg
.
msgType
])
(
pVnode
,
pW
riteMsg
);
}
else
{
}
else
{
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
}
}
dnodeProcessWriteResult
(
&
writeMsg
);
dnodeProcessWriteResult
(
pVnode
,
pWriteMsg
);
taosFreeQitem
(
pWriteMsg
);
}
}
// free the Qitems;
taosFreeQitems
(
qall
);
}
}
taosFreeQall
(
qall
);
return
NULL
;
return
NULL
;
}
}
static
void
dnodeProcessWriteResult
(
SWriteMsg
*
pWrite
)
{
static
void
dnodeProcessWriteResult
(
void
*
pVnode
,
SWriteMsg
*
pWrite
)
{
SRpcContext
*
pRpcContext
=
pWrite
->
pRpcContext
;
SRpcContext
*
pRpcContext
=
pWrite
->
pRpcContext
;
int32_t
code
=
0
;
int32_t
code
=
0
;
dnodeReleaseVnode
(
p
Write
->
p
Vnode
);
dnodeReleaseVnode
(
pVnode
);
if
(
pRpcContext
)
{
if
(
pRpcContext
)
{
if
(
terrno
)
{
if
(
terrno
)
{
...
...
src/rpc/test/rserver.c
浏览文件 @
fa9a4099
...
@@ -28,10 +28,13 @@ void *qhandle = NULL;
...
@@ -28,10 +28,13 @@ void *qhandle = NULL;
void
processShellMsg
()
{
void
processShellMsg
()
{
static
int
num
=
0
;
static
int
num
=
0
;
taos_qall
qall
;
taos_qall
qall
;
SRpcMsg
rpcMsg
;
SRpcMsg
*
pRpcMsg
,
rpcMsg
;
int
type
;
qall
=
taosAllocateQall
();
while
(
1
)
{
while
(
1
)
{
int
numOfMsgs
=
taosReadAllQitems
(
qhandle
,
&
qall
);
int
numOfMsgs
=
taosReadAllQitems
(
qhandle
,
qall
);
if
(
numOfMsgs
<=
0
)
{
if
(
numOfMsgs
<=
0
)
{
usleep
(
1000
);
usleep
(
1000
);
continue
;
continue
;
...
@@ -40,10 +43,10 @@ void processShellMsg() {
...
@@ -40,10 +43,10 @@ void processShellMsg() {
tTrace
(
"%d shell msgs are received"
,
numOfMsgs
);
tTrace
(
"%d shell msgs are received"
,
numOfMsgs
);
for
(
int
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
taosGetQitem
(
qall
,
&
r
pcMsg
);
taosGetQitem
(
qall
,
&
type
,
(
void
**
)
&
pR
pcMsg
);
if
(
dataFd
>=
0
)
{
if
(
dataFd
>=
0
)
{
if
(
write
(
dataFd
,
rpcMsg
.
pCont
,
rpcMsg
.
contLen
)
<
0
)
{
if
(
write
(
dataFd
,
pRpcMsg
->
pCont
,
pRpcMsg
->
contLen
)
<
0
)
{
tPrint
(
"failed to write data file, reason:%s"
,
strerror
(
errno
));
tPrint
(
"failed to write data file, reason:%s"
,
strerror
(
errno
));
}
}
}
}
...
@@ -62,19 +65,22 @@ void processShellMsg() {
...
@@ -62,19 +65,22 @@ void processShellMsg() {
taosResetQitems
(
qall
);
taosResetQitems
(
qall
);
for
(
int
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
taosGetQitem
(
qall
,
&
rpcMsg
);
rpcFreeCont
(
rpcMsg
.
pCont
);
taosGetQitem
(
qall
,
&
type
,
(
void
**
)
&
pRpcMsg
);
rpcFreeCont
(
pRpcMsg
->
pCont
);
rpcMsg
.
pCont
=
rpcMallocCont
(
msgSize
);
rpcMsg
.
pCont
=
rpcMallocCont
(
msgSize
);
rpcMsg
.
contLen
=
msgSize
;
rpcMsg
.
contLen
=
msgSize
;
rpcMsg
.
handle
=
rpcMsg
.
handle
;
rpcMsg
.
handle
=
pRpcMsg
->
handle
;
rpcMsg
.
code
=
1
;
rpcMsg
.
code
=
1
;
rpcSendResponse
(
&
rpcMsg
);
rpcSendResponse
(
&
rpcMsg
);
taosFreeQitem
(
pRpcMsg
);
}
}
taosFreeQitems
(
qall
);
}
}
taosFreeQall
(
qall
);
/*
/*
SRpcIpSet ipSet;
SRpcIpSet ipSet;
ipSet.numOfIps = 1;
ipSet.numOfIps = 1;
...
@@ -108,8 +114,13 @@ int retrieveAuthInfo(char *meterId, char *spi, char *encrypt, char *secret, char
...
@@ -108,8 +114,13 @@ int retrieveAuthInfo(char *meterId, char *spi, char *encrypt, char *secret, char
}
}
void
processRequestMsg
(
SRpcMsg
*
pMsg
)
{
void
processRequestMsg
(
SRpcMsg
*
pMsg
)
{
tTrace
(
"request is received, type:%d, contLen:%d"
,
pMsg
->
msgType
,
pMsg
->
contLen
);
SRpcMsg
*
pTemp
;
taosWriteQitem
(
qhandle
,
pMsg
);
pTemp
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
));
memcpy
(
pTemp
,
pMsg
,
sizeof
(
SRpcMsg
));
tTrace
(
"request is received, type:%d, contLen:%d, item:%p"
,
pMsg
->
msgType
,
pMsg
->
contLen
,
pTemp
);
taosWriteQitem
(
qhandle
,
TAOS_QTYPE_RPC
,
pTemp
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
...
@@ -143,6 +154,7 @@ int main(int argc, char *argv[]) {
...
@@ -143,6 +154,7 @@ int main(int argc, char *argv[]) {
commit
=
atoi
(
argv
[
++
i
]);
commit
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-d"
)
==
0
&&
i
<
argc
-
1
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-d"
)
==
0
&&
i
<
argc
-
1
)
{
rpcDebugFlag
=
atoi
(
argv
[
++
i
]);
rpcDebugFlag
=
atoi
(
argv
[
++
i
]);
ddebugFlag
=
rpcDebugFlag
;
uDebugFlag
=
rpcDebugFlag
;
uDebugFlag
=
rpcDebugFlag
;
}
else
{
}
else
{
printf
(
"
\n
usage: %s [options]
\n
"
,
argv
[
0
]);
printf
(
"
\n
usage: %s [options]
\n
"
,
argv
[
0
]);
...
...
src/util/inc/tlog.h
浏览文件 @
fa9a4099
...
@@ -78,7 +78,7 @@ void taosResetLogFile();
...
@@ -78,7 +78,7 @@ void taosResetLogFile();
// utility log function
// utility log function
#define pError(...) \
#define pError(...) \
if (uDebugFlag & DEBUG_ERROR) { \
if (uDebugFlag & DEBUG_ERROR) { \
tprintf("ERROR UTL ",
255
, __VA_ARGS__); \
tprintf("ERROR UTL ",
uDebugFlag
, __VA_ARGS__); \
}
}
#define pWarn(...) \
#define pWarn(...) \
if (uDebugFlag & DEBUG_WARN) { \
if (uDebugFlag & DEBUG_WARN) { \
...
...
src/util/inc/tqueue.h
浏览文件 @
fa9a4099
...
@@ -20,28 +20,35 @@
...
@@ -20,28 +20,35 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#define TAOS_QTYPE_RPC 0
#define TAOS_QTYPE_FWD 1
#define TAOS_QTYPE_WAL 2
typedef
void
*
taos_queue
;
typedef
void
*
taos_queue
;
typedef
void
*
taos_qset
;
typedef
void
*
taos_qset
;
typedef
void
*
taos_qall
;
typedef
void
*
taos_qall
;
taos_queue
taosOpenQueue
(
int
itemSize
);
taos_queue
taosOpenQueue
();
void
taosCloseQueue
(
taos_queue
);
void
taosCloseQueue
(
taos_queue
);
int
taosWriteQitem
(
taos_queue
,
void
*
item
);
void
*
taosAllocateQitem
(
int
size
);
int
taosReadQitem
(
taos_queue
,
void
*
item
);
void
taosFreeQitem
(
void
*
item
);
int
taosWriteQitem
(
taos_queue
,
int
type
,
void
*
item
);
int
taosReadAllQitems
(
taos_queue
,
taos_qall
*
);
int
taosReadQitem
(
taos_queue
,
int
*
type
,
void
**
pitem
);
int
taosGetQitem
(
taos_qall
,
void
*
item
);
taos_qall
taosAllocateQall
();
void
taosFreeQall
(
taos_qall
);
int
taosReadAllQitems
(
taos_queue
,
taos_qall
);
int
taosGetQitem
(
taos_qall
,
int
*
type
,
void
**
pitem
);
void
taosResetQitems
(
taos_qall
);
void
taosResetQitems
(
taos_qall
);
void
taosFreeQitems
(
taos_qall
);
taos_qset
taosOpenQset
();
taos_qset
taosOpenQset
();
void
taosCloseQset
();
void
taosCloseQset
();
int
taosAddIntoQset
(
taos_qset
,
taos_queue
);
int
taosAddIntoQset
(
taos_qset
,
taos_queue
,
void
*
ahandle
);
void
taosRemoveFromQset
(
taos_qset
,
taos_queue
);
void
taosRemoveFromQset
(
taos_qset
,
taos_queue
);
int
taosGetQueueNumber
(
taos_qset
);
int
taosGetQueueNumber
(
taos_qset
);
int
taosReadQitemFromQset
(
taos_qset
,
void
*
item
);
int
taosReadQitemFromQset
(
taos_qset
,
int
*
type
,
void
**
pitem
,
void
**
handle
);
int
taosReadAllQitemsFromQset
(
taos_qset
,
taos_qall
*
);
int
taosReadAllQitemsFromQset
(
taos_qset
,
taos_qall
,
void
**
handle
);
int
taosGetQueueItemsNumber
(
taos_queue
param
);
int
taosGetQueueItemsNumber
(
taos_queue
param
);
int
taosGetQsetItemsNumber
(
taos_qset
param
);
int
taosGetQsetItemsNumber
(
taos_qset
param
);
...
...
src/util/src/tqueue.c
浏览文件 @
fa9a4099
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include "tqueue.h"
#include "tqueue.h"
typedef
struct
_taos_qnode
{
typedef
struct
_taos_qnode
{
int
type
;
struct
_taos_qnode
*
next
;
struct
_taos_qnode
*
next
;
char
item
[];
char
item
[];
}
STaosQnode
;
}
STaosQnode
;
...
@@ -30,6 +31,7 @@ typedef struct _taos_q {
...
@@ -30,6 +31,7 @@ typedef struct _taos_q {
struct
_taos_qnode
*
tail
;
struct
_taos_qnode
*
tail
;
struct
_taos_q
*
next
;
// for queue set
struct
_taos_q
*
next
;
// for queue set
struct
_taos_qset
*
qset
;
// for queue set
struct
_taos_qset
*
qset
;
// for queue set
void
*
ahandle
;
// for queue set
pthread_mutex_t
mutex
;
pthread_mutex_t
mutex
;
}
STaosQueue
;
}
STaosQueue
;
...
@@ -48,7 +50,7 @@ typedef struct _taos_qall {
...
@@ -48,7 +50,7 @@ typedef struct _taos_qall {
int32_t
numOfItems
;
int32_t
numOfItems
;
}
STaosQall
;
}
STaosQall
;
taos_queue
taosOpenQueue
(
int
itemSize
)
{
taos_queue
taosOpenQueue
()
{
STaosQueue
*
queue
=
(
STaosQueue
*
)
calloc
(
sizeof
(
STaosQueue
),
1
);
STaosQueue
*
queue
=
(
STaosQueue
*
)
calloc
(
sizeof
(
STaosQueue
),
1
);
if
(
queue
==
NULL
)
{
if
(
queue
==
NULL
)
{
...
@@ -57,8 +59,6 @@ taos_queue taosOpenQueue(int itemSize) {
...
@@ -57,8 +59,6 @@ taos_queue taosOpenQueue(int itemSize) {
}
}
pthread_mutex_init
(
&
queue
->
mutex
,
NULL
);
pthread_mutex_init
(
&
queue
->
mutex
,
NULL
);
queue
->
itemSize
=
(
int32_t
)
itemSize
;
return
queue
;
return
queue
;
}
}
...
@@ -83,16 +83,26 @@ void taosCloseQueue(taos_queue param) {
...
@@ -83,16 +83,26 @@ void taosCloseQueue(taos_queue param) {
free
(
queue
);
free
(
queue
);
}
}
int
taosWriteQitem
(
taos_queue
param
,
void
*
item
)
{
void
*
taosAllocateQitem
(
int
size
)
{
STaosQueue
*
queue
=
(
STaosQueue
*
)
param
;
STaosQnode
*
pNode
=
(
STaosQnode
*
)
calloc
(
sizeof
(
STaosQnode
)
+
size
,
1
);
if
(
pNode
==
NULL
)
return
NULL
;
return
(
void
*
)
pNode
->
item
;
}
STaosQnode
*
pNode
=
(
STaosQnode
*
)
calloc
(
sizeof
(
STaosQnode
)
+
queue
->
itemSize
,
1
);
void
taosFreeQitem
(
void
*
param
)
{
if
(
pNode
==
NULL
)
{
if
(
param
==
NULL
)
return
;
terrno
=
TSDB_CODE_NO_RESOURCE
;
return
-
1
;
//pTrace("item:%p is freed", param);
}
memcpy
(
pNode
->
item
,
item
,
queue
->
itemSize
);
char
*
temp
=
(
char
*
)
param
;
temp
-=
sizeof
(
STaosQnode
);
free
(
temp
);
}
int
taosWriteQitem
(
taos_queue
param
,
int
type
,
void
*
item
)
{
STaosQueue
*
queue
=
(
STaosQueue
*
)
param
;
STaosQnode
*
pNode
=
(
STaosQnode
*
)(((
char
*
)
item
)
-
sizeof
(
STaosQnode
));
pNode
->
type
=
type
;
pthread_mutex_lock
(
&
queue
->
mutex
);
pthread_mutex_lock
(
&
queue
->
mutex
);
...
@@ -107,12 +117,14 @@ int taosWriteQitem(taos_queue param, void *item) {
...
@@ -107,12 +117,14 @@ int taosWriteQitem(taos_queue param, void *item) {
queue
->
numOfItems
++
;
queue
->
numOfItems
++
;
if
(
queue
->
qset
)
atomic_add_fetch_32
(
&
queue
->
qset
->
numOfItems
,
1
);
if
(
queue
->
qset
)
atomic_add_fetch_32
(
&
queue
->
qset
->
numOfItems
,
1
);
//pTrace("item:%p is put into queue, items:%d", item, queue->numOfItems);
pthread_mutex_unlock
(
&
queue
->
mutex
);
pthread_mutex_unlock
(
&
queue
->
mutex
);
return
0
;
return
0
;
}
}
int
taosReadQitem
(
taos_queue
param
,
void
*
item
)
{
int
taosReadQitem
(
taos_queue
param
,
int
*
type
,
void
**
p
item
)
{
STaosQueue
*
queue
=
(
STaosQueue
*
)
param
;
STaosQueue
*
queue
=
(
STaosQueue
*
)
param
;
STaosQnode
*
pNode
=
NULL
;
STaosQnode
*
pNode
=
NULL
;
int
code
=
0
;
int
code
=
0
;
...
@@ -121,14 +133,15 @@ int taosReadQitem(taos_queue param, void *item) {
...
@@ -121,14 +133,15 @@ int taosReadQitem(taos_queue param, void *item) {
if
(
queue
->
head
)
{
if
(
queue
->
head
)
{
pNode
=
queue
->
head
;
pNode
=
queue
->
head
;
memcpy
(
item
,
pNode
->
item
,
queue
->
itemSize
);
*
pitem
=
pNode
->
item
;
*
type
=
pNode
->
type
;
queue
->
head
=
pNode
->
next
;
queue
->
head
=
pNode
->
next
;
if
(
queue
->
head
==
NULL
)
if
(
queue
->
head
==
NULL
)
queue
->
tail
=
NULL
;
queue
->
tail
=
NULL
;
free
(
pNode
);
queue
->
numOfItems
--
;
queue
->
numOfItems
--
;
if
(
queue
->
qset
)
atomic_sub_fetch_32
(
&
queue
->
qset
->
numOfItems
,
1
);
if
(
queue
->
qset
)
atomic_sub_fetch_32
(
&
queue
->
qset
->
numOfItems
,
1
);
code
=
1
;
code
=
1
;
//pTrace("item:%p is read out from queue, items:%d", *pitem, queue->numOfItems);
}
}
pthread_mutex_unlock
(
&
queue
->
mutex
);
pthread_mutex_unlock
(
&
queue
->
mutex
);
...
@@ -136,19 +149,24 @@ int taosReadQitem(taos_queue param, void *item) {
...
@@ -136,19 +149,24 @@ int taosReadQitem(taos_queue param, void *item) {
return
code
;
return
code
;
}
}
int
taosReadAllQitems
(
taos_queue
param
,
taos_qall
*
res
)
{
void
*
taosAllocateQall
()
{
void
*
p
=
malloc
(
sizeof
(
STaosQall
));
return
p
;
}
void
taosFreeQall
(
void
*
param
)
{
free
(
param
);
}
int
taosReadAllQitems
(
taos_queue
param
,
taos_qall
p2
)
{
STaosQueue
*
queue
=
(
STaosQueue
*
)
param
;
STaosQueue
*
queue
=
(
STaosQueue
*
)
param
;
STaosQall
*
qall
=
NULL
;
STaosQall
*
qall
=
(
STaosQall
*
)
p2
;
int
code
=
0
;
int
code
=
0
;
pthread_mutex_lock
(
&
queue
->
mutex
);
pthread_mutex_lock
(
&
queue
->
mutex
);
if
(
queue
->
head
)
{
if
(
queue
->
head
)
{
qall
=
(
STaosQall
*
)
calloc
(
sizeof
(
STaosQall
),
1
);
memset
(
qall
,
0
,
sizeof
(
STaosQall
));
if
(
qall
==
NULL
)
{
terrno
=
TSDB_CODE_NO_RESOURCE
;
code
=
-
1
;
}
else
{
qall
->
current
=
queue
->
head
;
qall
->
current
=
queue
->
head
;
qall
->
start
=
queue
->
head
;
qall
->
start
=
queue
->
head
;
qall
->
numOfItems
=
queue
->
numOfItems
;
qall
->
numOfItems
=
queue
->
numOfItems
;
...
@@ -160,15 +178,13 @@ int taosReadAllQitems(taos_queue param, taos_qall *res) {
...
@@ -160,15 +178,13 @@ int taosReadAllQitems(taos_queue param, taos_qall *res) {
queue
->
numOfItems
=
0
;
queue
->
numOfItems
=
0
;
if
(
queue
->
qset
)
atomic_sub_fetch_32
(
&
queue
->
qset
->
numOfItems
,
qall
->
numOfItems
);
if
(
queue
->
qset
)
atomic_sub_fetch_32
(
&
queue
->
qset
->
numOfItems
,
qall
->
numOfItems
);
}
}
}
pthread_mutex_unlock
(
&
queue
->
mutex
);
pthread_mutex_unlock
(
&
queue
->
mutex
);
*
res
=
qall
;
return
code
;
return
code
;
}
}
int
taosGetQitem
(
taos_qall
param
,
void
*
item
)
{
int
taosGetQitem
(
taos_qall
param
,
int
*
type
,
void
**
p
item
)
{
STaosQall
*
qall
=
(
STaosQall
*
)
param
;
STaosQall
*
qall
=
(
STaosQall
*
)
param
;
STaosQnode
*
pNode
;
STaosQnode
*
pNode
;
int
num
=
0
;
int
num
=
0
;
...
@@ -178,8 +194,10 @@ int taosGetQitem(taos_qall param, void *item) {
...
@@ -178,8 +194,10 @@ int taosGetQitem(taos_qall param, void *item) {
qall
->
current
=
pNode
->
next
;
qall
->
current
=
pNode
->
next
;
if
(
pNode
)
{
if
(
pNode
)
{
memcpy
(
item
,
pNode
->
item
,
qall
->
itemSize
);
*
pitem
=
pNode
->
item
;
*
type
=
pNode
->
type
;
num
=
1
;
num
=
1
;
//pTrace("item:%p is fetched", *pitem);
}
}
return
num
;
return
num
;
...
@@ -190,19 +208,6 @@ void taosResetQitems(taos_qall param) {
...
@@ -190,19 +208,6 @@ void taosResetQitems(taos_qall param) {
qall
->
current
=
qall
->
start
;
qall
->
current
=
qall
->
start
;
}
}
void
taosFreeQitems
(
taos_qall
param
)
{
STaosQall
*
qall
=
(
STaosQall
*
)
param
;
STaosQnode
*
pNode
;
while
(
qall
->
current
)
{
pNode
=
qall
->
current
;
qall
->
current
=
pNode
->
next
;
free
(
pNode
);
}
free
(
qall
);
}
taos_qset
taosOpenQset
()
{
taos_qset
taosOpenQset
()
{
STaosQset
*
qset
=
(
STaosQset
*
)
calloc
(
sizeof
(
STaosQset
),
1
);
STaosQset
*
qset
=
(
STaosQset
*
)
calloc
(
sizeof
(
STaosQset
),
1
);
...
@@ -221,7 +226,7 @@ void taosCloseQset(taos_qset param) {
...
@@ -221,7 +226,7 @@ void taosCloseQset(taos_qset param) {
free
(
qset
);
free
(
qset
);
}
}
int
taosAddIntoQset
(
taos_qset
p1
,
taos_queue
p2
)
{
int
taosAddIntoQset
(
taos_qset
p1
,
taos_queue
p2
,
void
*
ahandle
)
{
STaosQueue
*
queue
=
(
STaosQueue
*
)
p2
;
STaosQueue
*
queue
=
(
STaosQueue
*
)
p2
;
STaosQset
*
qset
=
(
STaosQset
*
)
p1
;
STaosQset
*
qset
=
(
STaosQset
*
)
p1
;
...
@@ -230,6 +235,7 @@ int taosAddIntoQset(taos_qset p1, taos_queue p2) {
...
@@ -230,6 +235,7 @@ int taosAddIntoQset(taos_qset p1, taos_queue p2) {
pthread_mutex_lock
(
&
qset
->
mutex
);
pthread_mutex_lock
(
&
qset
->
mutex
);
queue
->
next
=
qset
->
head
;
queue
->
next
=
qset
->
head
;
queue
->
ahandle
=
ahandle
;
qset
->
head
=
queue
;
qset
->
head
=
queue
;
qset
->
numOfQueues
++
;
qset
->
numOfQueues
++
;
...
@@ -283,7 +289,7 @@ int taosGetQueueNumber(taos_qset param) {
...
@@ -283,7 +289,7 @@ int taosGetQueueNumber(taos_qset param) {
return
((
STaosQset
*
)
param
)
->
numOfQueues
;
return
((
STaosQset
*
)
param
)
->
numOfQueues
;
}
}
int
taosReadQitemFromQset
(
taos_qset
param
,
void
*
item
)
{
int
taosReadQitemFromQset
(
taos_qset
param
,
int
*
type
,
void
**
pitem
,
void
**
phandle
)
{
STaosQset
*
qset
=
(
STaosQset
*
)
param
;
STaosQset
*
qset
=
(
STaosQset
*
)
param
;
STaosQnode
*
pNode
=
NULL
;
STaosQnode
*
pNode
=
NULL
;
int
code
=
0
;
int
code
=
0
;
...
@@ -301,11 +307,12 @@ int taosReadQitemFromQset(taos_qset param, void *item) {
...
@@ -301,11 +307,12 @@ int taosReadQitemFromQset(taos_qset param, void *item) {
if
(
queue
->
head
)
{
if
(
queue
->
head
)
{
pNode
=
queue
->
head
;
pNode
=
queue
->
head
;
memcpy
(
item
,
pNode
->
item
,
queue
->
itemSize
);
*
pitem
=
pNode
->
item
;
*
type
=
pNode
->
type
;
*
phandle
=
queue
->
ahandle
;
queue
->
head
=
pNode
->
next
;
queue
->
head
=
pNode
->
next
;
if
(
queue
->
head
==
NULL
)
if
(
queue
->
head
==
NULL
)
queue
->
tail
=
NULL
;
queue
->
tail
=
NULL
;
free
(
pNode
);
queue
->
numOfItems
--
;
queue
->
numOfItems
--
;
atomic_sub_fetch_32
(
&
qset
->
numOfItems
,
1
);
atomic_sub_fetch_32
(
&
qset
->
numOfItems
,
1
);
code
=
1
;
code
=
1
;
...
@@ -318,10 +325,10 @@ int taosReadQitemFromQset(taos_qset param, void *item) {
...
@@ -318,10 +325,10 @@ int taosReadQitemFromQset(taos_qset param, void *item) {
return
code
;
return
code
;
}
}
int
taosReadAllQitemsFromQset
(
taos_qset
param
,
taos_qall
*
res
)
{
int
taosReadAllQitemsFromQset
(
taos_qset
param
,
taos_qall
p2
,
void
**
phandle
)
{
STaosQset
*
qset
=
(
STaosQset
*
)
param
;
STaosQset
*
qset
=
(
STaosQset
*
)
param
;
STaosQueue
*
queue
;
STaosQueue
*
queue
;
STaosQall
*
qall
=
NULL
;
STaosQall
*
qall
=
(
STaosQall
*
)
p2
;
int
code
=
0
;
int
code
=
0
;
for
(
int
i
=
0
;
i
<
qset
->
numOfQueues
;
++
i
)
{
for
(
int
i
=
0
;
i
<
qset
->
numOfQueues
;
++
i
)
{
...
@@ -336,31 +343,24 @@ int taosReadAllQitemsFromQset(taos_qset param, taos_qall *res) {
...
@@ -336,31 +343,24 @@ int taosReadAllQitemsFromQset(taos_qset param, taos_qall *res) {
pthread_mutex_lock
(
&
queue
->
mutex
);
pthread_mutex_lock
(
&
queue
->
mutex
);
if
(
queue
->
head
)
{
if
(
queue
->
head
)
{
qall
=
(
STaosQall
*
)
calloc
(
sizeof
(
STaosQall
),
1
);
if
(
qall
==
NULL
)
{
terrno
=
TSDB_CODE_NO_RESOURCE
;
code
=
-
1
;
}
else
{
qall
->
current
=
queue
->
head
;
qall
->
current
=
queue
->
head
;
qall
->
start
=
queue
->
head
;
qall
->
start
=
queue
->
head
;
qall
->
numOfItems
=
queue
->
numOfItems
;
qall
->
numOfItems
=
queue
->
numOfItems
;
qall
->
itemSize
=
queue
->
itemSize
;
qall
->
itemSize
=
queue
->
itemSize
;
code
=
qall
->
numOfItems
;
code
=
qall
->
numOfItems
;
*
phandle
=
queue
->
ahandle
;
queue
->
head
=
NULL
;
queue
->
head
=
NULL
;
queue
->
tail
=
NULL
;
queue
->
tail
=
NULL
;
queue
->
numOfItems
=
0
;
queue
->
numOfItems
=
0
;
atomic_sub_fetch_32
(
&
qset
->
numOfItems
,
qall
->
numOfItems
);
atomic_sub_fetch_32
(
&
qset
->
numOfItems
,
qall
->
numOfItems
);
}
}
}
pthread_mutex_unlock
(
&
queue
->
mutex
);
pthread_mutex_unlock
(
&
queue
->
mutex
);
if
(
code
!=
0
)
break
;
if
(
code
!=
0
)
break
;
}
}
*
res
=
qall
;
return
code
;
return
code
;
}
}
...
...
src/util/src/tsocket.c
浏览文件 @
fa9a4099
...
@@ -330,7 +330,7 @@ int taosOpenTcpClientSocket(char *destIp, uint16_t destPort, char *clientIp) {
...
@@ -330,7 +330,7 @@ int taosOpenTcpClientSocket(char *destIp, uint16_t destPort, char *clientIp) {
struct
sockaddr_in
serverAddr
,
clientAddr
;
struct
sockaddr_in
serverAddr
,
clientAddr
;
int
ret
;
int
ret
;
pTrace
(
"open tcp client socket:%s:%d"
,
destIp
,
destPort
);
// pTrace("open tcp client socket:%s:%d, local Ip:%s", destIp, destPort, clientIp
);
sockFd
=
(
int
)
socket
(
PF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
sockFd
=
(
int
)
socket
(
PF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
...
@@ -362,7 +362,7 @@ int taosOpenTcpClientSocket(char *destIp, uint16_t destPort, char *clientIp) {
...
@@ -362,7 +362,7 @@ int taosOpenTcpClientSocket(char *destIp, uint16_t destPort, char *clientIp) {
ret
=
connect
(
sockFd
,
(
struct
sockaddr
*
)
&
serverAddr
,
sizeof
(
serverAddr
));
ret
=
connect
(
sockFd
,
(
struct
sockaddr
*
)
&
serverAddr
,
sizeof
(
serverAddr
));
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
pError
(
"failed to connect socket, ip:%s, port:%hu, reason: %s"
,
destIp
,
destPort
,
strerror
(
errno
));
//
pError("failed to connect socket, ip:%s, port:%hu, reason: %s", destIp, destPort, strerror(errno));
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
sockFd
=
-
1
;
sockFd
=
-
1
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录