Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
46304e6b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
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看板
提交
46304e6b
编写于
7月 11, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-825] check http release contexet funciton
上级
46eae6c8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
24 addition
and
25 deletion
+24
-25
src/plugins/http/inc/httpCode.h
src/plugins/http/inc/httpCode.h
+1
-1
src/plugins/http/inc/httpInt.h
src/plugins/http/inc/httpInt.h
+3
-0
src/plugins/http/inc/httpServer.h
src/plugins/http/inc/httpServer.h
+1
-1
src/plugins/http/src/httpHandle.c
src/plugins/http/src/httpHandle.c
+7
-14
src/plugins/http/src/httpServer.c
src/plugins/http/src/httpServer.c
+12
-9
未找到文件。
src/plugins/http/inc/httpCode.h
浏览文件 @
46304e6b
...
...
@@ -105,7 +105,7 @@
#define HTTP_OP_VALUE_TYPE 79
//tgf
#define HTTP_TG_STABLE_NOT_EXIST 80
#define HTTP_TG_STABLE_NOT_EXIST
80
extern
char
*
httpMsg
[];
...
...
src/plugins/http/inc/httpInt.h
浏览文件 @
46304e6b
...
...
@@ -61,6 +61,9 @@
#define HTTP_CHECK_BODY_CONTINUE 0
#define HTTP_CHECK_BODY_SUCCESS 1
#define HTTP_READ_DATA_SUCCESS 0
#define HTTP_READ_DATA_FAILED 1
#define HTTP_WRITE_RETRY_TIMES 500
#define HTTP_WRITE_WAIT_TIME_MS 5
#define HTTP_EXPIRED_TIME 60000
...
...
src/plugins/http/inc/httpServer.h
浏览文件 @
46304e6b
...
...
@@ -23,6 +23,6 @@ void httpCleanUpConnect();
void
*
httpInitServer
(
char
*
ip
,
uint16_t
port
,
char
*
label
,
int
numOfThreads
,
void
*
fp
,
void
*
shandle
);
void
httpCleanUpServer
(
HttpServer
*
pServer
);
bool
httpReadDataImp
(
HttpContext
*
pContext
);
int
httpReadDataImp
(
HttpContext
*
pContext
);
#endif
src/plugins/http/src/httpHandle.c
浏览文件 @
46304e6b
...
...
@@ -60,6 +60,7 @@ bool httpParseURL(HttpContext* pContext) {
char
*
pSeek
;
char
*
pEnd
=
strchr
(
pParser
->
pLast
,
' '
);
if
(
pEnd
==
NULL
)
{
httpSendErrorResp
(
pContext
,
HTTP_UNSUPPORT_URL
);
return
false
;
}
...
...
@@ -275,14 +276,14 @@ bool httpParseChunkedBody(HttpContext* pContext, HttpParser* pParser, bool test)
return
true
;
}
bool
httpReadChunkedBody
(
HttpContext
*
pContext
,
HttpParser
*
pParser
)
{
int
httpReadChunkedBody
(
HttpContext
*
pContext
,
HttpParser
*
pParser
)
{
bool
parsedOk
=
httpParseChunkedBody
(
pContext
,
pParser
,
true
);
if
(
parsedOk
)
{
httpParseChunkedBody
(
pContext
,
pParser
,
false
);
return
HTTP_CHECK_BODY_SUCCESS
;
}
else
{
httpTrace
(
"context:%p, fd:%d, ip:%s, chunked body not finished, continue read"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
);
if
(
!
httpReadDataImp
(
pContext
)
)
{
if
(
httpReadDataImp
(
pContext
)
!=
HTTP_READ_DATA_SUCCESS
)
{
httpError
(
"context:%p, fd:%d, ip:%s, read chunked request error"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
);
return
HTTP_CHECK_BODY_ERROR
;
}
else
{
...
...
@@ -296,7 +297,6 @@ int httpReadUnChunkedBody(HttpContext* pContext, HttpParser* pParser) {
if
(
dataReadLen
>
pParser
->
data
.
len
)
{
httpError
(
"context:%p, fd:%d, ip:%s, un-chunked body length invalid, read size:%d dataReadLen:%d > pContext->data.len:%d"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
parser
.
bufsize
,
dataReadLen
,
pParser
->
data
.
len
);
httpSendErrorResp
(
pContext
,
HTTP_PARSE_BODY_ERROR
);
return
HTTP_CHECK_BODY_ERROR
;
}
else
if
(
dataReadLen
<
pParser
->
data
.
len
)
{
httpTrace
(
"context:%p, fd:%d, ip:%s, un-chunked body not finished, read size:%d dataReadLen:%d < pContext->data.len:%d, continue read"
,
...
...
@@ -358,20 +358,13 @@ bool httpParseRequest(HttpContext* pContext) {
}
int
httpCheckReadCompleted
(
HttpContext
*
pContext
)
{
HttpParser
*
pParser
=
&
pContext
->
parser
;
HttpParser
*
pParser
=
&
pContext
->
parser
;
if
(
pContext
->
httpChunked
==
HTTP_UNCUNKED
)
{
int
ret
=
httpReadUnChunkedBody
(
pContext
,
pParser
);
if
(
ret
!=
HTTP_CHECK_BODY_SUCCESS
)
{
return
ret
;
}
return
httpReadUnChunkedBody
(
pContext
,
pParser
);
}
else
{
int
ret
=
httpReadChunkedBody
(
pContext
,
pParser
);
if
(
ret
!=
HTTP_CHECK_BODY_SUCCESS
)
{
return
ret
;
}
return
httpReadChunkedBody
(
pContext
,
pParser
);
}
return
HTTP_CHECK_BODY_SUCCESS
;
}
bool
httpDecodeRequest
(
HttpContext
*
pContext
)
{
...
...
src/plugins/http/src/httpServer.c
浏览文件 @
46304e6b
...
...
@@ -69,7 +69,7 @@ void httpCleanUpConnect() {
httpDebug
(
"http server:%s is cleaned up"
,
pServer
->
label
);
}
bool
httpReadDataImp
(
HttpContext
*
pContext
)
{
int
httpReadDataImp
(
HttpContext
*
pContext
)
{
HttpParser
*
pParser
=
&
pContext
->
parser
;
while
(
pParser
->
bufsize
<=
(
HTTP_BUFFER_SIZE
-
HTTP_STEP_SIZE
))
{
...
...
@@ -85,8 +85,7 @@ bool httpReadDataImp(HttpContext *pContext) {
}
else
{
httpError
(
"context:%p, fd:%d, ip:%s, read from socket error:%d, close connect"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
errno
);
httpReleaseContext
(
pContext
);
return
false
;
return
HTTP_READ_DATA_FAILED
;
}
}
else
{
pParser
->
bufsize
+=
nread
;
...
...
@@ -95,15 +94,13 @@ bool httpReadDataImp(HttpContext *pContext) {
if
(
pParser
->
bufsize
>=
(
HTTP_BUFFER_SIZE
-
HTTP_STEP_SIZE
))
{
httpError
(
"context:%p, fd:%d, ip:%s, thread:%s, request big than:%d"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
pThread
->
label
,
HTTP_BUFFER_SIZE
);
httpSendErrorResp
(
pContext
,
HTTP_REQUSET_TOO_BIG
);
httpNotifyContextClose
(
pContext
);
return
false
;
return
HTTP_REQUSET_TOO_BIG
;
}
}
pParser
->
buffer
[
pParser
->
bufsize
]
=
0
;
return
true
;
return
HTTP_READ_DATA_SUCCESS
;
}
static
bool
httpDecompressData
(
HttpContext
*
pContext
)
{
...
...
@@ -141,8 +138,14 @@ static bool httpReadData(HttpContext *pContext) {
httpInitContext
(
pContext
);
}
if
(
!
httpReadDataImp
(
pContext
))
{
httpNotifyContextClose
(
pContext
);
int32_t
code
=
httpReadDataImp
(
pContext
);
if
(
code
!=
HTTP_READ_DATA_SUCCESS
)
{
if
(
code
==
HTTP_READ_DATA_FAILED
)
{
httpReleaseContext
(
pContext
);
}
else
{
httpSendErrorResp
(
pContext
,
code
);
httpNotifyContextClose
(
pContext
);
}
return
false
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录