Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
dad3b9f1
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看板
提交
dad3b9f1
编写于
6月 07, 2020
作者:
陶建辉(Jeff)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add a new definition foe label length
上级
6f29506e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
42 addition
and
39 deletion
+42
-39
src/inc/taosdef.h
src/inc/taosdef.h
+1
-0
src/rpc/src/rpcMain.c
src/rpc/src/rpcMain.c
+2
-2
src/rpc/src/rpcTcp.c
src/rpc/src/rpcTcp.c
+33
-33
src/rpc/src/rpcUdp.c
src/rpc/src/rpcUdp.c
+4
-3
src/util/src/tsched.c
src/util/src/tsched.c
+2
-1
未找到文件。
src/inc/taosdef.h
浏览文件 @
dad3b9f1
...
...
@@ -221,6 +221,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_COUNTRY_LEN 20
#define TSDB_LOCALE_LEN 64
#define TSDB_TIMEZONE_LEN 64
#define TSDB_LABEL_LEN 8
#define TSDB_FQDN_LEN 128
#define TSDB_EP_LEN (TSDB_FQDN_LEN+6)
...
...
src/rpc/src/rpcMain.c
浏览文件 @
dad3b9f1
...
...
@@ -47,7 +47,7 @@ typedef struct {
uint16_t
localPort
;
int8_t
connType
;
int
index
;
// for UDP server only, round robin for multiple threads
char
label
[
12
];
char
label
[
TSDB_LABEL_LEN
];
char
user
[
TSDB_UNI_LEN
];
// meter ID
char
spi
;
// security parameter index
...
...
@@ -88,7 +88,7 @@ typedef struct {
}
SRpcReqContext
;
typedef
struct
SRpcConn
{
char
info
[
50
];
// debug info: label + pConn + ahandle
char
info
[
48
];
// debug info: label + pConn + ahandle
int
sid
;
// session ID
uint32_t
ownId
;
// own link ID
uint32_t
peerId
;
// peer link ID
...
...
src/rpc/src/rpcTcp.c
浏览文件 @
dad3b9f1
...
...
@@ -16,6 +16,7 @@
#include "os.h"
#include "tsocket.h"
#include "tutil.h"
#include "taosdef.h"
#include "taoserror.h"
#include "rpcLog.h"
#include "rpcHead.h"
...
...
@@ -46,7 +47,7 @@ typedef struct SThreadObj {
int
pollFd
;
int
numOfFds
;
int
threadId
;
char
label
[
12
];
char
label
[
TSDB_LABEL_LEN
];
void
*
shandle
;
// handle passed by upper layer during server initialization
void
*
(
*
processData
)(
SRecvInfo
*
pPacket
);
}
SThreadObj
;
...
...
@@ -55,7 +56,7 @@ typedef struct {
int
fd
;
uint32_t
ip
;
uint16_t
port
;
char
label
[
12
];
char
label
[
TSDB_LABEL_LEN
];
int
numOfThreads
;
void
*
shandle
;
SThreadObj
*
pThreadObj
;
...
...
@@ -79,6 +80,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread
return
NULL
;
}
pServerObj
->
thread
=
0
;
pServerObj
->
ip
=
ip
;
pServerObj
->
port
=
port
;
tstrncpy
(
pServerObj
->
label
,
label
,
sizeof
(
pServerObj
->
label
));
...
...
@@ -93,8 +95,14 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread
}
int
code
=
0
;
pthread_attr_t
thattr
;
pthread_attr_init
(
&
thattr
);
pthread_attr_setdetachstate
(
&
thattr
,
PTHREAD_CREATE_JOINABLE
);
pThreadObj
=
pServerObj
->
pThreadObj
;
for
(
int
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
pThreadObj
->
pollFd
=
-
1
;
pThreadObj
->
thread
=
0
;
pThreadObj
->
processData
=
fp
;
tstrncpy
(
pThreadObj
->
label
,
label
,
sizeof
(
pThreadObj
->
label
));
pThreadObj
->
shandle
=
shandle
;
...
...
@@ -114,11 +122,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread
break
;
}
pthread_attr_t
thattr
;
pthread_attr_init
(
&
thattr
);
pthread_attr_setdetachstate
(
&
thattr
,
PTHREAD_CREATE_JOINABLE
);
code
=
pthread_create
(
&
(
pThreadObj
->
thread
),
&
thattr
,
taosProcessTcpData
,
(
void
*
)(
pThreadObj
));
pthread_attr_destroy
(
&
thattr
);
if
(
code
!=
0
)
{
tError
(
"%s failed to create TCP process data thread(%s)"
,
label
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
...
...
@@ -130,11 +134,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread
}
if
(
code
==
0
)
{
pthread_attr_t
thattr
;
pthread_attr_init
(
&
thattr
);
pthread_attr_setdetachstate
(
&
thattr
,
PTHREAD_CREATE_JOINABLE
);
code
=
pthread_create
(
&
(
pServerObj
->
thread
),
&
thattr
,
(
void
*
)
taosAcceptTcpConnection
,
(
void
*
)(
pServerObj
));
pthread_attr_destroy
(
&
thattr
);
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
tError
(
"%s failed to create TCP accept thread(%s)"
,
label
,
strerror
(
errno
));
...
...
@@ -142,38 +142,39 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread
}
if
(
code
!=
0
)
{
free
(
pServerObj
->
pThreadObj
);
free
(
pServerObj
);
taosCleanUpTcpServer
(
pServerObj
);
pServerObj
=
NULL
;
}
else
{
tTrace
(
"%s TCP server is initialized, ip:0x%x port:%hu numOfThreads:%d"
,
label
,
ip
,
port
,
numOfThreads
);
}
pthread_attr_destroy
(
&
thattr
);
return
(
void
*
)
pServerObj
;
}
static
void
taosStopTcpThread
(
SThreadObj
*
pThreadObj
)
{
pThreadObj
->
stop
=
true
;
// signal the thread to stop, try graceful method first,
// and use pthread_cancel when failed
struct
epoll_event
event
=
{
.
events
=
EPOLLIN
};
eventfd_t
fd
=
eventfd
(
1
,
0
);
if
(
fd
==
-
1
)
{
// failed to create eventfd, call pthread_cancel instead, which may result in data corruption:
tError
(
"%s, failed to create eventfd(%s)"
,
pThreadObj
->
label
,
strerror
(
errno
));
pthread_cancel
(
pThreadObj
->
thread
);
}
else
if
(
epoll_ctl
(
pThreadObj
->
pollFd
,
EPOLL_CTL_ADD
,
fd
,
&
event
)
<
0
)
{
// failed to call epoll_ctl, call pthread_cancel instead, which may result in data corruption:
tError
(
"%s, failed to call epoll_ctl(%s)"
,
pThreadObj
->
label
,
strerror
(
errno
));
pthread_cancel
(
pThreadObj
->
thread
);
eventfd_t
fd
=
-
1
;
if
(
pThreadObj
->
thread
&&
pThreadObj
->
pollFd
>=
0
)
{
// signal the thread to stop, try graceful method first,
// and use pthread_cancel when failed
struct
epoll_event
event
=
{
.
events
=
EPOLLIN
};
fd
=
eventfd
(
1
,
0
);
if
(
fd
==
-
1
)
{
// failed to create eventfd, call pthread_cancel instead, which may result in data corruption:
tError
(
"%s, failed to create eventfd(%s)"
,
pThreadObj
->
label
,
strerror
(
errno
));
pthread_cancel
(
pThreadObj
->
thread
);
}
else
if
(
epoll_ctl
(
pThreadObj
->
pollFd
,
EPOLL_CTL_ADD
,
fd
,
&
event
)
<
0
)
{
// failed to call epoll_ctl, call pthread_cancel instead, which may result in data corruption:
tError
(
"%s, failed to call epoll_ctl(%s)"
,
pThreadObj
->
label
,
strerror
(
errno
));
pthread_cancel
(
pThreadObj
->
thread
);
}
}
pthread_join
(
pThreadObj
->
thread
,
NULL
);
close
(
pThreadObj
->
pollFd
);
if
(
fd
!=
-
1
)
{
close
(
fd
);
}
if
(
pThreadObj
->
thread
)
pthread_join
(
pThreadObj
->
thread
,
NULL
);
if
(
pThreadObj
->
pollFd
>=
0
)
close
(
pThreadObj
->
pollFd
);
if
(
fd
!=
-
1
)
close
(
fd
);
while
(
pThreadObj
->
pHead
)
{
SFdObj
*
pFdObj
=
pThreadObj
->
pHead
;
...
...
@@ -188,9 +189,8 @@ void taosCleanUpTcpServer(void *handle) {
SThreadObj
*
pThreadObj
;
if
(
pServerObj
==
NULL
)
return
;
shutdown
(
pServerObj
->
fd
,
SHUT_RD
);
pthread_join
(
pServerObj
->
thread
,
NULL
);
if
(
pServerObj
->
fd
>=
0
)
shutdown
(
pServerObj
->
fd
,
SHUT_RD
);
if
(
pServerObj
->
thread
)
pthread_join
(
pServerObj
->
thread
,
NULL
);
for
(
int
i
=
0
;
i
<
pServerObj
->
numOfThreads
;
++
i
)
{
pThreadObj
=
pServerObj
->
pThreadObj
+
i
;
...
...
src/rpc/src/rpcUdp.c
浏览文件 @
dad3b9f1
...
...
@@ -18,6 +18,7 @@
#include "tsystem.h"
#include "ttimer.h"
#include "tutil.h"
#include "taosdef.h"
#include "rpcLog.h"
#include "rpcUdp.h"
#include "rpcHead.h"
...
...
@@ -33,7 +34,7 @@ typedef struct {
int
fd
;
uint16_t
port
;
// peer port
uint16_t
localPort
;
// local port
char
label
[
12
];
// copy from udpConnSet;
char
label
[
TSDB_LABEL_LEN
];
// copy from udpConnSet;
pthread_t
thread
;
void
*
hash
;
void
*
shandle
;
// handle passed by upper layer during server initialization
...
...
@@ -49,7 +50,7 @@ typedef struct {
uint16_t
port
;
// local Port
void
*
shandle
;
// handle passed by upper layer during server initialization
int
threads
;
char
label
[
12
];
char
label
[
TSDB_LABEL_LEN
];
void
*
(
*
fp
)(
SRecvInfo
*
pPacket
);
SUdpConn
udpConn
[];
}
SUdpConnSet
;
...
...
@@ -93,7 +94,7 @@ void *taosInitUdpConnection(uint32_t ip, uint16_t port, char *label, int threads
}
struct
sockaddr_in
sin
;
unsigned
int
addrlen
=
sizeof
(
sin
);
unsigned
int
addrlen
=
sizeof
(
sin
);
if
(
getsockname
(
pConn
->
fd
,
(
struct
sockaddr
*
)
&
sin
,
&
addrlen
)
==
0
&&
sin
.
sin_family
==
AF_INET
&&
addrlen
==
sizeof
(
sin
))
{
pConn
->
localPort
=
(
uint16_t
)
ntohs
(
sin
.
sin_port
);
...
...
src/util/src/tsched.c
浏览文件 @
dad3b9f1
...
...
@@ -14,6 +14,7 @@
*/
#include "os.h"
#include "taosdef.h"
#include "tulog.h"
#include "tsched.h"
#include "ttimer.h"
...
...
@@ -21,7 +22,7 @@
#define DUMP_SCHEDULER_TIME_WINDOW 30000 //every 30sec, take a snap shot of task queue.
typedef
struct
{
char
label
[
16
];
char
label
[
TSDB_LABEL_LEN
];
tsem_t
emptySem
;
tsem_t
fullSem
;
pthread_mutex_t
queueMutex
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录