Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7c434d61
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
7c434d61
编写于
8月 01, 2020
作者:
F
freemine
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add env FALLBACK, for the sake of easy debug in different mode
上级
93cb6386
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
34 addition
and
20 deletion
+34
-20
src/plugins/http/inc/httpInt.h
src/plugins/http/inc/httpInt.h
+2
-0
src/plugins/http/src/httpContext.c
src/plugins/http/src/httpContext.c
+22
-18
src/plugins/http/src/httpServer.c
src/plugins/http/src/httpServer.c
+4
-2
src/plugins/http/src/httpSystem.c
src/plugins/http/src/httpSystem.c
+6
-0
未找到文件。
src/plugins/http/inc/httpInt.h
浏览文件 @
7c434d61
...
...
@@ -242,6 +242,8 @@ typedef struct HttpServer {
pthread_mutex_t
serverMutex
;
HttpDecodeMethod
*
methodScanner
[
HTTP_METHOD_SCANNER_SIZE
];
bool
(
*
processData
)(
HttpContext
*
pContext
);
int
fallback
:
2
;
}
HttpServer
;
extern
const
char
*
httpKeepAliveStr
[];
...
...
src/plugins/http/src/httpContext.c
浏览文件 @
7c434d61
...
...
@@ -72,6 +72,13 @@ static void httpDestroyContext(void *data) {
httpFreeJsonBuf
(
pContext
);
httpFreeMultiCmds
(
pContext
);
if
(
!
tsHttpServer
.
fallback
)
{
if
(
pContext
->
parser
.
parser
)
{
ehttp_parser_destroy
(
pContext
->
parser
.
parser
);
pContext
->
parser
.
parser
=
NULL
;
}
}
tfree
(
pContext
);
}
...
...
@@ -169,11 +176,6 @@ void httpReleaseContext(HttpContext *pContext) {
httpDebug
(
"context:%p, won't be destroyed for cache is already released"
,
pContext
);
// httpDestroyContext((void **)(&ppContext));
}
if
(
pContext
->
parser
.
parser
)
{
ehttp_parser_destroy
(
pContext
->
parser
.
parser
);
pContext
->
parser
.
parser
=
NULL
;
}
}
bool
httpInitContext
(
HttpContext
*
pContext
)
{
...
...
@@ -193,19 +195,21 @@ bool httpInitContext(HttpContext *pContext) {
memset
(
pParser
,
0
,
sizeof
(
HttpParser
));
pParser
->
pCur
=
pParser
->
pLast
=
pParser
->
buffer
;
ehttp_parser_callbacks_t
callbacks
=
{
on_request_line
,
on_status_line
,
on_header_field
,
on_body
,
on_end
,
on_error
};
ehttp_parser_conf_t
conf
=
{
.
flush_block_size
=
0
};
pParser
->
parser
=
ehttp_parser_create
(
callbacks
,
conf
,
pContext
);
pParser
->
inited
=
1
;
if
(
!
tsHttpServer
.
fallback
)
{
ehttp_parser_callbacks_t
callbacks
=
{
on_request_line
,
on_status_line
,
on_header_field
,
on_body
,
on_end
,
on_error
};
ehttp_parser_conf_t
conf
=
{
.
flush_block_size
=
0
};
pParser
->
parser
=
ehttp_parser_create
(
callbacks
,
conf
,
pContext
);
pParser
->
inited
=
1
;
}
httpDebug
(
"context:%p, fd:%d, ip:%s, thread:%s, accessTimes:%d, parsed:%d"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
pThread
->
label
,
pContext
->
accessTimes
,
pContext
->
parsed
);
...
...
src/plugins/http/src/httpServer.c
浏览文件 @
7c434d61
...
...
@@ -138,7 +138,7 @@ static bool httpDecompressData(HttpContext *pContext) {
}
static
bool
httpReadData
(
HttpContext
*
pContext
)
{
if
(
1
)
return
ehttpReadData
(
pContext
);
if
(
!
tsHttpServer
.
fallback
)
return
ehttpReadData
(
pContext
);
if
(
!
pContext
->
parsed
)
{
httpInitContext
(
pContext
);
...
...
@@ -437,11 +437,13 @@ static bool ehttpReadData(HttpContext *pContext) {
if
(
strstr
(
buf
,
"GET "
)
==
buf
&&
!
strchr
(
buf
,
'\r'
)
&&
!
strchr
(
buf
,
'\n'
))
{
D
(
"==half of request line received:
\n
%s
\n
=="
,
buf
);
}
if
(
ehttp_parser_parse
(
pParser
->
parser
,
buf
,
nread
))
{
D
(
"==parsing failed=="
);
httpCloseContextByServer
(
pContext
);
return
false
;
}
if
(
pContext
->
parser
.
failed
)
{
D
(
"==parsing failed: [0x%x]=="
,
pContext
->
parser
.
failed
);
httpNotifyContextClose
(
pContext
);
...
...
@@ -450,7 +452,7 @@ static bool ehttpReadData(HttpContext *pContext) {
if
(
pContext
->
parsed
)
{
// int ret = httpCheckReadCompleted(pContext);
// already done in ehttp_parser
int
ret
=
HTTP_CHECK_BODY_SUCCESS
;
int
ret
=
HTTP_CHECK_BODY_SUCCESS
;
if
(
ret
==
HTTP_CHECK_BODY_CONTINUE
)
{
//httpDebug("context:%p, fd:%d, ip:%s, not finished yet, wait another event", pContext, pContext->fd, pContext->ipstr);
httpReleaseContext
(
pContext
);
...
...
src/plugins/http/src/httpSystem.c
浏览文件 @
7c434d61
...
...
@@ -39,6 +39,12 @@ HttpServer tsHttpServer;
void
taosInitNote
(
int
numOfNoteLines
,
int
maxNotes
,
char
*
lable
);
int
httpInitSystem
()
{
tsHttpServer
.
fallback
=
0
;
const
char
*
v
=
getenv
(
"FALLBACK"
);
if
(
v
)
{
tsHttpServer
.
fallback
=
1
;
}
strcpy
(
tsHttpServer
.
label
,
"rest"
);
tsHttpServer
.
serverIp
=
0
;
tsHttpServer
.
serverPort
=
tsHttpPort
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录