Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
fe8e84a6
Unverified
提交
fe8e84a6
authored
2月 01, 2023
作者:
José Luis Millán
提交者:
GitHub
2月 01, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Worker: const correctness (#1002)
上级
8c2ba441
隐藏空白字符变更
内嵌
并排
正在显示
23 个修改的文件
包含
51 行增加
和
51 行删除
+51
-51
DepLibSRTP.cpp
worker/src/DepLibSRTP.cpp
+1
-1
DepLibUV.cpp
worker/src/DepLibUV.cpp
+2
-2
DepUsrSCTP.cpp
worker/src/DepUsrSCTP.cpp
+2
-2
H264.cpp
worker/src/RTC/Codecs/H264.cpp
+5
-5
H264_SVC.cpp
worker/src/RTC/Codecs/H264_SVC.cpp
+4
-4
VP9.cpp
worker/src/RTC/Codecs/VP9.cpp
+1
-1
Bye.cpp
worker/src/RTC/RTCP/Bye.cpp
+1
-1
FeedbackPsRpsi.cpp
worker/src/RTC/RTCP/FeedbackPsRpsi.cpp
+2
-2
FeedbackPsSli.cpp
worker/src/RTC/RTCP/FeedbackPsSli.cpp
+2
-2
FeedbackPsVbcm.cpp
worker/src/RTC/RTCP/FeedbackPsVbcm.cpp
+2
-2
FeedbackRtpTmmb.cpp
worker/src/RTC/RTCP/FeedbackRtpTmmb.cpp
+3
-3
FeedbackRtpTransport.cpp
worker/src/RTC/RTCP/FeedbackRtpTransport.cpp
+3
-3
Packet.cpp
worker/src/RTC/RTCP/Packet.cpp
+1
-1
ReceiverReport.cpp
worker/src/RTC/RTCP/ReceiverReport.cpp
+1
-1
Sdes.cpp
worker/src/RTC/RTCP/Sdes.cpp
+2
-2
SenderReport.cpp
worker/src/RTC/RTCP/SenderReport.cpp
+1
-1
XR.cpp
worker/src/RTC/RTCP/XR.cpp
+1
-1
XrDelaySinceLastRr.cpp
worker/src/RTC/RTCP/XrDelaySinceLastRr.cpp
+1
-1
TcpConnectionHandler.cpp
worker/src/handles/TcpConnectionHandler.cpp
+5
-5
TcpServerHandler.cpp
worker/src/handles/TcpServerHandler.cpp
+1
-1
Timer.cpp
worker/src/handles/Timer.cpp
+5
-5
UdpSocketHandler.cpp
worker/src/handles/UdpSocketHandler.cpp
+2
-2
UnixStreamSocket.cpp
worker/src/handles/UnixStreamSocket.cpp
+3
-3
没有找到文件。
worker/src/DepLibSRTP.cpp
浏览文件 @
fe8e84a6
...
@@ -56,7 +56,7 @@ void DepLibSRTP::ClassInit()
...
@@ -56,7 +56,7 @@ void DepLibSRTP::ClassInit()
{
{
MS_DEBUG_TAG
(
info
,
"libsrtp version:
\"
%s
\"
"
,
srtp_get_version_string
());
MS_DEBUG_TAG
(
info
,
"libsrtp version:
\"
%s
\"
"
,
srtp_get_version_string
());
srtp_err_status_t
err
=
srtp_init
();
const
srtp_err_status_t
err
=
srtp_init
();
if
(
DepLibSRTP
::
IsError
(
err
))
if
(
DepLibSRTP
::
IsError
(
err
))
MS_THROW_ERROR
(
"srtp_init() failed: %s"
,
DepLibSRTP
::
GetErrorString
(
err
));
MS_THROW_ERROR
(
"srtp_init() failed: %s"
,
DepLibSRTP
::
GetErrorString
(
err
));
...
...
worker/src/DepLibUV.cpp
浏览文件 @
fe8e84a6
...
@@ -38,7 +38,7 @@ void DepLibUV::ClassInit()
...
@@ -38,7 +38,7 @@ void DepLibUV::ClassInit()
DepLibUV
::
loop
=
new
uv_loop_t
;
DepLibUV
::
loop
=
new
uv_loop_t
;
int
err
=
uv_loop_init
(
DepLibUV
::
loop
);
const
int
err
=
uv_loop_init
(
DepLibUV
::
loop
);
if
(
err
!=
0
)
if
(
err
!=
0
)
MS_ABORT
(
"libuv loop initialization failed"
);
MS_ABORT
(
"libuv loop initialization failed"
);
...
@@ -88,7 +88,7 @@ void DepLibUV::RunLoop()
...
@@ -88,7 +88,7 @@ void DepLibUV::RunLoop()
// This should never happen.
// This should never happen.
MS_ASSERT
(
DepLibUV
::
loop
!=
nullptr
,
"loop unset"
);
MS_ASSERT
(
DepLibUV
::
loop
!=
nullptr
,
"loop unset"
);
int
ret
=
uv_run
(
DepLibUV
::
loop
,
UV_RUN_DEFAULT
);
const
int
ret
=
uv_run
(
DepLibUV
::
loop
,
UV_RUN_DEFAULT
);
MS_ASSERT
(
ret
==
0
,
"uv_run() returned %s"
,
uv_err_name
(
ret
));
MS_ASSERT
(
ret
==
0
,
"uv_run() returned %s"
,
uv_err_name
(
ret
));
}
}
worker/src/DepUsrSCTP.cpp
浏览文件 @
fe8e84a6
...
@@ -236,8 +236,8 @@ void DepUsrSCTP::Checker::OnTimer(Timer* /*timer*/)
...
@@ -236,8 +236,8 @@ void DepUsrSCTP::Checker::OnTimer(Timer* /*timer*/)
{
{
MS_TRACE
();
MS_TRACE
();
auto
nowMs
=
DepLibUV
::
GetTimeMs
();
auto
nowMs
=
DepLibUV
::
GetTimeMs
();
int
elapsedMs
=
this
->
lastCalledAtMs
?
static_cast
<
int
>
(
nowMs
-
this
->
lastCalledAtMs
)
:
0
;
const
int
elapsedMs
=
this
->
lastCalledAtMs
?
static_cast
<
int
>
(
nowMs
-
this
->
lastCalledAtMs
)
:
0
;
usrsctp_handle_timers
(
elapsedMs
);
usrsctp_handle_timers
(
elapsedMs
);
...
...
worker/src/RTC/Codecs/H264.cpp
浏览文件 @
fe8e84a6
...
@@ -63,7 +63,7 @@ namespace RTC
...
@@ -63,7 +63,7 @@ namespace RTC
// there is no frame-marking or if there is but keyframe was not detected above.
// there is no frame-marking or if there is but keyframe was not detected above.
if
(
!
frameMarking
||
!
payloadDescriptor
->
isKeyFrame
)
if
(
!
frameMarking
||
!
payloadDescriptor
->
isKeyFrame
)
{
{
uint8_t
nal
=
*
data
&
0x1F
;
const
uint8_t
nal
=
*
data
&
0x1F
;
switch
(
nal
)
switch
(
nal
)
{
{
...
@@ -87,8 +87,8 @@ namespace RTC
...
@@ -87,8 +87,8 @@ namespace RTC
// Iterate NAL units.
// Iterate NAL units.
while
(
len
>=
3
)
while
(
len
>=
3
)
{
{
auto
naluSize
=
Utils
::
Byte
::
Get2Bytes
(
data
,
offset
);
auto
naluSize
=
Utils
::
Byte
::
Get2Bytes
(
data
,
offset
);
uint8_t
subnal
=
*
(
data
+
offset
+
sizeof
(
naluSize
))
&
0x1F
;
const
uint8_t
subnal
=
*
(
data
+
offset
+
sizeof
(
naluSize
))
&
0x1F
;
if
(
subnal
==
7
)
if
(
subnal
==
7
)
{
{
...
@@ -115,8 +115,8 @@ namespace RTC
...
@@ -115,8 +115,8 @@ namespace RTC
case
28
:
case
28
:
case
29
:
case
29
:
{
{
uint8_t
subnal
=
*
(
data
+
1
)
&
0x1F
;
const
uint8_t
subnal
=
*
(
data
+
1
)
&
0x1F
;
uint8_t
startBit
=
*
(
data
+
1
)
&
0x80
;
const
uint8_t
startBit
=
*
(
data
+
1
)
&
0x80
;
if
(
subnal
==
7
&&
startBit
==
128
)
if
(
subnal
==
7
&&
startBit
==
128
)
{
{
...
...
worker/src/RTC/Codecs/H264_SVC.cpp
浏览文件 @
fe8e84a6
...
@@ -58,7 +58,7 @@ namespace RTC
...
@@ -58,7 +58,7 @@ namespace RTC
// there is no frame-marking or if there is but keyframe was not detected above.
// there is no frame-marking or if there is but keyframe was not detected above.
if
(
!
frameMarking
||
!
payloadDescriptor
->
isKeyFrame
)
if
(
!
frameMarking
||
!
payloadDescriptor
->
isKeyFrame
)
{
{
uint8_t
nal
=
*
data
&
0x1F
;
const
uint8_t
nal
=
*
data
&
0x1F
;
switch
(
nal
)
switch
(
nal
)
{
{
...
@@ -121,7 +121,7 @@ namespace RTC
...
@@ -121,7 +121,7 @@ namespace RTC
case
28
:
case
28
:
case
29
:
case
29
:
{
{
uint8_t
startBit
=
*
(
data
+
1
)
&
0x80
;
const
uint8_t
startBit
=
*
(
data
+
1
)
&
0x80
;
if
(
startBit
==
128
)
if
(
startBit
==
128
)
{
{
...
@@ -145,7 +145,7 @@ namespace RTC
...
@@ -145,7 +145,7 @@ namespace RTC
std
::
unique_ptr
<
H264_SVC
::
PayloadDescriptor
>
payloadDescriptor
,
std
::
unique_ptr
<
H264_SVC
::
PayloadDescriptor
>
payloadDescriptor
,
bool
isStartBit
)
bool
isStartBit
)
{
{
uint8_t
nal
=
*
data
&
0x1F
;
const
uint8_t
nal
=
*
data
&
0x1F
;
switch
(
nal
)
switch
(
nal
)
{
{
...
@@ -286,7 +286,7 @@ namespace RTC
...
@@ -286,7 +286,7 @@ namespace RTC
}
}
// clang-format off
// clang-format off
bool
isOldPacket
=
false
;
const
bool
isOldPacket
=
false
;
// Upgrade current spatial layer if needed.
// Upgrade current spatial layer if needed.
if
(
context
->
GetTargetSpatialLayer
()
>
context
->
GetCurrentSpatialLayer
())
if
(
context
->
GetTargetSpatialLayer
()
>
context
->
GetCurrentSpatialLayer
())
...
...
worker/src/RTC/Codecs/VP9.cpp
浏览文件 @
fe8e84a6
...
@@ -223,7 +223,7 @@ namespace RTC
...
@@ -223,7 +223,7 @@ namespace RTC
}
}
// clang-format off
// clang-format off
bool
isOldPacket
=
(
const
bool
isOldPacket
=
(
this
->
payloadDescriptor
->
hasPictureId
&&
this
->
payloadDescriptor
->
hasPictureId
&&
RTC
::
SeqManager
<
uint16_t
,
15
>::
IsSeqLowerThan
(
RTC
::
SeqManager
<
uint16_t
,
15
>::
IsSeqLowerThan
(
this
->
payloadDescriptor
->
pictureId
,
this
->
payloadDescriptor
->
pictureId
,
...
...
worker/src/RTC/RTCP/Bye.cpp
浏览文件 @
fe8e84a6
...
@@ -75,7 +75,7 @@ namespace RTC
...
@@ -75,7 +75,7 @@ namespace RTC
}
}
// 32 bits padding.
// 32 bits padding.
size_t
padding
=
(
-
offset
)
&
3
;
const
size_t
padding
=
(
-
offset
)
&
3
;
for
(
size_t
i
{
0
};
i
<
padding
;
++
i
)
for
(
size_t
i
{
0
};
i
<
padding
;
++
i
)
{
{
...
...
worker/src/RTC/RTCP/FeedbackPsRpsi.cpp
浏览文件 @
fe8e84a6
...
@@ -25,7 +25,7 @@ namespace RTC
...
@@ -25,7 +25,7 @@ namespace RTC
isCorrect
=
false
;
isCorrect
=
false
;
}
}
size_t
paddingBytes
=
this
->
header
->
paddingBits
/
8
;
const
size_t
paddingBytes
=
this
->
header
->
paddingBits
/
8
;
if
(
paddingBytes
>
FeedbackPsRpsiItem
::
maxBitStringSize
)
if
(
paddingBytes
>
FeedbackPsRpsiItem
::
maxBitStringSize
)
{
{
...
@@ -50,7 +50,7 @@ namespace RTC
...
@@ -50,7 +50,7 @@ namespace RTC
this
->
header
=
reinterpret_cast
<
Header
*>
(
this
->
raw
);
this
->
header
=
reinterpret_cast
<
Header
*>
(
this
->
raw
);
// 32 bits padding.
// 32 bits padding.
size_t
padding
=
(
-
length
)
&
3
;
const
size_t
padding
=
(
-
length
)
&
3
;
this
->
header
->
paddingBits
=
padding
*
8
;
this
->
header
->
paddingBits
=
padding
*
8
;
this
->
header
->
zero
=
0
;
this
->
header
->
zero
=
0
;
...
...
worker/src/RTC/RTCP/FeedbackPsSli.cpp
浏览文件 @
fe8e84a6
...
@@ -26,8 +26,8 @@ namespace RTC
...
@@ -26,8 +26,8 @@ namespace RTC
size_t
FeedbackPsSliItem
::
Serialize
(
uint8_t
*
buffer
)
size_t
FeedbackPsSliItem
::
Serialize
(
uint8_t
*
buffer
)
{
{
uint32_t
compact
=
(
this
->
first
<<
19
)
|
(
this
->
number
<<
6
)
|
this
->
pictureId
;
const
uint32_t
compact
=
(
this
->
first
<<
19
)
|
(
this
->
number
<<
6
)
|
this
->
pictureId
;
auto
*
header
=
reinterpret_cast
<
Header
*>
(
buffer
);
auto
*
header
=
reinterpret_cast
<
Header
*>
(
buffer
);
header
->
compact
=
uint32_t
{
htonl
(
compact
)
};
header
->
compact
=
uint32_t
{
htonl
(
compact
)
};
std
::
memcpy
(
buffer
,
header
,
HeaderSize
);
std
::
memcpy
(
buffer
,
header
,
HeaderSize
);
...
...
worker/src/RTC/RTCP/FeedbackPsVbcm.cpp
浏览文件 @
fe8e84a6
...
@@ -34,9 +34,9 @@ namespace RTC
...
@@ -34,9 +34,9 @@ namespace RTC
// Copy the content.
// Copy the content.
std
::
memcpy
(
buffer
+
8
,
this
->
header
->
value
,
GetLength
());
std
::
memcpy
(
buffer
+
8
,
this
->
header
->
value
,
GetLength
());
size_t
offset
=
8
+
GetLength
();
const
size_t
offset
=
8
+
GetLength
();
// 32 bits padding.
// 32 bits padding.
size_t
padding
=
(
-
offset
)
&
3
;
const
size_t
padding
=
(
-
offset
)
&
3
;
for
(
size_t
i
{
0
};
i
<
padding
;
++
i
)
for
(
size_t
i
{
0
};
i
<
padding
;
++
i
)
{
{
...
...
worker/src/RTC/RTCP/FeedbackRtpTmmb.cpp
浏览文件 @
fe8e84a6
...
@@ -23,10 +23,10 @@ namespace RTC
...
@@ -23,10 +23,10 @@ namespace RTC
this
->
ssrc
=
Utils
::
Byte
::
Get4Bytes
(
data
,
0
);
this
->
ssrc
=
Utils
::
Byte
::
Get4Bytes
(
data
,
0
);
// Read the 4 bytes block.
// Read the 4 bytes block.
uint32_t
compact
=
Utils
::
Byte
::
Get4Bytes
(
data
,
4
);
const
uint32_t
compact
=
Utils
::
Byte
::
Get4Bytes
(
data
,
4
);
// Read each component.
// Read each component.
uint8_t
exponent
=
compact
>>
26
;
// 6 bits.
const
uint8_t
exponent
=
compact
>>
26
;
// 6 bits.
uint64_t
mantissa
=
(
compact
>>
9
)
&
0x1ffff
;
// 17 bits.
const
uint64_t
mantissa
=
(
compact
>>
9
)
&
0x1ffff
;
// 17 bits.
this
->
overhead
=
compact
&
0x1ff
;
// 9 bits.
this
->
overhead
=
compact
&
0x1ff
;
// 9 bits.
// Get the bitrate out of exponent and mantissa.
// Get the bitrate out of exponent and mantissa.
...
...
worker/src/RTC/RTCP/FeedbackRtpTransport.cpp
浏览文件 @
fe8e84a6
...
@@ -265,7 +265,7 @@ namespace RTC
...
@@ -265,7 +265,7 @@ namespace RTC
}
}
// 32 bits padding.
// 32 bits padding.
size_t
padding
=
(
-
offset
)
&
3
;
const
size_t
padding
=
(
-
offset
)
&
3
;
for
(
size_t
i
{
0u
};
i
<
padding
;
++
i
)
for
(
size_t
i
{
0u
};
i
<
padding
;
++
i
)
{
{
...
@@ -318,7 +318,7 @@ namespace RTC
...
@@ -318,7 +318,7 @@ namespace RTC
// Deltas are represented as multiples of 250 us.
// Deltas are represented as multiples of 250 us.
// NOTE: Read it as int 64 to detect long elapsed times.
// NOTE: Read it as int 64 to detect long elapsed times.
int64_t
delta64
=
(
timestamp
-
this
->
latestTimestamp
)
*
4
;
const
int64_t
delta64
=
(
timestamp
-
this
->
latestTimestamp
)
*
4
;
// clang-format off
// clang-format off
if
(
if
(
...
@@ -414,7 +414,7 @@ namespace RTC
...
@@ -414,7 +414,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
uint16_t
expected
=
this
->
packetStatusCount
;
const
uint16_t
expected
=
this
->
packetStatusCount
;
uint16_t
lost
{
0u
};
uint16_t
lost
{
0u
};
if
(
expected
==
0u
)
if
(
expected
==
0u
)
...
...
worker/src/RTC/RTCP/Packet.cpp
浏览文件 @
fe8e84a6
...
@@ -204,7 +204,7 @@ namespace RTC
...
@@ -204,7 +204,7 @@ namespace RTC
this
->
header
=
reinterpret_cast
<
CommonHeader
*>
(
buffer
);
this
->
header
=
reinterpret_cast
<
CommonHeader
*>
(
buffer
);
size_t
length
=
(
GetSize
()
/
4
)
-
1
;
const
size_t
length
=
(
GetSize
()
/
4
)
-
1
;
// Fill the common header.
// Fill the common header.
this
->
header
->
version
=
2
;
this
->
header
->
version
=
2
;
...
...
worker/src/RTC/RTCP/ReceiverReport.cpp
浏览文件 @
fe8e84a6
...
@@ -86,7 +86,7 @@ namespace RTC
...
@@ -86,7 +86,7 @@ namespace RTC
std
::
unique_ptr
<
ReceiverReportPacket
>
packet
(
new
ReceiverReportPacket
(
header
));
std
::
unique_ptr
<
ReceiverReportPacket
>
packet
(
new
ReceiverReportPacket
(
header
));
uint32_t
ssrc
=
const
uint32_t
ssrc
=
Utils
::
Byte
::
Get4Bytes
(
reinterpret_cast
<
uint8_t
*>
(
header
),
Packet
::
CommonHeaderSize
);
Utils
::
Byte
::
Get4Bytes
(
reinterpret_cast
<
uint8_t
*>
(
header
),
Packet
::
CommonHeaderSize
);
packet
->
SetSsrc
(
ssrc
);
packet
->
SetSsrc
(
ssrc
);
...
...
worker/src/RTC/RTCP/Sdes.cpp
浏览文件 @
fe8e84a6
...
@@ -119,7 +119,7 @@ namespace RTC
...
@@ -119,7 +119,7 @@ namespace RTC
return
nullptr
;
return
nullptr
;
}
}
uint32_t
ssrc
=
Utils
::
Byte
::
Get4Bytes
(
data
,
0
);
const
uint32_t
ssrc
=
Utils
::
Byte
::
Get4Bytes
(
data
,
0
);
std
::
unique_ptr
<
SdesChunk
>
chunk
(
new
SdesChunk
(
ssrc
));
std
::
unique_ptr
<
SdesChunk
>
chunk
(
new
SdesChunk
(
ssrc
));
...
@@ -156,7 +156,7 @@ namespace RTC
...
@@ -156,7 +156,7 @@ namespace RTC
}
}
// 32 bits padding.
// 32 bits padding.
size_t
padding
=
(
-
offset
)
&
3
;
const
size_t
padding
=
(
-
offset
)
&
3
;
for
(
size_t
i
{
0
};
i
<
padding
;
++
i
)
for
(
size_t
i
{
0
};
i
<
padding
;
++
i
)
{
{
...
...
worker/src/RTC/RTCP/SenderReport.cpp
浏览文件 @
fe8e84a6
...
@@ -65,7 +65,7 @@ namespace RTC
...
@@ -65,7 +65,7 @@ namespace RTC
auto
*
header
=
const_cast
<
CommonHeader
*>
(
reinterpret_cast
<
const
CommonHeader
*>
(
data
));
auto
*
header
=
const_cast
<
CommonHeader
*>
(
reinterpret_cast
<
const
CommonHeader
*>
(
data
));
std
::
unique_ptr
<
SenderReportPacket
>
packet
(
new
SenderReportPacket
(
header
));
std
::
unique_ptr
<
SenderReportPacket
>
packet
(
new
SenderReportPacket
(
header
));
size_t
offset
=
Packet
::
CommonHeaderSize
;
const
size_t
offset
=
Packet
::
CommonHeaderSize
;
SenderReport
*
report
=
SenderReport
::
Parse
(
data
+
offset
,
len
-
offset
);
SenderReport
*
report
=
SenderReport
::
Parse
(
data
+
offset
,
len
-
offset
);
...
...
worker/src/RTC/RTCP/XR.cpp
浏览文件 @
fe8e84a6
...
@@ -71,7 +71,7 @@ namespace RTC
...
@@ -71,7 +71,7 @@ namespace RTC
std
::
unique_ptr
<
ExtendedReportPacket
>
packet
(
new
ExtendedReportPacket
(
header
));
std
::
unique_ptr
<
ExtendedReportPacket
>
packet
(
new
ExtendedReportPacket
(
header
));
uint32_t
ssrc
=
const
uint32_t
ssrc
=
Utils
::
Byte
::
Get4Bytes
(
reinterpret_cast
<
uint8_t
*>
(
header
),
Packet
::
CommonHeaderSize
);
Utils
::
Byte
::
Get4Bytes
(
reinterpret_cast
<
uint8_t
*>
(
header
),
Packet
::
CommonHeaderSize
);
packet
->
SetSsrc
(
ssrc
);
packet
->
SetSsrc
(
ssrc
);
...
...
worker/src/RTC/RTCP/XrDelaySinceLastRr.cpp
浏览文件 @
fe8e84a6
...
@@ -94,7 +94,7 @@ namespace RTC
...
@@ -94,7 +94,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
size_t
length
=
static_cast
<
uint16_t
>
((
SsrcInfo
::
BodySize
*
this
->
ssrcInfos
.
size
()
/
4
));
const
size_t
length
=
static_cast
<
uint16_t
>
((
SsrcInfo
::
BodySize
*
this
->
ssrcInfos
.
size
()
/
4
));
// Fill the common header.
// Fill the common header.
this
->
header
->
blockType
=
static_cast
<
uint8_t
>
(
this
->
type
);
this
->
header
->
blockType
=
static_cast
<
uint8_t
>
(
this
->
type
);
...
...
worker/src/handles/TcpConnectionHandler.cpp
浏览文件 @
fe8e84a6
...
@@ -135,7 +135,7 @@ void TcpConnectionHandler::Setup(
...
@@ -135,7 +135,7 @@ void TcpConnectionHandler::Setup(
MS_TRACE
();
MS_TRACE
();
// Set the UV handle.
// Set the UV handle.
int
err
=
uv_tcp_init
(
DepLibUV
::
GetLoop
(),
this
->
uvHandle
);
const
int
err
=
uv_tcp_init
(
DepLibUV
::
GetLoop
(),
this
->
uvHandle
);
if
(
err
!=
0
)
if
(
err
!=
0
)
{
{
...
@@ -205,7 +205,7 @@ void TcpConnectionHandler::Write(
...
@@ -205,7 +205,7 @@ void TcpConnectionHandler::Write(
return
;
return
;
}
}
size_t
totalLen
=
len1
+
len2
;
const
size_t
totalLen
=
len1
+
len2
;
uv_buf_t
buffers
[
2
];
uv_buf_t
buffers
[
2
];
int
written
{
0
};
int
written
{
0
};
int
err
;
int
err
;
...
@@ -246,8 +246,8 @@ void TcpConnectionHandler::Write(
...
@@ -246,8 +246,8 @@ void TcpConnectionHandler::Write(
written
=
0
;
written
=
0
;
}
}
size_t
pendingLen
=
totalLen
-
written
;
const
size_t
pendingLen
=
totalLen
-
written
;
auto
*
writeData
=
new
UvWriteData
(
pendingLen
);
auto
*
writeData
=
new
UvWriteData
(
pendingLen
);
writeData
->
req
.
data
=
static_cast
<
void
*>
(
writeData
);
writeData
->
req
.
data
=
static_cast
<
void
*>
(
writeData
);
...
@@ -269,7 +269,7 @@ void TcpConnectionHandler::Write(
...
@@ -269,7 +269,7 @@ void TcpConnectionHandler::Write(
writeData
->
cb
=
cb
;
writeData
->
cb
=
cb
;
uv_buf_t
buffer
=
uv_buf_init
(
reinterpret_cast
<
char
*>
(
writeData
->
store
),
pendingLen
);
const
uv_buf_t
buffer
=
uv_buf_init
(
reinterpret_cast
<
char
*>
(
writeData
->
store
),
pendingLen
);
err
=
uv_write
(
err
=
uv_write
(
&
writeData
->
req
,
&
writeData
->
req
,
...
...
worker/src/handles/TcpServerHandler.cpp
浏览文件 @
fe8e84a6
...
@@ -117,7 +117,7 @@ void TcpServerHandler::AcceptTcpConnection(TcpConnectionHandler* connection)
...
@@ -117,7 +117,7 @@ void TcpServerHandler::AcceptTcpConnection(TcpConnectionHandler* connection)
}
}
// Accept the connection.
// Accept the connection.
int
err
=
uv_accept
(
const
int
err
=
uv_accept
(
reinterpret_cast
<
uv_stream_t
*>
(
this
->
uvHandle
),
reinterpret_cast
<
uv_stream_t
*>
(
this
->
uvHandle
),
reinterpret_cast
<
uv_stream_t
*>
(
connection
->
GetUvHandle
()));
reinterpret_cast
<
uv_stream_t
*>
(
connection
->
GetUvHandle
()));
...
...
worker/src/handles/Timer.cpp
浏览文件 @
fe8e84a6
...
@@ -27,7 +27,7 @@ Timer::Timer(Listener* listener) : listener(listener)
...
@@ -27,7 +27,7 @@ Timer::Timer(Listener* listener) : listener(listener)
this
->
uvHandle
=
new
uv_timer_t
;
this
->
uvHandle
=
new
uv_timer_t
;
this
->
uvHandle
->
data
=
static_cast
<
void
*>
(
this
);
this
->
uvHandle
->
data
=
static_cast
<
void
*>
(
this
);
int
err
=
uv_timer_init
(
DepLibUV
::
GetLoop
(),
this
->
uvHandle
);
const
int
err
=
uv_timer_init
(
DepLibUV
::
GetLoop
(),
this
->
uvHandle
);
if
(
err
!=
0
)
if
(
err
!=
0
)
{
{
...
@@ -71,7 +71,7 @@ void Timer::Start(uint64_t timeout, uint64_t repeat)
...
@@ -71,7 +71,7 @@ void Timer::Start(uint64_t timeout, uint64_t repeat)
if
(
uv_is_active
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
))
!=
0
)
if
(
uv_is_active
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
))
!=
0
)
Stop
();
Stop
();
int
err
=
uv_timer_start
(
this
->
uvHandle
,
static_cast
<
uv_timer_cb
>
(
onTimer
),
timeout
,
repeat
);
const
int
err
=
uv_timer_start
(
this
->
uvHandle
,
static_cast
<
uv_timer_cb
>
(
onTimer
),
timeout
,
repeat
);
if
(
err
!=
0
)
if
(
err
!=
0
)
MS_THROW_ERROR
(
"uv_timer_start() failed: %s"
,
uv_strerror
(
err
));
MS_THROW_ERROR
(
"uv_timer_start() failed: %s"
,
uv_strerror
(
err
));
...
@@ -84,7 +84,7 @@ void Timer::Stop()
...
@@ -84,7 +84,7 @@ void Timer::Stop()
if
(
this
->
closed
)
if
(
this
->
closed
)
MS_THROW_ERROR
(
"closed"
);
MS_THROW_ERROR
(
"closed"
);
int
err
=
uv_timer_stop
(
this
->
uvHandle
);
const
int
err
=
uv_timer_stop
(
this
->
uvHandle
);
if
(
err
!=
0
)
if
(
err
!=
0
)
MS_THROW_ERROR
(
"uv_timer_stop() failed: %s"
,
uv_strerror
(
err
));
MS_THROW_ERROR
(
"uv_timer_stop() failed: %s"
,
uv_strerror
(
err
));
...
@@ -103,7 +103,7 @@ void Timer::Reset()
...
@@ -103,7 +103,7 @@ void Timer::Reset()
if
(
this
->
repeat
==
0u
)
if
(
this
->
repeat
==
0u
)
return
;
return
;
int
err
=
const
int
err
=
uv_timer_start
(
this
->
uvHandle
,
static_cast
<
uv_timer_cb
>
(
onTimer
),
this
->
repeat
,
this
->
repeat
);
uv_timer_start
(
this
->
uvHandle
,
static_cast
<
uv_timer_cb
>
(
onTimer
),
this
->
repeat
,
this
->
repeat
);
if
(
err
!=
0
)
if
(
err
!=
0
)
...
@@ -120,7 +120,7 @@ void Timer::Restart()
...
@@ -120,7 +120,7 @@ void Timer::Restart()
if
(
uv_is_active
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
))
!=
0
)
if
(
uv_is_active
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
))
!=
0
)
Stop
();
Stop
();
int
err
=
const
int
err
=
uv_timer_start
(
this
->
uvHandle
,
static_cast
<
uv_timer_cb
>
(
onTimer
),
this
->
timeout
,
this
->
repeat
);
uv_timer_start
(
this
->
uvHandle
,
static_cast
<
uv_timer_cb
>
(
onTimer
),
this
->
timeout
,
this
->
repeat
);
if
(
err
!=
0
)
if
(
err
!=
0
)
...
...
worker/src/handles/UdpSocketHandler.cpp
浏览文件 @
fe8e84a6
...
@@ -101,7 +101,7 @@ void UdpSocketHandler::Close()
...
@@ -101,7 +101,7 @@ void UdpSocketHandler::Close()
this
->
uvHandle
->
data
=
nullptr
;
this
->
uvHandle
->
data
=
nullptr
;
// Don't read more.
// Don't read more.
int
err
=
uv_udp_recv_stop
(
this
->
uvHandle
);
const
int
err
=
uv_udp_recv_stop
(
this
->
uvHandle
);
if
(
err
!=
0
)
if
(
err
!=
0
)
MS_ABORT
(
"uv_udp_recv_stop() failed: %s"
,
uv_strerror
(
err
));
MS_ABORT
(
"uv_udp_recv_stop() failed: %s"
,
uv_strerror
(
err
));
...
@@ -149,7 +149,7 @@ void UdpSocketHandler::Send(
...
@@ -149,7 +149,7 @@ void UdpSocketHandler::Send(
// then build a uv_req_t and use uv_udp_send().
// then build a uv_req_t and use uv_udp_send().
uv_buf_t
buffer
=
uv_buf_init
(
reinterpret_cast
<
char
*>
(
const_cast
<
uint8_t
*>
(
data
)),
len
);
uv_buf_t
buffer
=
uv_buf_init
(
reinterpret_cast
<
char
*>
(
const_cast
<
uint8_t
*>
(
data
)),
len
);
int
sent
=
uv_udp_try_send
(
this
->
uvHandle
,
&
buffer
,
1
,
addr
);
const
int
sent
=
uv_udp_try_send
(
this
->
uvHandle
,
&
buffer
,
1
,
addr
);
// Entire datagram was sent. Done.
// Entire datagram was sent. Done.
if
(
sent
==
static_cast
<
int
>
(
len
))
if
(
sent
==
static_cast
<
int
>
(
len
))
...
...
worker/src/handles/UnixStreamSocket.cpp
浏览文件 @
fe8e84a6
...
@@ -197,15 +197,15 @@ void UnixStreamSocket::Write(const uint8_t* data, size_t len)
...
@@ -197,15 +197,15 @@ void UnixStreamSocket::Write(const uint8_t* data, size_t len)
written
=
0
;
written
=
0
;
}
}
size_t
pendingLen
=
len
-
written
;
const
size_t
pendingLen
=
len
-
written
;
auto
*
writeData
=
new
UvWriteData
(
pendingLen
);
auto
*
writeData
=
new
UvWriteData
(
pendingLen
);
writeData
->
req
.
data
=
static_cast
<
void
*>
(
writeData
);
writeData
->
req
.
data
=
static_cast
<
void
*>
(
writeData
);
std
::
memcpy
(
writeData
->
store
,
data
+
written
,
pendingLen
);
std
::
memcpy
(
writeData
->
store
,
data
+
written
,
pendingLen
);
buffer
=
uv_buf_init
(
reinterpret_cast
<
char
*>
(
writeData
->
store
),
pendingLen
);
buffer
=
uv_buf_init
(
reinterpret_cast
<
char
*>
(
writeData
->
store
),
pendingLen
);
int
err
=
uv_write
(
const
int
err
=
uv_write
(
&
writeData
->
req
,
&
writeData
->
req
,
reinterpret_cast
<
uv_stream_t
*>
(
this
->
uvHandle
),
reinterpret_cast
<
uv_stream_t
*>
(
this
->
uvHandle
),
&
buffer
,
&
buffer
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论