Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cc68f2e2
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
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看板
未验证
提交
cc68f2e2
编写于
3月 07, 2022
作者:
wafwerar
提交者:
GitHub
3月 07, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10587 from taosdata/fix/ZhiqiangWang/TD-13760-libuv-replace-socket-error
[TD-13760]<fix>: libuv replace socket error.
上级
611a2c62
15f33923
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
134 addition
and
143 deletion
+134
-143
include/libs/transport/thttp.h
include/libs/transport/thttp.h
+0
-0
include/os/osSocket.h
include/os/osSocket.h
+4
-13
source/libs/catalog/test/CMakeLists.txt
source/libs/catalog/test/CMakeLists.txt
+4
-4
source/libs/monitor/CMakeLists.txt
source/libs/monitor/CMakeLists.txt
+2
-1
source/libs/transport/src/thttp.c
source/libs/transport/src/thttp.c
+4
-6
source/os/CMakeLists.txt
source/os/CMakeLists.txt
+1
-1
source/os/src/osSocket.c
source/os/src/osSocket.c
+119
-118
未找到文件。
include/
util
/thttp.h
→
include/
libs/transport
/thttp.h
浏览文件 @
cc68f2e2
文件已移动
include/os/osSocket.h
浏览文件 @
cc68f2e2
...
@@ -34,16 +34,10 @@
...
@@ -34,16 +34,10 @@
#include <sys/epoll.h>
#include <sys/epoll.h>
#endif
#endif
#ifdef USE_UV
#include <uv.h>
#endif
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
#ifndef USE_UV
#define TAOS_EPOLL_WAIT_TIME 500
#define TAOS_EPOLL_WAIT_TIME 500
typedef
int32_t
SOCKET
;
typedef
int32_t
SOCKET
;
typedef
SOCKET
EpollFd
;
typedef
SOCKET
EpollFd
;
...
@@ -63,8 +57,6 @@ int32_t taosCloseSocket(SocketFd fd);
...
@@ -63,8 +57,6 @@ int32_t taosCloseSocket(SocketFd fd);
void
taosShutDownSocketRD
(
SOCKET
fd
);
void
taosShutDownSocketRD
(
SOCKET
fd
);
void
taosShutDownSocketWR
(
SOCKET
fd
);
void
taosShutDownSocketWR
(
SOCKET
fd
);
int32_t
taosSetNonblocking
(
SOCKET
sock
,
int32_t
on
);
int32_t
taosSetNonblocking
(
SOCKET
sock
,
int32_t
on
);
void
taosIgnSIGPIPE
();
void
taosSetMaskSIGPIPE
();
int32_t
taosSetSockOpt
(
SOCKET
socketfd
,
int32_t
level
,
int32_t
optname
,
void
*
optval
,
int32_t
optlen
);
int32_t
taosSetSockOpt
(
SOCKET
socketfd
,
int32_t
level
,
int32_t
optname
,
void
*
optval
,
int32_t
optlen
);
int32_t
taosGetSockOpt
(
SOCKET
socketfd
,
int32_t
level
,
int32_t
optname
,
void
*
optval
,
int32_t
*
optlen
);
int32_t
taosGetSockOpt
(
SOCKET
socketfd
,
int32_t
level
,
int32_t
optname
,
void
*
optval
,
int32_t
*
optlen
);
...
@@ -94,14 +86,13 @@ SOCKET taosOpenTcpClientSocket(uint32_t ip, uint16_t port, uint32_t localIp);
...
@@ -94,14 +86,13 @@ SOCKET taosOpenTcpClientSocket(uint32_t ip, uint16_t port, uint32_t localIp);
SOCKET
taosOpenTcpServerSocket
(
uint32_t
ip
,
uint16_t
port
);
SOCKET
taosOpenTcpServerSocket
(
uint32_t
ip
,
uint16_t
port
);
int32_t
taosKeepTcpAlive
(
SOCKET
sockFd
);
int32_t
taosKeepTcpAlive
(
SOCKET
sockFd
);
int32_t
taosGetFqdn
(
char
*
);
void
taosBlockSIGPIPE
(
);
uint32_t
taosGetIpv4FromFqdn
(
const
char
*
);
uint32_t
taosGetIpv4FromFqdn
(
const
char
*
);
int32_t
taosGetFqdn
(
char
*
);
void
tinet_ntoa
(
char
*
ipstr
,
uint32_t
ip
);
void
tinet_ntoa
(
char
*
ipstr
,
uint32_t
ip
);
uint32_t
ip2uint
(
const
char
*
const
ip_addr
);
uint32_t
ip2uint
(
const
char
*
const
ip_addr
);
void
taosIgnSIGPIPE
();
#endif
void
taosSetMaskSIGPIPE
();
void
taosBlockSIGPIPE
();
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/catalog/test/CMakeLists.txt
浏览文件 @
cc68f2e2
...
@@ -17,7 +17,7 @@ TARGET_INCLUDE_DIRECTORIES(
...
@@ -17,7 +17,7 @@ TARGET_INCLUDE_DIRECTORIES(
PRIVATE
"
${
CMAKE_SOURCE_DIR
}
/source/libs/catalog/inc"
PRIVATE
"
${
CMAKE_SOURCE_DIR
}
/source/libs/catalog/inc"
)
)
add_test
(
#
add_test(
NAME catalogTest
#
NAME catalogTest
COMMAND catalogTest
#
COMMAND catalogTest
)
#
)
source/libs/monitor/CMakeLists.txt
浏览文件 @
cc68f2e2
...
@@ -3,10 +3,11 @@ add_library(monitor STATIC ${MONITOR_SRC})
...
@@ -3,10 +3,11 @@ add_library(monitor STATIC ${MONITOR_SRC})
target_include_directories
(
target_include_directories
(
monitor
monitor
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/monitor"
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/monitor"
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/transport"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
)
target_link_libraries
(
monitor os util common
)
target_link_libraries
(
monitor os util common
transport
)
if
(
${
BUILD_TEST
}
)
if
(
${
BUILD_TEST
}
)
add_subdirectory
(
test
)
add_subdirectory
(
test
)
...
...
source/
util
/src/thttp.c
→
source/
libs/transport
/src/thttp.c
浏览文件 @
cc68f2e2
...
@@ -111,24 +111,22 @@ _OVER:
...
@@ -111,24 +111,22 @@ _OVER:
}
}
#ifdef USE_UV
#ifdef USE_UV
#include <uv.h>
static
void
clientConnCb
(
uv_connect_t
*
req
,
int32_t
status
)
{
static
void
clientConnCb
(
uv_connect_t
*
req
,
int32_t
status
)
{
if
(
status
<
0
)
{
if
(
status
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
status
);
terrno
=
TAOS_SYSTEM_ERROR
(
status
);
uError
(
"Connection error %s
\n
"
,
uv_strerror
(
status
));
uError
(
"Connection error %s
\n
"
,
uv_strerror
(
status
));
uv_close
((
uv_handle_t
*
)
req
->
handle
,
NULL
);
return
;
return
;
}
}
// impl later
uv_buf_t
*
wb
=
req
->
data
;
uv_buf_t
*
wb
=
req
->
data
;
if
(
wb
==
NULL
)
{
assert
(
wb
!=
NULL
);
uv_close
((
uv_handle_t
*
)
req
->
handle
,
NULL
);
}
uv_write_t
write_req
;
uv_write_t
write_req
;
uv_write
(
&
write_req
,
req
->
handle
,
wb
,
2
,
NULL
);
uv_write
(
&
write_req
,
req
->
handle
,
wb
,
2
,
NULL
);
uv_close
((
uv_handle_t
*
)
req
->
handle
,
NULL
);
uv_close
((
uv_handle_t
*
)
req
->
handle
,
NULL
);
}
}
int32_t
taosSendHttpReport
(
const
char
*
server
,
uint16_t
port
,
c
onst
c
har
*
pCont
,
int32_t
contLen
,
EHttpCompFlag
flag
)
{
int32_t
taosSendHttpReport
(
const
char
*
server
,
uint16_t
port
,
char
*
pCont
,
int32_t
contLen
,
EHttpCompFlag
flag
)
{
uint32_t
ipv4
=
taosGetIpv4FromFqdn
(
server
);
uint32_t
ipv4
=
taosGetIpv4FromFqdn
(
server
);
if
(
ipv4
==
0xffffffff
)
{
if
(
ipv4
==
0xffffffff
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
...
...
source/os/CMakeLists.txt
浏览文件 @
cc68f2e2
...
@@ -7,4 +7,4 @@ target_include_directories(
...
@@ -7,4 +7,4 @@ target_include_directories(
)
)
target_link_libraries
(
target_link_libraries
(
os pthread dl rt m
os pthread dl rt m
)
)
\ No newline at end of file
source/os/src/osSocket.c
浏览文件 @
cc68f2e2
...
@@ -34,8 +34,6 @@
...
@@ -34,8 +34,6 @@
#include <unistd.h>
#include <unistd.h>
#endif
#endif
#ifndef USE_UV
// typedef struct TdSocketServer {
// typedef struct TdSocketServer {
// #if SOCKET_WITH_LOCK
// #if SOCKET_WITH_LOCK
// pthread_rwlock_t rwlock;
// pthread_rwlock_t rwlock;
...
@@ -131,18 +129,8 @@ int32_t taosSetNonblocking(SOCKET sock, int32_t on) {
...
@@ -131,18 +129,8 @@ int32_t taosSetNonblocking(SOCKET sock, int32_t on) {
return
0
;
return
0
;
}
}
void
taosIgnSIGPIPE
()
{
signal
(
SIGPIPE
,
SIG_IGN
);
}
void
taosSetMaskSIGPIPE
()
{
sigset_t
signal_mask
;
sigemptyset
(
&
signal_mask
);
sigaddset
(
&
signal_mask
,
SIGPIPE
);
int32_t
rc
=
pthread_sigmask
(
SIG_SETMASK
,
&
signal_mask
,
NULL
);
if
(
rc
!=
0
)
{
//printf("failed to setmask SIGPIPE");
}
}
#endif
#endif
...
@@ -223,9 +211,6 @@ int32_t taosSetNonblocking(SOCKET sock, int32_t on) {
...
@@ -223,9 +211,6 @@ int32_t taosSetNonblocking(SOCKET sock, int32_t on) {
return
0
;
return
0
;
}
}
void
taosIgnSIGPIPE
()
{}
void
taosSetMaskSIGPIPE
()
{}
int32_t
taosSetSockOpt
(
SOCKET
socketfd
,
int32_t
level
,
int32_t
optname
,
void
*
optval
,
int32_t
optlen
)
{
int32_t
taosSetSockOpt
(
SOCKET
socketfd
,
int32_t
level
,
int32_t
optname
,
void
*
optval
,
int32_t
optlen
)
{
if
(
level
==
SOL_SOCKET
&&
optname
==
TCP_KEEPCNT
)
{
if
(
level
==
SOL_SOCKET
&&
optname
==
TCP_KEEPCNT
)
{
return
0
;
return
0
;
...
@@ -282,98 +267,6 @@ uint64_t htonll(uint64_t val) { return (((uint64_t)htonl(val)) << 32) + htonl(va
...
@@ -282,98 +267,6 @@ uint64_t htonll(uint64_t val) { return (((uint64_t)htonl(val)) << 32) + htonl(va
#define TCP_CONN_TIMEOUT 3000 // conn timeout
#define TCP_CONN_TIMEOUT 3000 // conn timeout
int32_t
taosGetFqdn
(
char
*
fqdn
)
{
char
hostname
[
1024
];
hostname
[
1023
]
=
'\0'
;
if
(
gethostname
(
hostname
,
1023
)
==
-
1
)
{
//printf("failed to get hostname, reason:%s", strerror(errno));
return
-
1
;
}
struct
addrinfo
hints
=
{
0
};
struct
addrinfo
*
result
=
NULL
;
#ifdef __APPLE__
// on macosx, hostname -f has the form of xxx.local
// which will block getaddrinfo for a few seconds if AI_CANONNAME is set
// thus, we choose AF_INET (ipv4 for the moment) to make getaddrinfo return
// immediately
hints
.
ai_family
=
AF_INET
;
#else // __APPLE__
hints
.
ai_flags
=
AI_CANONNAME
;
#endif // __APPLE__
int32_t
ret
=
getaddrinfo
(
hostname
,
NULL
,
&
hints
,
&
result
);
if
(
!
result
)
{
//printf("failed to get fqdn, code:%d, reason:%s", ret, gai_strerror(ret));
return
-
1
;
}
#ifdef __APPLE__
// refer to comments above
strcpy
(
fqdn
,
hostname
);
#else // __APPLE__
strcpy
(
fqdn
,
result
->
ai_canonname
);
#endif // __APPLE__
freeaddrinfo
(
result
);
return
0
;
}
uint32_t
taosGetIpv4FromFqdn
(
const
char
*
fqdn
)
{
struct
addrinfo
hints
=
{
0
};
hints
.
ai_family
=
AF_INET
;
hints
.
ai_socktype
=
SOCK_STREAM
;
struct
addrinfo
*
result
=
NULL
;
int32_t
ret
=
getaddrinfo
(
fqdn
,
NULL
,
&
hints
,
&
result
);
if
(
result
)
{
struct
sockaddr
*
sa
=
result
->
ai_addr
;
struct
sockaddr_in
*
si
=
(
struct
sockaddr_in
*
)
sa
;
struct
in_addr
ia
=
si
->
sin_addr
;
uint32_t
ip
=
ia
.
s_addr
;
freeaddrinfo
(
result
);
return
ip
;
}
else
{
#ifdef EAI_SYSTEM
if
(
ret
==
EAI_SYSTEM
)
{
//printf("failed to get the ip address, fqdn:%s, since:%s", fqdn, strerror(errno));
}
else
{
//printf("failed to get the ip address, fqdn:%s, since:%s", fqdn, gai_strerror(ret));
}
#else
//printf("failed to get the ip address, fqdn:%s, since:%s", fqdn, gai_strerror(ret));
#endif
return
0xFFFFFFFF
;
}
}
// Function converting an IP address string to an uint32_t.
uint32_t
ip2uint
(
const
char
*
const
ip_addr
)
{
char
ip_addr_cpy
[
20
];
char
ip
[
5
];
tstrncpy
(
ip_addr_cpy
,
ip_addr
,
sizeof
(
ip_addr_cpy
));
char
*
s_start
,
*
s_end
;
s_start
=
ip_addr_cpy
;
s_end
=
ip_addr_cpy
;
int32_t
k
;
for
(
k
=
0
;
*
s_start
!=
'\0'
;
s_start
=
s_end
)
{
for
(
s_end
=
s_start
;
*
s_end
!=
'.'
&&
*
s_end
!=
'\0'
;
s_end
++
)
{
}
if
(
*
s_end
==
'.'
)
{
*
s_end
=
'\0'
;
s_end
++
;
}
ip
[
k
++
]
=
(
char
)
atoi
(
s_start
);
}
ip
[
k
]
=
'\0'
;
return
*
((
uint32_t
*
)
ip
);
}
int32_t
taosWriteMsg
(
SOCKET
fd
,
void
*
buf
,
int32_t
nbytes
)
{
int32_t
taosWriteMsg
(
SOCKET
fd
,
void
*
buf
,
int32_t
nbytes
)
{
int32_t
nleft
,
nwritten
;
int32_t
nleft
,
nwritten
;
char
*
ptr
=
(
char
*
)
buf
;
char
*
ptr
=
(
char
*
)
buf
;
...
@@ -754,10 +647,6 @@ SOCKET taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
...
@@ -754,10 +647,6 @@ SOCKET taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
return
sockFd
;
return
sockFd
;
}
}
void
tinet_ntoa
(
char
*
ipstr
,
uint32_t
ip
)
{
sprintf
(
ipstr
,
"%d.%d.%d.%d"
,
ip
&
0xFF
,
(
ip
>>
8
)
&
0xFF
,
(
ip
>>
16
)
&
0xFF
,
ip
>>
24
);
}
#define COPY_SIZE 32768
#define COPY_SIZE 32768
// sendfile shall be used
// sendfile shall be used
...
@@ -795,12 +684,9 @@ int64_t taosCopyFds(SOCKET sfd, int32_t dfd, int64_t len) {
...
@@ -795,12 +684,9 @@ int64_t taosCopyFds(SOCKET sfd, int32_t dfd, int64_t len) {
return
len
;
return
len
;
}
}
#endif
#if !(defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32))
void
taosBlockSIGPIPE
()
{
void
taosBlockSIGPIPE
()
{
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
#else
sigset_t
signal_mask
;
sigset_t
signal_mask
;
sigemptyset
(
&
signal_mask
);
sigemptyset
(
&
signal_mask
);
sigaddset
(
&
signal_mask
,
SIGPIPE
);
sigaddset
(
&
signal_mask
,
SIGPIPE
);
...
@@ -808,7 +694,122 @@ void taosBlockSIGPIPE() {
...
@@ -808,7 +694,122 @@ void taosBlockSIGPIPE() {
if
(
rc
!=
0
)
{
if
(
rc
!=
0
)
{
//printf("failed to block SIGPIPE");
//printf("failed to block SIGPIPE");
}
}
#endif
}
uint32_t
taosGetIpv4FromFqdn
(
const
char
*
fqdn
)
{
struct
addrinfo
hints
=
{
0
};
hints
.
ai_family
=
AF_INET
;
hints
.
ai_socktype
=
SOCK_STREAM
;
struct
addrinfo
*
result
=
NULL
;
int32_t
ret
=
getaddrinfo
(
fqdn
,
NULL
,
&
hints
,
&
result
);
if
(
result
)
{
struct
sockaddr
*
sa
=
result
->
ai_addr
;
struct
sockaddr_in
*
si
=
(
struct
sockaddr_in
*
)
sa
;
struct
in_addr
ia
=
si
->
sin_addr
;
uint32_t
ip
=
ia
.
s_addr
;
freeaddrinfo
(
result
);
return
ip
;
}
else
{
#ifdef EAI_SYSTEM
if
(
ret
==
EAI_SYSTEM
)
{
//printf("failed to get the ip address, fqdn:%s, since:%s", fqdn, strerror(errno));
}
else
{
//printf("failed to get the ip address, fqdn:%s, since:%s", fqdn, gai_strerror(ret));
}
#else
//printf("failed to get the ip address, fqdn:%s, since:%s", fqdn, gai_strerror(ret));
#endif
return
0xFFFFFFFF
;
}
}
int32_t
taosGetFqdn
(
char
*
fqdn
)
{
char
hostname
[
1024
];
hostname
[
1023
]
=
'\0'
;
if
(
gethostname
(
hostname
,
1023
)
==
-
1
)
{
//printf("failed to get hostname, reason:%s", strerror(errno));
return
-
1
;
}
struct
addrinfo
hints
=
{
0
};
struct
addrinfo
*
result
=
NULL
;
#ifdef __APPLE__
// on macosx, hostname -f has the form of xxx.local
// which will block getaddrinfo for a few seconds if AI_CANONNAME is set
// thus, we choose AF_INET (ipv4 for the moment) to make getaddrinfo return
// immediately
hints
.
ai_family
=
AF_INET
;
#else // __APPLE__
hints
.
ai_flags
=
AI_CANONNAME
;
#endif // __APPLE__
int32_t
ret
=
getaddrinfo
(
hostname
,
NULL
,
&
hints
,
&
result
);
if
(
!
result
)
{
//printf("failed to get fqdn, code:%d, reason:%s", ret, gai_strerror(ret));
return
-
1
;
}
#ifdef __APPLE__
// refer to comments above
strcpy
(
fqdn
,
hostname
);
#else // __APPLE__
strcpy
(
fqdn
,
result
->
ai_canonname
);
#endif // __APPLE__
freeaddrinfo
(
result
);
return
0
;
}
}
// Function converting an IP address string to an uint32_t.
uint32_t
ip2uint
(
const
char
*
const
ip_addr
)
{
char
ip_addr_cpy
[
20
];
char
ip
[
5
];
tstrncpy
(
ip_addr_cpy
,
ip_addr
,
sizeof
(
ip_addr_cpy
));
char
*
s_start
,
*
s_end
;
s_start
=
ip_addr_cpy
;
s_end
=
ip_addr_cpy
;
int32_t
k
;
for
(
k
=
0
;
*
s_start
!=
'\0'
;
s_start
=
s_end
)
{
for
(
s_end
=
s_start
;
*
s_end
!=
'.'
&&
*
s_end
!=
'\0'
;
s_end
++
)
{
}
if
(
*
s_end
==
'.'
)
{
*
s_end
=
'\0'
;
s_end
++
;
}
ip
[
k
++
]
=
(
char
)
atoi
(
s_start
);
}
ip
[
k
]
=
'\0'
;
return
*
((
uint32_t
*
)
ip
);
}
void
tinet_ntoa
(
char
*
ipstr
,
uint32_t
ip
)
{
sprintf
(
ipstr
,
"%d.%d.%d.%d"
,
ip
&
0xFF
,
(
ip
>>
8
)
&
0xFF
,
(
ip
>>
16
)
&
0xFF
,
ip
>>
24
);
}
void
taosIgnSIGPIPE
()
{
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
#else
#else
void
taosBlockSIGPIPE
()
{}
signal
(
SIGPIPE
,
SIG_IGN
);
#endif
#endif
\ No newline at end of file
}
void
taosSetMaskSIGPIPE
()
{
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
#else
sigset_t
signal_mask
;
sigemptyset
(
&
signal_mask
);
sigaddset
(
&
signal_mask
,
SIGPIPE
);
int32_t
rc
=
pthread_sigmask
(
SIG_SETMASK
,
&
signal_mask
,
NULL
);
if
(
rc
!=
0
)
{
//printf("failed to setmask SIGPIPE");
}
#endif
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录