Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
c9e30e68
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c9e30e68
编写于
9月 11, 2017
作者:
S
siyangy
提交者:
Jiangtao Hu
9月 11, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Dreamview: Improve logging of websocket write
上级
b2dd5ff6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
16 deletion
+19
-16
modules/common/time/time.h
modules/common/time/time.h
+11
-11
modules/dreamview/backend/websocket/websocket.cc
modules/dreamview/backend/websocket/websocket.cc
+8
-5
未找到文件。
modules/common/time/time.h
浏览文件 @
c9e30e68
...
...
@@ -259,17 +259,17 @@ inline Clock::Clock()
#define PERF_BLOCK_NO_THRESHOLD(message) PERF_BLOCK_WITH_THRESHOLD(message, 0)
#define PERF_BLOCK_WITH_THRESHOLD(message, threshold)
\
using apollo::common::time::Clock;
\
for (double block_start_time = 0;
\
(block_start_time == 0 ? (block_start_time = Clock::NowInSecond())
\
: false);
\
[
block_start_time]() {
\
double now = Clock::NowInSecond();
\
if (now - block_start_time > (threshold)) {
\
A
DEBUG
<< std::fixed << (message) << ": " << now - block_start_time \
<< "s."; \
}
\
#define PERF_BLOCK_WITH_THRESHOLD(message, threshold) \
using apollo::common::time::Clock; \
for (double block_start_time = 0; \
(block_start_time == 0 ? (block_start_time = Clock::NowInSecond()) \
: false); \
[
&]() {
\
double now = Clock::NowInSecond(); \
if (now - block_start_time > (threshold)) { \
A
INFO
<< std::fixed << (message) << ": " << now - block_start_time \
<< "s."; \
} \
}())
}
// namespace time
}
// namespace common
...
...
modules/dreamview/backend/websocket/websocket.cc
浏览文件 @
c9e30e68
...
...
@@ -19,12 +19,14 @@ limitations under the License.
#include <vector>
#include "modules/common/log.h"
#include "modules/common/util/string_util.h"
#include "modules/common/time/time.h"
#include "modules/common/util/string_util.h"
namespace
apollo
{
namespace
dreamview
{
using
apollo
::
common
::
util
::
StrCat
;
void
WebSocketHandler
::
handleReadyState
(
CivetServer
*
server
,
Connection
*
conn
)
{
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex_
);
...
...
@@ -104,9 +106,10 @@ bool WebSocketHandler::SendData(const std::string &data, Connection *conn,
// Note that while we are holding the connection lock, the connection won't be
// closed and removed.
int
ret
;
PERF_BLOCK
(
"Websocket write took too long"
,
0.5
)
{
PERF_BLOCK
(
StrCat
(
"Writing "
,
data
.
size
(),
" bytes via websocket took"
),
0.1
)
{
ret
=
mg_websocket_write
(
conn
,
WEBSOCKET_OPCODE_TEXT
,
data
.
c_str
(),
data
.
size
());
data
.
size
());
}
connection_lock
->
unlock
();
...
...
@@ -118,8 +121,8 @@ bool WebSocketHandler::SendData(const std::string &data, Connection *conn,
}
else
if
(
ret
<
0
)
{
msg
=
"Send Error"
;
}
else
{
msg
=
apollo
::
common
::
util
::
StrCat
(
"Expect to send "
,
data
.
size
()
,
" bytes. But sent "
,
ret
,
" bytes"
);
msg
=
StrCat
(
"Expect to send "
,
data
.
size
(),
" bytes. But sent "
,
ret
,
" bytes"
);
}
AWARN
<<
"Failed to send data via websocket connection. Reason: "
<<
msg
;
return
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录