Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f294d606
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f294d606
编写于
2月 23, 2023
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: fix asan problem
上级
2e25f7e9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
50 addition
and
38 deletion
+50
-38
include/libs/transport/thttp.h
include/libs/transport/thttp.h
+3
-1
source/libs/transport/src/thttp.c
source/libs/transport/src/thttp.c
+40
-31
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+5
-6
source/libs/transport/src/transSvr.c
source/libs/transport/src/transSvr.c
+2
-0
未找到文件。
include/libs/transport/thttp.h
浏览文件 @
f294d606
...
...
@@ -17,6 +17,7 @@
#define _TD_UTIL_HTTP_H_
#include "os.h"
#include "tref.h"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -24,7 +25,8 @@ extern "C" {
typedef
enum
{
HTTP_GZIP
,
HTTP_FLAT
}
EHttpCompFlag
;
int32_t
taosSendHttpReport
(
const
char
*
server
,
const
char
*
uri
,
uint16_t
port
,
char
*
pCont
,
int32_t
contLen
,
EHttpCompFlag
flag
);
int32_t
taosSendHttpReport
(
const
char
*
server
,
const
char
*
uri
,
uint16_t
port
,
char
*
pCont
,
int32_t
contLen
,
EHttpCompFlag
flag
);
#ifdef __cplusplus
}
...
...
source/libs/transport/src/thttp.c
浏览文件 @
f294d606
...
...
@@ -26,6 +26,8 @@
#define HTTP_RECV_BUF_SIZE 1024
static
int32_t
httpRefMgt
=
0
;
static
int64_t
httpRef
=
-
1
;
typedef
struct
SHttpModule
{
uv_loop_t
*
loop
;
SAsyncPool
*
asyncPool
;
...
...
@@ -41,7 +43,6 @@ typedef struct SHttpMsg {
int32_t
len
;
EHttpCompFlag
flag
;
int8_t
quit
;
SHttpModule
*
http
;
}
SHttpMsg
;
...
...
@@ -57,7 +58,6 @@ typedef struct SHttpClient {
}
SHttpClient
;
static
TdThreadOnce
transHttpInit
=
PTHREAD_ONCE_INIT
;
static
SHttpModule
*
thttp
=
NULL
;
static
void
transHttpEnvInit
();
static
void
httpHandleReq
(
SHttpMsg
*
msg
);
...
...
@@ -280,26 +280,28 @@ static void clientConnCb(uv_connect_t* req, int32_t status) {
}
int32_t
httpSendQuit
()
{
SHttpModule
*
http
=
taosAcquireRef
(
httpRefMgt
,
httpRef
);
if
(
http
==
NULL
)
return
0
;
SHttpMsg
*
msg
=
taosMemoryCalloc
(
1
,
sizeof
(
SHttpMsg
));
msg
->
quit
=
1
;
SHttpModule
*
load
=
atomic_load_ptr
(
&
thttp
);
if
(
load
==
NULL
)
{
httpDestroyMsg
(
msg
);
tError
(
"http-report already released"
);
return
-
1
;
}
else
{
msg
->
http
=
load
;
}
transAsyncSend
(
load
->
asyncPool
,
&
(
msg
->
q
));
transAsyncSend
(
http
->
asyncPool
,
&
(
msg
->
q
));
taosReleaseRef
(
httpRefMgt
,
httpRef
);
return
0
;
}
static
int32_t
taosSendHttpReportImpl
(
const
char
*
server
,
const
char
*
uri
,
uint16_t
port
,
char
*
pCont
,
int32_t
contLen
,
EHttpCompFlag
flag
)
{
SHttpModule
*
load
=
taosAcquireRef
(
httpRefMgt
,
httpRef
);
if
(
load
==
NULL
)
{
tError
(
"http-report already released"
);
return
-
1
;
}
SHttpMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SHttpMsg
));
msg
->
server
=
strdup
(
server
);
msg
->
uri
=
strdup
(
uri
);
msg
->
uri
=
strdup
(
uri
);
msg
->
port
=
port
;
msg
->
cont
=
taosMemoryMalloc
(
contLen
);
memcpy
(
msg
->
cont
,
pCont
,
contLen
);
...
...
@@ -307,15 +309,9 @@ static int32_t taosSendHttpReportImpl(const char* server, const char* uri, uint1
msg
->
flag
=
flag
;
msg
->
quit
=
0
;
SHttpModule
*
load
=
atomic_load_ptr
(
&
thttp
);
if
(
load
==
NULL
)
{
httpDestroyMsg
(
msg
);
tError
(
"http-report already released"
);
return
-
1
;
}
msg
->
http
=
load
;
return
transAsyncSend
(
load
->
asyncPool
,
&
(
msg
->
q
));
int
ret
=
transAsyncSend
(
load
->
asyncPool
,
&
(
msg
->
q
));
taosReleaseRef
(
httpRefMgt
,
httpRef
);
return
ret
;
}
static
void
httpDestroyClientCb
(
uv_handle_t
*
handle
)
{
...
...
@@ -335,13 +331,19 @@ static void httpWalkCb(uv_handle_t* handle, void* arg) {
return
;
}
static
void
httpHandleQuit
(
SHttpMsg
*
msg
)
{
SHttpModule
*
http
=
msg
->
http
;
taosMemoryFree
(
msg
);
SHttpModule
*
http
=
taosAcquireRef
(
httpRefMgt
,
httpRef
);
if
(
http
==
NULL
)
return
;
uv_walk
(
http
->
loop
,
httpWalkCb
,
NULL
);
taosReleaseRef
(
httpRefMgt
,
httpRef
);
}
static
void
httpHandleReq
(
SHttpMsg
*
msg
)
{
SHttpModule
*
http
=
msg
->
http
;
SHttpModule
*
http
=
taosAcquireRef
(
httpRefMgt
,
httpRef
);
if
(
http
==
NULL
)
{
goto
END
;
}
struct
sockaddr_in
dest
=
{
0
};
if
(
taosBuildDstAddr
(
msg
->
server
,
msg
->
port
,
&
dest
)
<
0
)
{
...
...
@@ -391,6 +393,7 @@ static void httpHandleReq(SHttpMsg* msg) {
int
ret
=
uv_tcp_open
((
uv_tcp_t
*
)
&
cli
->
tcp
,
fd
);
if
(
ret
!=
0
)
{
tError
(
"http-report failed to open socket, reason:%s, dst:%s:%d"
,
uv_strerror
(
ret
),
cli
->
addr
,
cli
->
port
);
taosReleaseRef
(
httpRefMgt
,
httpRef
);
destroyHttpClient
(
cli
);
return
;
}
...
...
@@ -401,21 +404,26 @@ static void httpHandleReq(SHttpMsg* msg) {
cli
->
port
);
destroyHttpClient
(
cli
);
}
taosReleaseRef
(
httpRefMgt
,
httpRef
);
return
;
END:
tError
(
"http-report failed to report, reason: %s, addr: %s:%d"
,
terrstr
(),
msg
->
server
,
msg
->
port
);
httpDestroyMsg
(
msg
);
taosReleaseRef
(
httpRefMgt
,
httpRef
);
}
int32_t
taosSendHttpReport
(
const
char
*
server
,
const
char
*
uri
,
uint16_t
port
,
char
*
pCont
,
int32_t
contLen
,
EHttpCompFlag
flag
)
{
int32_t
taosSendHttpReport
(
const
char
*
server
,
const
char
*
uri
,
uint16_t
port
,
char
*
pCont
,
int32_t
contLen
,
EHttpCompFlag
flag
)
{
taosThreadOnce
(
&
transHttpInit
,
transHttpEnvInit
);
return
taosSendHttpReportImpl
(
server
,
uri
,
port
,
pCont
,
contLen
,
flag
);
}
static
void
transHttpDestroyHandle
(
void
*
handle
)
{
taosMemoryFree
(
handle
);
}
static
void
transHttpEnvInit
()
{
SHttpModule
*
http
=
taosMemoryMalloc
(
sizeof
(
SHttpModule
)
);
httpRefMgt
=
taosOpenRef
(
1
,
transHttpDestroyHandle
);
SHttpModule
*
http
=
taosMemoryMalloc
(
sizeof
(
SHttpModule
));
http
->
loop
=
taosMemoryMalloc
(
sizeof
(
uv_loop_t
));
uv_loop_init
(
http
->
loop
);
...
...
@@ -426,21 +434,22 @@ static void transHttpEnvInit() {
http
=
NULL
;
return
;
}
int
err
=
taosThreadCreate
(
&
http
->
thread
,
NULL
,
httpThread
,
(
void
*
)
http
);
if
(
err
!=
0
)
{
taosMemoryFree
(
http
->
loop
);
taosMemoryFree
(
http
);
http
=
NULL
;
}
atomic_store_ptr
(
&
thttp
,
http
);
httpRef
=
taosAddRef
(
httpRefMgt
,
http
);
}
void
transHttpEnvDestroy
()
{
SHttpModule
*
load
=
atomic_load_ptr
(
&
thttp
);
if
(
load
==
NULL
)
{
// remove http
if
(
httpRef
==
-
1
||
transHttpInit
==
PTHREAD_ONCE_INIT
)
{
return
;
}
SHttpModule
*
load
=
taosAcquireRef
(
httpRefMgt
,
httpRef
);
httpSendQuit
();
taosThreadJoin
(
load
->
thread
,
NULL
);
...
...
@@ -448,7 +457,7 @@ void transHttpEnvDestroy() {
transAsyncPoolDestroy
(
load
->
asyncPool
);
uv_loop_close
(
load
->
loop
);
taosMemoryFree
(
load
->
loop
);
taosMemoryFree
(
load
);
atomic_store_ptr
(
&
thttp
,
NULL
);
taosReleaseRef
(
httpRefMgt
,
httpRef
);
taosRemoveRef
(
httpRefMgt
,
httpRef
);
}
source/libs/transport/src/transCli.c
浏览文件 @
f294d606
...
...
@@ -67,15 +67,13 @@ typedef struct SCliConn {
SCliBatch
*
pBatch
;
int64_t
refId
;
char
*
ip
;
SDelayTask
*
task
;
// debug and log info
char
src
[
32
];
char
dst
[
32
];
char
*
ip
;
char
src
[
32
];
char
dst
[
32
];
int64_t
refId
;
}
SCliConn
;
typedef
struct
SCliMsg
{
...
...
@@ -134,6 +132,7 @@ typedef struct {
int32_t
threshold
;
int64_t
interval
;
}
SFailFastItem
;
// conn pool
// add expire timeout and capacity limit
static
void
*
createConnPool
(
int
size
);
...
...
source/libs/transport/src/transSvr.c
浏览文件 @
f294d606
...
...
@@ -14,6 +14,8 @@
#include "transComm.h"
static
int32_t
httpRefMgt
=
0
;
static
TdThreadOnce
transModuleInit
=
PTHREAD_ONCE_INIT
;
static
char
*
notify
=
"a"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录