Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
df7d8558
I
iSulad
项目概览
openeuler
/
iSulad
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
iSulad
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
df7d8558
编写于
7月 09, 2020
作者:
O
openeuler-ci-bot
提交者:
Gitee
7月 09, 2020
浏览文件
操作
浏览文件
下载
差异文件
!530 修复websocket限流可能引起卡死
Merge pull request !530 from JingWoo/master
上级
42090f07
56992519
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
5 addition
and
27 deletion
+5
-27
src/websocket/service/ws_server.cc
src/websocket/service/ws_server.cc
+2
-14
src/websocket/service/ws_server.h
src/websocket/service/ws_server.h
+3
-13
未找到文件。
src/websocket/service/ws_server.cc
浏览文件 @
df7d8558
...
...
@@ -288,18 +288,8 @@ int WebsocketServer::Wswrite(struct lws *wsi, void *in, size_t len)
return
0
;
}
void
WebsocketServer
::
Receive
(
struct
lws
*
wsi
,
void
*
user
,
void
*
in
,
size_t
len
)
void
WebsocketServer
::
Receive
(
struct
lws
*
wsi
,
void
*
in
,
size_t
len
)
{
if
(
user
!=
nullptr
)
{
struct
per_session_data__echo
*
pss
=
(
struct
per_session_data__echo
*
)
user
;
pss
->
final
=
lws_is_final_fragment
(
wsi
);
pss
->
binary
=
lws_frame_is_binary
(
wsi
);
(
void
)
memcpy
(
&
pss
->
buf
[
LWS_PRE
],
in
,
len
);
pss
->
len
=
(
unsigned
int
)
len
;
pss
->
rx
+=
len
;
lws_rx_flow_control
(
wsi
,
0
);
}
if
(
m_wsis
.
find
(
wsi
)
==
m_wsis
.
end
())
{
ERROR
(
"invailed websocket session!"
);
return
;
...
...
@@ -353,13 +343,11 @@ int WebsocketServer::Callback(struct lws *wsi, enum lws_callback_reasons reason,
return
-
1
;
}
WebsocketServer
::
GetInstance
()
->
SetLwsSendedFlag
(
wsi
,
true
);
lws_rx_flow_control
(
wsi
,
1
);
}
break
;
case
LWS_CALLBACK_RECEIVE
:
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
m_mutex
);
WebsocketServer
::
GetInstance
()
->
Receive
(
wsi
,
nullptr
,
(
char
*
)
in
,
len
);
lws_rx_flow_control
(
wsi
,
0
);
WebsocketServer
::
GetInstance
()
->
Receive
(
wsi
,
(
char
*
)
in
,
len
);
}
break
;
case
LWS_CALLBACK_CLOSED
:
{
...
...
src/websocket/service/ws_server.h
浏览文件 @
df7d8558
...
...
@@ -27,7 +27,7 @@
#include "url.h"
#include "errors.h"
#define MAX_ECHO_PAYLOAD
1024
#define MAX_ECHO_PAYLOAD
4096
#define MAX_ARRAY_LEN 2
#define MAX_BUF_LEN 256
#define MAX_PROTOCOL_NUM 2
...
...
@@ -37,16 +37,6 @@
#define BUF_BASE_SIZE 1024
#define LWS_TIMEOUT 50
struct
per_session_data__echo
{
size_t
rx
,
tx
;
unsigned
char
buf
[
LWS_PRE
+
MAX_ECHO_PAYLOAD
+
1
];
unsigned
int
len
;
unsigned
int
index
;
int
final
;
int
continuation
;
int
binary
;
};
enum
WebsocketChannel
{
STDINCHANNEL
=
0
,
STDOUTCHANNEL
,
...
...
@@ -95,7 +85,7 @@ private:
std
::
vector
<
std
::
string
>
split
(
std
::
string
str
,
char
r
);
static
void
EmitLog
(
int
level
,
const
char
*
line
);
int
CreateContext
();
inline
void
Receive
(
struct
lws
*
client
,
void
*
user
,
void
*
in
,
size_t
len
);
inline
void
Receive
(
struct
lws
*
client
,
void
*
in
,
size_t
len
);
int
Wswrite
(
struct
lws
*
wsi
,
void
*
in
,
size_t
len
);
inline
int
DumpHandshakeInfo
(
struct
lws
*
wsi
)
noexcept
;
static
int
Callback
(
struct
lws
*
wsi
,
enum
lws_callback_reasons
reason
,
...
...
@@ -110,7 +100,7 @@ private:
volatile
int
m_force_exit
=
0
;
std
::
thread
m_pthread_service
;
const
struct
lws_protocols
m_protocols
[
MAX_PROTOCOL_NUM
]
=
{
{
"channel.k8s.io"
,
Callback
,
sizeof
(
struct
per_session_data__echo
)
,
MAX_ECHO_PAYLOAD
,
},
{
"channel.k8s.io"
,
Callback
,
0
,
MAX_ECHO_PAYLOAD
,
},
{
NULL
,
NULL
,
0
,
0
}
};
RouteCallbackRegister
m_handler
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录