Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
XKZJ_WCL
TDengine
提交
14c90236
T
TDengine
项目概览
XKZJ_WCL
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
14c90236
编写于
8月 05, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1057
上级
241f1732
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
99 addition
and
122 deletion
+99
-122
deps/wepoll/inc/wepoll.h
deps/wepoll/inc/wepoll.h
+4
-4
deps/wepoll/src/wepoll.c
deps/wepoll/src/wepoll.c
+9
-9
src/cq/test/CMakeLists.txt
src/cq/test/CMakeLists.txt
+0
-6
src/mnode/CMakeLists.txt
src/mnode/CMakeLists.txt
+0
-4
src/os/inc/osSocket.h
src/os/inc/osSocket.h
+3
-2
src/os/inc/osWindows.h
src/os/inc/osWindows.h
+9
-5
src/os/src/darwin/darwinSocket.c
src/os/src/darwin/darwinSocket.c
+1
-1
src/os/src/detail/osSocket.c
src/os/src/detail/osSocket.c
+2
-2
src/os/src/windows/w64Socket.c
src/os/src/windows/w64Socket.c
+2
-2
src/rpc/src/rpcTcp.c
src/rpc/src/rpcTcp.c
+21
-18
src/rpc/src/rpcUdp.c
src/rpc/src/rpcUdp.c
+1
-1
src/rpc/test/CMakeLists.txt
src/rpc/test/CMakeLists.txt
+1
-5
src/sync/test/CMakeLists.txt
src/sync/test/CMakeLists.txt
+1
-5
src/util/inc/tsocket.h
src/util/inc/tsocket.h
+10
-10
src/util/src/tsocket.c
src/util/src/tsocket.c
+32
-32
src/wal/test/CMakeLists.txt
src/wal/test/CMakeLists.txt
+1
-5
tests/comparisonTest/tdengine/CMakeLists.txt
tests/comparisonTest/tdengine/CMakeLists.txt
+1
-6
tests/tsim/CMakeLists.txt
tests/tsim/CMakeLists.txt
+1
-5
未找到文件。
deps/wepoll/inc/wepoll.h
浏览文件 @
14c90236
...
@@ -69,7 +69,7 @@ enum EPOLL_EVENTS {
...
@@ -69,7 +69,7 @@ enum EPOLL_EVENTS {
#define EPOLL_CTL_DEL 3
#define EPOLL_CTL_DEL 3
typedef
void
*
HANDLE
;
typedef
void
*
HANDLE
;
typedef
uintptr_t
SOCKET
;
//
typedef uintptr_t SOCKET;
typedef
union
epoll_data
{
typedef
union
epoll_data
{
void
*
ptr
;
void
*
ptr
;
...
@@ -92,14 +92,14 @@ extern "C" {
...
@@ -92,14 +92,14 @@ extern "C" {
WEPOLL_EXPORT
HANDLE
epoll_create
(
int
size
);
WEPOLL_EXPORT
HANDLE
epoll_create
(
int
size
);
WEPOLL_EXPORT
HANDLE
epoll_create1
(
int
flags
);
WEPOLL_EXPORT
HANDLE
epoll_create1
(
int
flags
);
WEPOLL_EXPORT
int
epoll_close
(
HANDLE
ephnd
);
WEPOLL_EXPORT
int
epoll_close
(
SOCKET
ephnd
);
WEPOLL_EXPORT
int
epoll_ctl
(
HANDLE
ephnd
,
WEPOLL_EXPORT
int
epoll_ctl
(
SOCKET
ephnd
,
int
op
,
int
op
,
SOCKET
sock
,
SOCKET
sock
,
struct
epoll_event
*
event
);
struct
epoll_event
*
event
);
WEPOLL_EXPORT
int
epoll_wait
(
HANDLE
ephnd
,
WEPOLL_EXPORT
int
epoll_wait
(
SOCKET
ephnd
,
struct
epoll_event
*
events
,
struct
epoll_event
*
events
,
int
maxevents
,
int
maxevents
,
int
timeout
);
int
timeout
);
...
...
deps/wepoll/src/wepoll.c
浏览文件 @
14c90236
...
@@ -89,14 +89,14 @@ extern "C" {
...
@@ -89,14 +89,14 @@ extern "C" {
WEPOLL_EXPORT
HANDLE
epoll_create
(
int
size
);
WEPOLL_EXPORT
HANDLE
epoll_create
(
int
size
);
WEPOLL_EXPORT
HANDLE
epoll_create1
(
int
flags
);
WEPOLL_EXPORT
HANDLE
epoll_create1
(
int
flags
);
WEPOLL_EXPORT
int
epoll_close
(
HANDLE
ephnd
);
WEPOLL_EXPORT
int
epoll_close
(
SOCKET
ephnd
);
WEPOLL_EXPORT
int
epoll_ctl
(
HANDLE
ephnd
,
WEPOLL_EXPORT
int
epoll_ctl
(
SOCKET
ephnd
,
int
op
,
int
op
,
SOCKET
sock
,
SOCKET
sock
,
struct
epoll_event
*
event
);
struct
epoll_event
*
event
);
WEPOLL_EXPORT
int
epoll_wait
(
HANDLE
ephnd
,
WEPOLL_EXPORT
int
epoll_wait
(
SOCKET
ephnd
,
struct
epoll_event
*
events
,
struct
epoll_event
*
events
,
int
maxevents
,
int
maxevents
,
int
timeout
);
int
timeout
);
...
@@ -593,7 +593,7 @@ HANDLE epoll_create1(int flags) {
...
@@ -593,7 +593,7 @@ HANDLE epoll_create1(int flags) {
return
epoll__create
();
return
epoll__create
();
}
}
int
epoll_close
(
HANDLE
ephnd
)
{
int
epoll_close
(
SOCKET
ephnd
)
{
ts_tree_node_t
*
tree_node
;
ts_tree_node_t
*
tree_node
;
port_state_t
*
port_state
;
port_state_t
*
port_state
;
...
@@ -614,11 +614,11 @@ int epoll_close(HANDLE ephnd) {
...
@@ -614,11 +614,11 @@ int epoll_close(HANDLE ephnd) {
return
port_delete
(
port_state
);
return
port_delete
(
port_state
);
err:
err:
err_check_handle
(
ephnd
);
err_check_handle
(
(
HANDLE
)
ephnd
);
return
-
1
;
return
-
1
;
}
}
int
epoll_ctl
(
HANDLE
ephnd
,
int
op
,
SOCKET
sock
,
struct
epoll_event
*
ev
)
{
int
epoll_ctl
(
SOCKET
ephnd
,
int
op
,
SOCKET
sock
,
struct
epoll_event
*
ev
)
{
ts_tree_node_t
*
tree_node
;
ts_tree_node_t
*
tree_node
;
port_state_t
*
port_state
;
port_state_t
*
port_state
;
int
r
;
int
r
;
...
@@ -645,12 +645,12 @@ int epoll_ctl(HANDLE ephnd, int op, SOCKET sock, struct epoll_event* ev) {
...
@@ -645,12 +645,12 @@ int epoll_ctl(HANDLE ephnd, int op, SOCKET sock, struct epoll_event* ev) {
err:
err:
/* On Linux, in the case of epoll_ctl(), EBADF takes priority over other
/* On Linux, in the case of epoll_ctl(), EBADF takes priority over other
* errors. Wepoll mimics this behavior. */
* errors. Wepoll mimics this behavior. */
err_check_handle
(
ephnd
);
err_check_handle
(
(
HANDLE
)
ephnd
);
err_check_handle
((
HANDLE
)
sock
);
err_check_handle
((
HANDLE
)
sock
);
return
-
1
;
return
-
1
;
}
}
int
epoll_wait
(
HANDLE
ephnd
,
int
epoll_wait
(
SOCKET
ephnd
,
struct
epoll_event
*
events
,
struct
epoll_event
*
events
,
int
maxevents
,
int
maxevents
,
int
timeout
)
{
int
timeout
)
{
...
@@ -681,7 +681,7 @@ int epoll_wait(HANDLE ephnd,
...
@@ -681,7 +681,7 @@ int epoll_wait(HANDLE ephnd,
return
num_events
;
return
num_events
;
err:
err:
err_check_handle
(
ephnd
);
err_check_handle
(
(
HANDLE
)
ephnd
);
return
-
1
;
return
-
1
;
}
}
...
...
src/cq/test/CMakeLists.txt
浏览文件 @
14c90236
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
PROJECT
(
TDengine
)
PROJECT
(
TDengine
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/os/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/util/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/common/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/cq/inc
)
LIST
(
APPEND CQTEST_SRC ./cqtest.c
)
LIST
(
APPEND CQTEST_SRC ./cqtest.c
)
ADD_EXECUTABLE
(
cqtest
${
CQTEST_SRC
}
)
ADD_EXECUTABLE
(
cqtest
${
CQTEST_SRC
}
)
TARGET_LINK_LIBRARIES
(
cqtest tcq
)
TARGET_LINK_LIBRARIES
(
cqtest tcq
)
src/mnode/CMakeLists.txt
浏览文件 @
14c90236
...
@@ -2,10 +2,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
...
@@ -2,10 +2,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT
(
TDengine
)
PROJECT
(
TDengine
)
IF
(
TD_LINUX
)
IF
(
TD_LINUX
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/os/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/common/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/util/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/query/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/query/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/dnode/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/dnode/inc
)
...
...
src/os/inc/osSocket.h
浏览文件 @
14c90236
...
@@ -32,6 +32,7 @@ extern "C" {
...
@@ -32,6 +32,7 @@ extern "C" {
x = FD_INITIALIZER; \
x = FD_INITIALIZER; \
} \
} \
}
}
typedef
int
SOCKET
;
#endif
#endif
#define taosClose(x) taosCloseSocket(x)
#define taosClose(x) taosCloseSocket(x)
...
@@ -54,11 +55,11 @@ extern "C" {
...
@@ -54,11 +55,11 @@ extern "C" {
#endif
#endif
// TAOS_OS_FUNC_SOCKET
// TAOS_OS_FUNC_SOCKET
int
taosSetNonblocking
(
int
sock
,
int
on
);
int
taosSetNonblocking
(
SOCKET
sock
,
int
on
);
void
taosBlockSIGPIPE
();
void
taosBlockSIGPIPE
();
// TAOS_OS_FUNC_SOCKET_SETSOCKETOPT
// TAOS_OS_FUNC_SOCKET_SETSOCKETOPT
int
taosSetSockOpt
(
int
socketfd
,
int
level
,
int
optname
,
void
*
optval
,
int
optlen
);
int
taosSetSockOpt
(
SOCKET
socketfd
,
int
level
,
int
optname
,
void
*
optval
,
int
optlen
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/os/inc/osWindows.h
浏览文件 @
14c90236
...
@@ -85,11 +85,15 @@ extern "C" {
...
@@ -85,11 +85,15 @@ extern "C" {
#define TAOS_OS_FUNC_SOCKET
#define TAOS_OS_FUNC_SOCKET
#define TAOS_OS_FUNC_SOCKET_SETSOCKETOPT
#define TAOS_OS_FUNC_SOCKET_SETSOCKETOPT
#define TAOS_OS_FUNC_SOCKET_OP
#define TAOS_OS_FUNC_SOCKET_OP
#define taosSend(sockfd, buf, len, flags) send(sockfd, buf, len, flags)
#define taosSend(sockfd, buf, len, flags) send((SOCKET)sockfd, buf, len, flags)
#define taosSendto(sockfd, buf, len, flags, dest_addr, addrlen) sendto(sockfd, buf, len, flags, dest_addr, addrlen)
#define taosSendto(sockfd, buf, len, flags, dest_addr, addrlen) sendto((SOCKET)sockfd, buf, len, flags, dest_addr, addrlen)
#define taosWriteSocket(fd, buf, len) send(fd, buf, len, 0)
#define taosWriteSocket(fd, buf, len) send((SOCKET)fd, buf, len, 0)
#define taosReadSocket(fd, buf, len) recv(fd, buf, len, 0)
#define taosReadSocket(fd, buf, len) recv((SOCKET)fd, buf, len, 0)
#define taosCloseSocket(fd) closesocket(fd)
#define taosCloseSocket(fd) closesocket((SOCKET)fd)
typedef
SOCKET
eventfd_t
;
#define eventfd(a, b) -1
#define TAOS_OS_FUNC_STRING_WCHAR
#define TAOS_OS_FUNC_STRING_WCHAR
int
twcslen
(
const
wchar_t
*
wcs
);
int
twcslen
(
const
wchar_t
*
wcs
);
...
...
src/os/src/darwin/darwinSocket.c
浏览文件 @
14c90236
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
int
taosSetSockOpt
(
int
socketfd
,
int
level
,
int
optname
,
void
*
optval
,
int
optlen
)
{
int
taosSetSockOpt
(
SOCKET
socketfd
,
int
level
,
int
optname
,
void
*
optval
,
int
optlen
)
{
if
(
level
==
SOL_SOCKET
&&
optname
==
SO_SNDBUF
)
{
if
(
level
==
SOL_SOCKET
&&
optname
==
SO_SNDBUF
)
{
return
0
;
return
0
;
}
}
...
...
src/os/src/detail/osSocket.c
浏览文件 @
14c90236
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
#ifndef TAOS_OS_FUNC_SOCKET
#ifndef TAOS_OS_FUNC_SOCKET
int
taosSetNonblocking
(
int
sock
,
int
on
)
{
int
taosSetNonblocking
(
SOCKET
sock
,
int
on
)
{
int
flags
=
0
;
int
flags
=
0
;
if
((
flags
=
fcntl
(
sock
,
F_GETFL
,
0
))
<
0
)
{
if
((
flags
=
fcntl
(
sock
,
F_GETFL
,
0
))
<
0
)
{
uError
(
"fcntl(F_GETFL) error: %d (%s)
\n
"
,
errno
,
strerror
(
errno
));
uError
(
"fcntl(F_GETFL) error: %d (%s)
\n
"
,
errno
,
strerror
(
errno
));
...
@@ -53,7 +53,7 @@ void taosBlockSIGPIPE() {
...
@@ -53,7 +53,7 @@ void taosBlockSIGPIPE() {
#ifndef TAOS_OS_FUNC_SOCKET_SETSOCKETOPT
#ifndef TAOS_OS_FUNC_SOCKET_SETSOCKETOPT
int
taosSetSockOpt
(
int
socketfd
,
int
level
,
int
optname
,
void
*
optval
,
int
optlen
)
{
int
taosSetSockOpt
(
SOCKET
socketfd
,
int
level
,
int
optname
,
void
*
optval
,
int
optlen
)
{
return
setsockopt
(
socketfd
,
level
,
optname
,
optval
,
(
socklen_t
)
optlen
);
return
setsockopt
(
socketfd
,
level
,
optname
,
optval
,
(
socklen_t
)
optlen
);
}
}
...
...
src/os/src/windows/w64Socket.c
浏览文件 @
14c90236
...
@@ -34,7 +34,7 @@ void taosWinSocketInit() {
...
@@ -34,7 +34,7 @@ void taosWinSocketInit() {
}
}
}
}
int
taosSetNonblocking
(
int
sock
,
int
on
)
{
int
taosSetNonblocking
(
SOCKET
sock
,
int
on
)
{
u_long
mode
;
u_long
mode
;
if
(
on
)
{
if
(
on
)
{
mode
=
1
;
mode
=
1
;
...
@@ -48,7 +48,7 @@ int taosSetNonblocking(int sock, int on) {
...
@@ -48,7 +48,7 @@ int taosSetNonblocking(int sock, int on) {
void
taosBlockSIGPIPE
()
{}
void
taosBlockSIGPIPE
()
{}
int
taosSetSockOpt
(
int
socketfd
,
int
level
,
int
optname
,
void
*
optval
,
int
optlen
)
{
int
taosSetSockOpt
(
SOCKET
socketfd
,
int
level
,
int
optname
,
void
*
optval
,
int
optlen
)
{
if
(
level
==
SOL_SOCKET
&&
optname
==
TCP_KEEPCNT
)
{
if
(
level
==
SOL_SOCKET
&&
optname
==
TCP_KEEPCNT
)
{
return
0
;
return
0
;
}
}
...
...
src/rpc/src/rpcTcp.c
浏览文件 @
14c90236
...
@@ -21,6 +21,9 @@
...
@@ -21,6 +21,9 @@
#include "rpcLog.h"
#include "rpcLog.h"
#include "rpcHead.h"
#include "rpcHead.h"
#include "rpcTcp.h"
#include "rpcTcp.h"
#ifdef WINDOWS
#include "wepoll.h"
#endif
#ifndef EPOLLWAKEUP
#ifndef EPOLLWAKEUP
#define EPOLLWAKEUP (1u << 29)
#define EPOLLWAKEUP (1u << 29)
...
@@ -28,7 +31,7 @@
...
@@ -28,7 +31,7 @@
typedef
struct
SFdObj
{
typedef
struct
SFdObj
{
void
*
signature
;
void
*
signature
;
int
fd
;
// TCP socket FD
SOCKET
fd
;
// TCP socket FD
int
closedByApp
;
// 1: already closed by App
int
closedByApp
;
// 1: already closed by App
void
*
thandle
;
// handle from upper layer, like TAOS
void
*
thandle
;
// handle from upper layer, like TAOS
uint32_t
ip
;
uint32_t
ip
;
...
@@ -44,7 +47,7 @@ typedef struct SThreadObj {
...
@@ -44,7 +47,7 @@ typedef struct SThreadObj {
pthread_mutex_t
mutex
;
pthread_mutex_t
mutex
;
uint32_t
ip
;
uint32_t
ip
;
bool
stop
;
bool
stop
;
int
pollFd
;
SOCKET
pollFd
;
int
numOfFds
;
int
numOfFds
;
int
threadId
;
int
threadId
;
char
label
[
TSDB_LABEL_LEN
];
char
label
[
TSDB_LABEL_LEN
];
...
@@ -53,7 +56,7 @@ typedef struct SThreadObj {
...
@@ -53,7 +56,7 @@ typedef struct SThreadObj {
}
SThreadObj
;
}
SThreadObj
;
typedef
struct
{
typedef
struct
{
int
fd
;
SOCKET
fd
;
uint32_t
ip
;
uint32_t
ip
;
uint16_t
port
;
uint16_t
port
;
char
label
[
TSDB_LABEL_LEN
];
char
label
[
TSDB_LABEL_LEN
];
...
@@ -64,7 +67,7 @@ typedef struct {
...
@@ -64,7 +67,7 @@ typedef struct {
}
SServerObj
;
}
SServerObj
;
static
void
*
taosProcessTcpData
(
void
*
param
);
static
void
*
taosProcessTcpData
(
void
*
param
);
static
SFdObj
*
taosMallocFdObj
(
SThreadObj
*
pThreadObj
,
int
fd
);
static
SFdObj
*
taosMallocFdObj
(
SThreadObj
*
pThreadObj
,
SOCKET
fd
);
static
void
taosFreeFdObj
(
SFdObj
*
pFdObj
);
static
void
taosFreeFdObj
(
SFdObj
*
pFdObj
);
static
void
taosReportBrokenLink
(
SFdObj
*
pFdObj
);
static
void
taosReportBrokenLink
(
SFdObj
*
pFdObj
);
static
void
*
taosAcceptTcpConnection
(
void
*
arg
);
static
void
*
taosAcceptTcpConnection
(
void
*
arg
);
...
@@ -120,7 +123,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread
...
@@ -120,7 +123,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread
break
;
break
;
}
}
pThreadObj
->
pollFd
=
epoll_create
(
10
);
// size does not matter
pThreadObj
->
pollFd
=
(
int64_t
)
epoll_create
(
10
);
// size does not matter
if
(
pThreadObj
->
pollFd
<
0
)
{
if
(
pThreadObj
->
pollFd
<
0
)
{
tError
(
"%s failed to create TCP epoll"
,
label
);
tError
(
"%s failed to create TCP epoll"
,
label
);
code
=
-
1
;
code
=
-
1
;
...
@@ -163,7 +166,7 @@ static void taosStopTcpThread(SThreadObj* pThreadObj) {
...
@@ -163,7 +166,7 @@ static void taosStopTcpThread(SThreadObj* pThreadObj) {
pThreadObj
->
stop
=
true
;
pThreadObj
->
stop
=
true
;
eventfd_t
fd
=
-
1
;
eventfd_t
fd
=
-
1
;
if
(
pThreadObj
->
thread
&&
pThreadObj
->
pollFd
>=
0
)
{
if
(
taosCheckPthreadValid
(
pThreadObj
->
thread
)
&&
pThreadObj
->
pollFd
>=
0
)
{
// signal the thread to stop, try graceful method first,
// signal the thread to stop, try graceful method first,
// and use pthread_cancel when failed
// and use pthread_cancel when failed
struct
epoll_event
event
=
{
.
events
=
EPOLLIN
};
struct
epoll_event
event
=
{
.
events
=
EPOLLIN
};
...
@@ -179,9 +182,9 @@ static void taosStopTcpThread(SThreadObj* pThreadObj) {
...
@@ -179,9 +182,9 @@ static void taosStopTcpThread(SThreadObj* pThreadObj) {
}
}
}
}
if
(
pThreadObj
->
thread
)
pthread_join
(
pThreadObj
->
thread
,
NULL
);
if
(
taosCheckPthreadValid
(
pThreadObj
->
thread
)
)
pthread_join
(
pThreadObj
->
thread
,
NULL
);
if
(
pThreadObj
->
pollFd
>=
0
)
close
(
pThreadObj
->
pollFd
);
if
(
pThreadObj
->
pollFd
>=
0
)
taosCloseSocket
(
pThreadObj
->
pollFd
);
if
(
fd
!=
-
1
)
close
(
fd
);
if
(
fd
!=
-
1
)
taosCloseSocket
(
fd
);
while
(
pThreadObj
->
pHead
)
{
while
(
pThreadObj
->
pHead
)
{
SFdObj
*
pFdObj
=
pThreadObj
->
pHead
;
SFdObj
*
pFdObj
=
pThreadObj
->
pHead
;
...
@@ -195,7 +198,7 @@ void taosStopTcpServer(void *handle) {
...
@@ -195,7 +198,7 @@ void taosStopTcpServer(void *handle) {
if
(
pServerObj
==
NULL
)
return
;
if
(
pServerObj
==
NULL
)
return
;
if
(
pServerObj
->
fd
>=
0
)
shutdown
(
pServerObj
->
fd
,
SHUT_RD
);
if
(
pServerObj
->
fd
>=
0
)
shutdown
(
pServerObj
->
fd
,
SHUT_RD
);
if
(
pServerObj
->
thread
)
pthread_join
(
pServerObj
->
thread
,
NULL
);
if
(
taosCheckPthreadValid
(
pServerObj
->
thread
)
)
pthread_join
(
pServerObj
->
thread
,
NULL
);
tDebug
(
"%s TCP server is stopped"
,
pServerObj
->
label
);
tDebug
(
"%s TCP server is stopped"
,
pServerObj
->
label
);
}
}
...
@@ -218,7 +221,7 @@ void taosCleanUpTcpServer(void *handle) {
...
@@ -218,7 +221,7 @@ void taosCleanUpTcpServer(void *handle) {
}
}
static
void
*
taosAcceptTcpConnection
(
void
*
arg
)
{
static
void
*
taosAcceptTcpConnection
(
void
*
arg
)
{
int
connFd
=
-
1
;
SOCKET
connFd
=
-
1
;
struct
sockaddr_in
caddr
;
struct
sockaddr_in
caddr
;
int
threadId
=
0
;
int
threadId
=
0
;
SThreadObj
*
pThreadObj
;
SThreadObj
*
pThreadObj
;
...
@@ -252,7 +255,7 @@ static void *taosAcceptTcpConnection(void *arg) {
...
@@ -252,7 +255,7 @@ static void *taosAcceptTcpConnection(void *arg) {
tDebug
(
"%s new TCP connection from %s:%hu, fd:%d FD:%p numOfFds:%d"
,
pServerObj
->
label
,
tDebug
(
"%s new TCP connection from %s:%hu, fd:%d FD:%p numOfFds:%d"
,
pServerObj
->
label
,
inet_ntoa
(
caddr
.
sin_addr
),
pFdObj
->
port
,
connFd
,
pFdObj
,
pThreadObj
->
numOfFds
);
inet_ntoa
(
caddr
.
sin_addr
),
pFdObj
->
port
,
connFd
,
pFdObj
,
pThreadObj
->
numOfFds
);
}
else
{
}
else
{
close
(
connFd
);
taosCloseSocket
(
connFd
);
tError
(
"%s failed to malloc FdObj(%s) for connection from:%s:%hu"
,
pServerObj
->
label
,
strerror
(
errno
),
tError
(
"%s failed to malloc FdObj(%s) for connection from:%s:%hu"
,
pServerObj
->
label
,
strerror
(
errno
),
inet_ntoa
(
caddr
.
sin_addr
),
htons
(
caddr
.
sin_port
));
inet_ntoa
(
caddr
.
sin_addr
),
htons
(
caddr
.
sin_port
));
}
}
...
@@ -262,7 +265,7 @@ static void *taosAcceptTcpConnection(void *arg) {
...
@@ -262,7 +265,7 @@ static void *taosAcceptTcpConnection(void *arg) {
threadId
=
threadId
%
pServerObj
->
numOfThreads
;
threadId
=
threadId
%
pServerObj
->
numOfThreads
;
}
}
close
(
pServerObj
->
fd
);
taosCloseSocket
(
pServerObj
->
fd
);
return
NULL
;
return
NULL
;
}
}
...
@@ -283,7 +286,7 @@ void *taosInitTcpClient(uint32_t ip, uint16_t port, char *label, int num, void *
...
@@ -283,7 +286,7 @@ void *taosInitTcpClient(uint32_t ip, uint16_t port, char *label, int num, void *
return
NULL
;
return
NULL
;
}
}
pThreadObj
->
pollFd
=
epoll_create
(
10
);
// size does not matter
pThreadObj
->
pollFd
=
(
SOCKET
)
epoll_create
(
10
);
// size does not matter
if
(
pThreadObj
->
pollFd
<
0
)
{
if
(
pThreadObj
->
pollFd
<
0
)
{
tError
(
"%s failed to create TCP client epoll"
,
label
);
tError
(
"%s failed to create TCP client epoll"
,
label
);
free
(
pThreadObj
);
free
(
pThreadObj
);
...
@@ -298,7 +301,7 @@ void *taosInitTcpClient(uint32_t ip, uint16_t port, char *label, int num, void *
...
@@ -298,7 +301,7 @@ void *taosInitTcpClient(uint32_t ip, uint16_t port, char *label, int num, void *
int
code
=
pthread_create
(
&
(
pThreadObj
->
thread
),
&
thattr
,
taosProcessTcpData
,
(
void
*
)(
pThreadObj
));
int
code
=
pthread_create
(
&
(
pThreadObj
->
thread
),
&
thattr
,
taosProcessTcpData
,
(
void
*
)(
pThreadObj
));
pthread_attr_destroy
(
&
thattr
);
pthread_attr_destroy
(
&
thattr
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
close
(
pThreadObj
->
pollFd
);
taosCloseSocket
(
pThreadObj
->
pollFd
);
free
(
pThreadObj
);
free
(
pThreadObj
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
tError
(
"%s failed to create TCP read data thread(%s)"
,
label
,
strerror
(
errno
));
tError
(
"%s failed to create TCP read data thread(%s)"
,
label
,
strerror
(
errno
));
...
@@ -330,7 +333,7 @@ void taosCleanUpTcpClient(void *chandle) {
...
@@ -330,7 +333,7 @@ void taosCleanUpTcpClient(void *chandle) {
void
*
taosOpenTcpClientConnection
(
void
*
shandle
,
void
*
thandle
,
uint32_t
ip
,
uint16_t
port
)
{
void
*
taosOpenTcpClientConnection
(
void
*
shandle
,
void
*
thandle
,
uint32_t
ip
,
uint16_t
port
)
{
SThreadObj
*
pThreadObj
=
shandle
;
SThreadObj
*
pThreadObj
=
shandle
;
int
fd
=
taosOpenTcpClientSocket
(
ip
,
port
,
pThreadObj
->
ip
);
SOCKET
fd
=
taosOpenTcpClientSocket
(
ip
,
port
,
pThreadObj
->
ip
);
if
(
fd
<
0
)
return
NULL
;
if
(
fd
<
0
)
return
NULL
;
struct
sockaddr_in
sin
;
struct
sockaddr_in
sin
;
...
@@ -350,7 +353,7 @@ void *taosOpenTcpClientConnection(void *shandle, void *thandle, uint32_t ip, uin
...
@@ -350,7 +353,7 @@ void *taosOpenTcpClientConnection(void *shandle, void *thandle, uint32_t ip, uin
tDebug
(
"%s %p TCP connection to 0x%x:%hu is created, localPort:%hu FD:%p numOfFds:%d"
,
tDebug
(
"%s %p TCP connection to 0x%x:%hu is created, localPort:%hu FD:%p numOfFds:%d"
,
pThreadObj
->
label
,
thandle
,
ip
,
port
,
localPort
,
pFdObj
,
pThreadObj
->
numOfFds
);
pThreadObj
->
label
,
thandle
,
ip
,
port
,
localPort
,
pFdObj
,
pThreadObj
->
numOfFds
);
}
else
{
}
else
{
close
(
fd
);
taosCloseSocket
(
fd
);
tError
(
"%s failed to malloc client FdObj(%s)"
,
pThreadObj
->
label
,
strerror
(
errno
));
tError
(
"%s failed to malloc client FdObj(%s)"
,
pThreadObj
->
label
,
strerror
(
errno
));
}
}
...
@@ -502,7 +505,7 @@ static void *taosProcessTcpData(void *param) {
...
@@ -502,7 +505,7 @@ static void *taosProcessTcpData(void *param) {
return
NULL
;
return
NULL
;
}
}
static
SFdObj
*
taosMallocFdObj
(
SThreadObj
*
pThreadObj
,
int
fd
)
{
static
SFdObj
*
taosMallocFdObj
(
SThreadObj
*
pThreadObj
,
SOCKET
fd
)
{
struct
epoll_event
event
;
struct
epoll_event
event
;
SFdObj
*
pFdObj
=
(
SFdObj
*
)
calloc
(
sizeof
(
SFdObj
),
1
);
SFdObj
*
pFdObj
=
(
SFdObj
*
)
calloc
(
sizeof
(
SFdObj
),
1
);
...
...
src/rpc/src/rpcUdp.c
浏览文件 @
14c90236
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
typedef
struct
{
typedef
struct
{
int
index
;
int
index
;
int
fd
;
SOCKET
fd
;
uint16_t
port
;
// peer port
uint16_t
port
;
// peer port
uint16_t
localPort
;
// local port
uint16_t
localPort
;
// local port
char
label
[
TSDB_LABEL_LEN
];
// copy from udpConnSet;
char
label
[
TSDB_LABEL_LEN
];
// copy from udpConnSet;
...
...
src/rpc/test/CMakeLists.txt
浏览文件 @
14c90236
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
PROJECT
(
TDengine
)
PROJECT
(
TDengine
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/os/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/util/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/common/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/rpc/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/rpc/inc
)
IF
(
(
TD_LINUX_64
)
OR
(
TD_LINUX_32 AND TD_ARM
)
)
IF
(
TD_LINUX_64
)
LIST
(
APPEND CLIENT_SRC ./rclient.c
)
LIST
(
APPEND CLIENT_SRC ./rclient.c
)
ADD_EXECUTABLE
(
rclient
${
CLIENT_SRC
}
)
ADD_EXECUTABLE
(
rclient
${
CLIENT_SRC
}
)
TARGET_LINK_LIBRARIES
(
rclient trpc
)
TARGET_LINK_LIBRARIES
(
rclient trpc
)
...
...
src/sync/test/CMakeLists.txt
浏览文件 @
14c90236
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
PROJECT
(
TDengine
)
PROJECT
(
TDengine
)
IF
((
TD_LINUX_64
)
OR
(
TD_LINUX_32 AND TD_ARM
))
IF
(
TD_LINUX_64
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/os/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/util/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/common/inc
)
INCLUDE_DIRECTORIES
(
../inc
)
INCLUDE_DIRECTORIES
(
../inc
)
LIST
(
APPEND CLIENT_SRC ./syncClient.c
)
LIST
(
APPEND CLIENT_SRC ./syncClient.c
)
...
...
src/util/inc/tsocket.h
浏览文件 @
14c90236
...
@@ -20,17 +20,17 @@
...
@@ -20,17 +20,17 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
int
taosReadn
(
int
sock
,
char
*
buffer
,
int
len
);
int
taosReadn
(
SOCKET
sock
,
char
*
buffer
,
int
len
);
int
taosWriteMsg
(
int
fd
,
void
*
ptr
,
int
nbytes
);
int
taosWriteMsg
(
SOCKET
fd
,
void
*
ptr
,
int
nbytes
);
int
taosReadMsg
(
int
fd
,
void
*
ptr
,
int
nbytes
);
int
taosReadMsg
(
SOCKET
fd
,
void
*
ptr
,
int
nbytes
);
int
taosNonblockwrite
(
int
fd
,
char
*
ptr
,
int
nbytes
);
int
taosNonblockwrite
(
SOCKET
fd
,
char
*
ptr
,
int
nbytes
);
int
taosCopyFds
(
int
sfd
,
int
dfd
,
int64_t
len
);
int
taosCopyFds
(
SOCKET
sfd
,
SOCKET
dfd
,
int64_t
len
);
int
taosSetNonblocking
(
int
sock
,
int
on
);
int
taosSetNonblocking
(
SOCKET
sock
,
int
on
);
int
taosOpenUdpSocket
(
uint32_t
localIp
,
uint16_t
localPort
);
SOCKET
taosOpenUdpSocket
(
uint32_t
localIp
,
uint16_t
localPort
);
int
taosOpenTcpClientSocket
(
uint32_t
ip
,
uint16_t
port
,
uint32_t
localIp
);
SOCKET
taosOpenTcpClientSocket
(
uint32_t
ip
,
uint16_t
port
,
uint32_t
localIp
);
int
taosOpenTcpServerSocket
(
uint32_t
ip
,
uint16_t
port
);
SOCKET
taosOpenTcpServerSocket
(
uint32_t
ip
,
uint16_t
port
);
int
taosKeepTcpAlive
(
int
sockFd
);
int
taosKeepTcpAlive
(
SOCKET
sockFd
);
int
taosGetFqdn
(
char
*
);
int
taosGetFqdn
(
char
*
);
uint32_t
taosGetIpFromFqdn
(
const
char
*
);
uint32_t
taosGetIpFromFqdn
(
const
char
*
);
...
...
src/util/src/tsocket.c
浏览文件 @
14c90236
...
@@ -90,7 +90,7 @@ uint32_t ip2uint(const char *const ip_addr) {
...
@@ -90,7 +90,7 @@ uint32_t ip2uint(const char *const ip_addr) {
return
*
((
unsigned
int
*
)
ip
);
return
*
((
unsigned
int
*
)
ip
);
}
}
int
taosWriteMsg
(
int
fd
,
void
*
buf
,
int
nbytes
)
{
int
taosWriteMsg
(
SOCKET
fd
,
void
*
buf
,
int
nbytes
)
{
int
nleft
,
nwritten
;
int
nleft
,
nwritten
;
char
*
ptr
=
(
char
*
)
buf
;
char
*
ptr
=
(
char
*
)
buf
;
...
@@ -112,7 +112,7 @@ int taosWriteMsg(int fd, void *buf, int nbytes) {
...
@@ -112,7 +112,7 @@ int taosWriteMsg(int fd, void *buf, int nbytes) {
return
(
nbytes
-
nleft
);
return
(
nbytes
-
nleft
);
}
}
int
taosReadMsg
(
int
fd
,
void
*
buf
,
int
nbytes
)
{
int
taosReadMsg
(
SOCKET
fd
,
void
*
buf
,
int
nbytes
)
{
int
nleft
,
nread
;
int
nleft
,
nread
;
char
*
ptr
=
(
char
*
)
buf
;
char
*
ptr
=
(
char
*
)
buf
;
...
@@ -139,7 +139,7 @@ int taosReadMsg(int fd, void *buf, int nbytes) {
...
@@ -139,7 +139,7 @@ int taosReadMsg(int fd, void *buf, int nbytes) {
return
(
nbytes
-
nleft
);
return
(
nbytes
-
nleft
);
}
}
int
taosNonblockwrite
(
int
fd
,
char
*
ptr
,
int
nbytes
)
{
int
taosNonblockwrite
(
SOCKET
fd
,
char
*
ptr
,
int
nbytes
)
{
taosSetNonblocking
(
fd
,
1
);
taosSetNonblocking
(
fd
,
1
);
int
nleft
,
nwritten
,
nready
;
int
nleft
,
nwritten
,
nready
;
...
@@ -152,7 +152,7 @@ int taosNonblockwrite(int fd, char *ptr, int nbytes) {
...
@@ -152,7 +152,7 @@ int taosNonblockwrite(int fd, char *ptr, int nbytes) {
tv
.
tv_usec
=
0
;
tv
.
tv_usec
=
0
;
FD_ZERO
(
&
fset
);
FD_ZERO
(
&
fset
);
FD_SET
(
fd
,
&
fset
);
FD_SET
(
fd
,
&
fset
);
if
((
nready
=
select
(
fd
+
1
,
NULL
,
&
fset
,
NULL
,
&
tv
))
==
0
)
{
if
((
nready
=
select
(
(
int
)(
fd
+
1
)
,
NULL
,
&
fset
,
NULL
,
&
tv
))
==
0
)
{
errno
=
ETIMEDOUT
;
errno
=
ETIMEDOUT
;
uError
(
"fd %d timeout, no enough space to write"
,
fd
);
uError
(
"fd %d timeout, no enough space to write"
,
fd
);
break
;
break
;
...
@@ -181,7 +181,7 @@ int taosNonblockwrite(int fd, char *ptr, int nbytes) {
...
@@ -181,7 +181,7 @@ int taosNonblockwrite(int fd, char *ptr, int nbytes) {
return
(
nbytes
-
nleft
);
return
(
nbytes
-
nleft
);
}
}
int
taosReadn
(
int
fd
,
char
*
ptr
,
int
nbytes
)
{
int
taosReadn
(
SOCKET
fd
,
char
*
ptr
,
int
nbytes
)
{
int
nread
,
nready
,
nleft
=
nbytes
;
int
nread
,
nready
,
nleft
=
nbytes
;
fd_set
fset
;
fd_set
fset
;
...
@@ -192,7 +192,7 @@ int taosReadn(int fd, char *ptr, int nbytes) {
...
@@ -192,7 +192,7 @@ int taosReadn(int fd, char *ptr, int nbytes) {
tv
.
tv_usec
=
0
;
tv
.
tv_usec
=
0
;
FD_ZERO
(
&
fset
);
FD_ZERO
(
&
fset
);
FD_SET
(
fd
,
&
fset
);
FD_SET
(
fd
,
&
fset
);
if
((
nready
=
select
(
fd
+
1
,
NULL
,
&
fset
,
NULL
,
&
tv
))
==
0
)
{
if
((
nready
=
select
(
(
int
)(
fd
+
1
)
,
NULL
,
&
fset
,
NULL
,
&
tv
))
==
0
)
{
errno
=
ETIMEDOUT
;
errno
=
ETIMEDOUT
;
uError
(
"fd %d timeout
\n
"
,
fd
);
uError
(
"fd %d timeout
\n
"
,
fd
);
break
;
break
;
...
@@ -219,9 +219,9 @@ int taosReadn(int fd, char *ptr, int nbytes) {
...
@@ -219,9 +219,9 @@ int taosReadn(int fd, char *ptr, int nbytes) {
return
(
nbytes
-
nleft
);
return
(
nbytes
-
nleft
);
}
}
int
taosOpenUdpSocket
(
uint32_t
ip
,
uint16_t
port
)
{
SOCKET
taosOpenUdpSocket
(
uint32_t
ip
,
uint16_t
port
)
{
struct
sockaddr_in
localAddr
;
struct
sockaddr_in
localAddr
;
int
sockFd
;
SOCKET
sockFd
;
int
bufSize
=
1024000
;
int
bufSize
=
1024000
;
uDebug
(
"open udp socket:0x%x:%hu"
,
ip
,
port
);
uDebug
(
"open udp socket:0x%x:%hu"
,
ip
,
port
);
...
@@ -238,32 +238,32 @@ int taosOpenUdpSocket(uint32_t ip, uint16_t port) {
...
@@ -238,32 +238,32 @@ int taosOpenUdpSocket(uint32_t ip, uint16_t port) {
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_SNDBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_SNDBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
uError
(
"failed to set the send buffer size for UDP socket
\n
"
);
uError
(
"failed to set the send buffer size for UDP socket
\n
"
);
close
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_RCVBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_RCVBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
uError
(
"failed to set the receive buffer size for UDP socket
\n
"
);
uError
(
"failed to set the receive buffer size for UDP socket
\n
"
);
close
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
/* bind socket to local address */
/* bind socket to local address */
if
(
bind
(
sockFd
,
(
struct
sockaddr
*
)
&
localAddr
,
sizeof
(
localAddr
))
<
0
)
{
if
(
bind
(
sockFd
,
(
struct
sockaddr
*
)
&
localAddr
,
sizeof
(
localAddr
))
<
0
)
{
uError
(
"failed to bind udp socket: %d (%s), 0x%x:%hu"
,
errno
,
strerror
(
errno
),
ip
,
port
);
uError
(
"failed to bind udp socket: %d (%s), 0x%x:%hu"
,
errno
,
strerror
(
errno
),
ip
,
port
);
close
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
return
sockFd
;
return
sockFd
;
}
}
int
taosOpenTcpClientSocket
(
uint32_t
destIp
,
uint16_t
destPort
,
uint32_t
clientIp
)
{
SOCKET
taosOpenTcpClientSocket
(
uint32_t
destIp
,
uint16_t
destPort
,
uint32_t
clientIp
)
{
int
sockFd
=
0
;
SOCKET
sockFd
=
0
;
struct
sockaddr_in
serverAddr
,
clientAddr
;
struct
sockaddr_in
serverAddr
,
clientAddr
;
int
ret
;
int
ret
;
sockFd
=
(
int
)
socket
(
PF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
sockFd
=
socket
(
PF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
if
(
sockFd
<
0
)
{
if
(
sockFd
<
0
)
{
uError
(
"failed to open the socket: %d (%s)"
,
errno
,
strerror
(
errno
));
uError
(
"failed to open the socket: %d (%s)"
,
errno
,
strerror
(
errno
));
...
@@ -274,11 +274,11 @@ int taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clientI
...
@@ -274,11 +274,11 @@ int taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clientI
int
reuse
=
1
;
int
reuse
=
1
;
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
void
*
)
&
reuse
,
sizeof
(
reuse
))
<
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
void
*
)
&
reuse
,
sizeof
(
reuse
))
<
0
)
{
uError
(
"setsockopt SO_REUSEADDR failed: %d (%s)"
,
errno
,
strerror
(
errno
));
uError
(
"setsockopt SO_REUSEADDR failed: %d (%s)"
,
errno
,
strerror
(
errno
));
close
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
};
};
if
(
clientIp
!=
0
)
{
if
(
clientIp
!=
0
)
{
memset
((
char
*
)
&
clientAddr
,
0
,
sizeof
(
clientAddr
));
memset
((
char
*
)
&
clientAddr
,
0
,
sizeof
(
clientAddr
));
clientAddr
.
sin_family
=
AF_INET
;
clientAddr
.
sin_family
=
AF_INET
;
clientAddr
.
sin_addr
.
s_addr
=
clientIp
;
clientAddr
.
sin_addr
.
s_addr
=
clientIp
;
...
@@ -288,7 +288,7 @@ int taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clientI
...
@@ -288,7 +288,7 @@ int taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clientI
if
(
bind
(
sockFd
,
(
struct
sockaddr
*
)
&
clientAddr
,
sizeof
(
clientAddr
))
<
0
)
{
if
(
bind
(
sockFd
,
(
struct
sockaddr
*
)
&
clientAddr
,
sizeof
(
clientAddr
))
<
0
)
{
uError
(
"bind tcp client socket failed, client(0x%x:0), dest(0x%x:%d), reason:(%s)"
,
uError
(
"bind tcp client socket failed, client(0x%x:0), dest(0x%x:%d), reason:(%s)"
,
clientIp
,
destIp
,
destPort
,
strerror
(
errno
));
clientIp
,
destIp
,
destPort
,
strerror
(
errno
));
close
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -302,7 +302,7 @@ int taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clientI
...
@@ -302,7 +302,7 @@ int taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clientI
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
//uError("failed to connect socket, ip:0x%x, port:%hu(%s)", destIp, destPort, strerror(errno));
//uError("failed to connect socket, ip:0x%x, port:%hu(%s)", destIp, destPort, strerror(errno));
close
(
sockFd
);
taosCloseSocket
(
sockFd
);
sockFd
=
-
1
;
sockFd
=
-
1
;
}
else
{
}
else
{
taosKeepTcpAlive
(
sockFd
);
taosKeepTcpAlive
(
sockFd
);
...
@@ -311,39 +311,39 @@ int taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clientI
...
@@ -311,39 +311,39 @@ int taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clientI
return
sockFd
;
return
sockFd
;
}
}
int
taosKeepTcpAlive
(
int
sockFd
)
{
int
taosKeepTcpAlive
(
SOCKET
sockFd
)
{
int
alive
=
1
;
int
alive
=
1
;
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_KEEPALIVE
,
(
void
*
)
&
alive
,
sizeof
(
alive
))
<
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_KEEPALIVE
,
(
void
*
)
&
alive
,
sizeof
(
alive
))
<
0
)
{
uError
(
"fd:%d setsockopt SO_KEEPALIVE failed: %d (%s)"
,
sockFd
,
errno
,
strerror
(
errno
));
uError
(
"fd:%d setsockopt SO_KEEPALIVE failed: %d (%s)"
,
sockFd
,
errno
,
strerror
(
errno
));
close
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
int
probes
=
3
;
int
probes
=
3
;
if
(
taosSetSockOpt
(
sockFd
,
SOL_TCP
,
TCP_KEEPCNT
,
(
void
*
)
&
probes
,
sizeof
(
probes
))
<
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_TCP
,
TCP_KEEPCNT
,
(
void
*
)
&
probes
,
sizeof
(
probes
))
<
0
)
{
uError
(
"fd:%d setsockopt SO_KEEPCNT failed: %d (%s)"
,
sockFd
,
errno
,
strerror
(
errno
));
uError
(
"fd:%d setsockopt SO_KEEPCNT failed: %d (%s)"
,
sockFd
,
errno
,
strerror
(
errno
));
close
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
int
alivetime
=
10
;
int
alivetime
=
10
;
if
(
taosSetSockOpt
(
sockFd
,
SOL_TCP
,
TCP_KEEPIDLE
,
(
void
*
)
&
alivetime
,
sizeof
(
alivetime
))
<
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_TCP
,
TCP_KEEPIDLE
,
(
void
*
)
&
alivetime
,
sizeof
(
alivetime
))
<
0
)
{
uError
(
"fd:%d setsockopt SO_KEEPIDLE failed: %d (%s)"
,
sockFd
,
errno
,
strerror
(
errno
));
uError
(
"fd:%d setsockopt SO_KEEPIDLE failed: %d (%s)"
,
sockFd
,
errno
,
strerror
(
errno
));
close
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
int
interval
=
3
;
int
interval
=
3
;
if
(
taosSetSockOpt
(
sockFd
,
SOL_TCP
,
TCP_KEEPINTVL
,
(
void
*
)
&
interval
,
sizeof
(
interval
))
<
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_TCP
,
TCP_KEEPINTVL
,
(
void
*
)
&
interval
,
sizeof
(
interval
))
<
0
)
{
uError
(
"fd:%d setsockopt SO_KEEPINTVL failed: %d (%s)"
,
sockFd
,
errno
,
strerror
(
errno
));
uError
(
"fd:%d setsockopt SO_KEEPINTVL failed: %d (%s)"
,
sockFd
,
errno
,
strerror
(
errno
));
close
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
int
nodelay
=
1
;
int
nodelay
=
1
;
if
(
taosSetSockOpt
(
sockFd
,
IPPROTO_TCP
,
TCP_NODELAY
,
(
void
*
)
&
nodelay
,
sizeof
(
nodelay
))
<
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
IPPROTO_TCP
,
TCP_NODELAY
,
(
void
*
)
&
nodelay
,
sizeof
(
nodelay
))
<
0
)
{
uError
(
"fd:%d setsockopt TCP_NODELAY failed %d (%s)"
,
sockFd
,
errno
,
strerror
(
errno
));
uError
(
"fd:%d setsockopt TCP_NODELAY failed %d (%s)"
,
sockFd
,
errno
,
strerror
(
errno
));
close
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
...
@@ -352,16 +352,16 @@ int taosKeepTcpAlive(int sockFd) {
...
@@ -352,16 +352,16 @@ int taosKeepTcpAlive(int sockFd) {
linger
.
l_linger
=
3
;
linger
.
l_linger
=
3
;
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_LINGER
,
(
void
*
)
&
linger
,
sizeof
(
linger
))
<
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_LINGER
,
(
void
*
)
&
linger
,
sizeof
(
linger
))
<
0
)
{
uError
(
"setsockopt SO_LINGER failed: %d (%s)"
,
errno
,
strerror
(
errno
));
uError
(
"setsockopt SO_LINGER failed: %d (%s)"
,
errno
,
strerror
(
errno
));
close
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
}
}
int
taosOpenTcpServerSocket
(
uint32_t
ip
,
uint16_t
port
)
{
SOCKET
taosOpenTcpServerSocket
(
uint32_t
ip
,
uint16_t
port
)
{
struct
sockaddr_in
serverAdd
;
struct
sockaddr_in
serverAdd
;
int
sockFd
;
SOCKET
sockFd
;
int
reuse
;
int
reuse
;
uDebug
(
"open tcp server socket:0x%x:%hu"
,
ip
,
port
);
uDebug
(
"open tcp server socket:0x%x:%hu"
,
ip
,
port
);
...
@@ -380,26 +380,26 @@ int taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
...
@@ -380,26 +380,26 @@ int taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
reuse
=
1
;
reuse
=
1
;
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
void
*
)
&
reuse
,
sizeof
(
reuse
))
<
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
void
*
)
&
reuse
,
sizeof
(
reuse
))
<
0
)
{
uError
(
"setsockopt SO_REUSEADDR failed: %d (%s)"
,
errno
,
strerror
(
errno
));
uError
(
"setsockopt SO_REUSEADDR failed: %d (%s)"
,
errno
,
strerror
(
errno
));
close
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
};
};
/* bind socket to server address */
/* bind socket to server address */
if
(
bind
(
sockFd
,
(
struct
sockaddr
*
)
&
serverAdd
,
sizeof
(
serverAdd
))
<
0
)
{
if
(
bind
(
sockFd
,
(
struct
sockaddr
*
)
&
serverAdd
,
sizeof
(
serverAdd
))
<
0
)
{
uError
(
"bind tcp server socket failed, 0x%x:%hu(%s)"
,
ip
,
port
,
strerror
(
errno
));
uError
(
"bind tcp server socket failed, 0x%x:%hu(%s)"
,
ip
,
port
,
strerror
(
errno
));
close
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
if
(
taosKeepTcpAlive
(
sockFd
)
<
0
)
{
if
(
taosKeepTcpAlive
(
sockFd
)
<
0
)
{
uError
(
"failed to set tcp server keep-alive option, 0x%x:%hu(%s)"
,
ip
,
port
,
strerror
(
errno
));
uError
(
"failed to set tcp server keep-alive option, 0x%x:%hu(%s)"
,
ip
,
port
,
strerror
(
errno
));
close
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
if
(
listen
(
sockFd
,
10
)
<
0
)
{
if
(
listen
(
sockFd
,
10
)
<
0
)
{
uError
(
"listen tcp server socket failed, 0x%x:%hu(%s)"
,
ip
,
port
,
strerror
(
errno
));
uError
(
"listen tcp server socket failed, 0x%x:%hu(%s)"
,
ip
,
port
,
strerror
(
errno
));
close
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
...
@@ -413,7 +413,7 @@ void tinet_ntoa(char *ipstr, unsigned int ip) {
...
@@ -413,7 +413,7 @@ void tinet_ntoa(char *ipstr, unsigned int ip) {
#define COPY_SIZE 32768
#define COPY_SIZE 32768
// sendfile shall be used
// sendfile shall be used
int
taosCopyFds
(
int
sfd
,
int
dfd
,
int64_t
len
)
{
int
taosCopyFds
(
SOCKET
sfd
,
SOCKET
dfd
,
int64_t
len
)
{
int64_t
leftLen
;
int64_t
leftLen
;
int
readLen
,
writeLen
;
int
readLen
,
writeLen
;
char
temp
[
COPY_SIZE
];
char
temp
[
COPY_SIZE
];
...
...
src/wal/test/CMakeLists.txt
浏览文件 @
14c90236
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
PROJECT
(
TDengine
)
PROJECT
(
TDengine
)
IF
((
TD_LINUX_64
)
OR
(
TD_LINUX_32 AND TD_ARM
))
IF
(
TD_LINUX_64
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/os/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/util/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/common/inc
)
INCLUDE_DIRECTORIES
(
../inc
)
INCLUDE_DIRECTORIES
(
../inc
)
LIST
(
APPEND WALTEST_SRC ./waltest.c
)
LIST
(
APPEND WALTEST_SRC ./waltest.c
)
...
...
tests/comparisonTest/tdengine/CMakeLists.txt
浏览文件 @
14c90236
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
PROJECT
(
TDengine
)
PROJECT
(
TDengine
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/inc
)
IF
(
TD_LINUX_64
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/util/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/common/inc
)
INCLUDE_DIRECTORIES
(
${
TD_OS_DIR
}
/inc
)
IF
((
TD_LINUX_64
)
OR
(
TD_LINUX_32 AND TD_ARM
))
add_executable
(
tdengineTest tdengineTest.c
)
add_executable
(
tdengineTest tdengineTest.c
)
target_link_libraries
(
tdengineTest taos_static tutil common pthread
)
target_link_libraries
(
tdengineTest taos_static tutil common pthread
)
ENDIF
()
ENDIF
()
tests/tsim/CMakeLists.txt
浏览文件 @
14c90236
PROJECT
(
TDengine
)
PROJECT
(
TDengine
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/os/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/util/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/common/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/client/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/client/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/cJson/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/cJson/inc
)
INCLUDE_DIRECTORIES
(
inc
)
INCLUDE_DIRECTORIES
(
inc
)
IF
(
TD_WINDOWS
_64
)
IF
(
TD_WINDOWS
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/pthread
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/pthread
)
ENDIF
()
ENDIF
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录