Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mtproto_proxy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mtproto_proxy
Commits
8d9c64b5
Unverified
Commit
8d9c64b5
authored
Oct 20, 2018
by
Сергей Прохоров
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't crash on tcp send errors
parent
e0d586ef
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
4 deletions
+27
-4
mtp_handler.erl
src/mtp_handler.erl
+20
-2
mtp_metric.erl
src/mtp_metric.erl
+7
-2
No files found.
src/mtp_handler.erl
View file @
8d9c64b5
...
@@ -307,7 +307,16 @@ up_send(Packet, #state{stage = tunnel,
...
@@ -307,7 +307,16 @@ up_send(Packet, #state{stage = tunnel,
{
Encoded
,
UpCodec1
}
=
mtp_layer
:
encode_packet
(
Packet
,
UpCodec
),
{
Encoded
,
UpCodec1
}
=
mtp_layer
:
encode_packet
(
Packet
,
UpCodec
),
mtp_metric
:
rt
([
?
APP
,
upstream_send_duration
,
seconds
],
mtp_metric
:
rt
([
?
APP
,
upstream_send_duration
,
seconds
],
fun
()
->
fun
()
->
ok
=
Transport
:
send
(
Sock
,
Encoded
)
case
Transport
:
send
(
Sock
,
Encoded
)
of
ok
->
ok
;
{
error
,
Reason
}
->
is_atom
(
Reason
)
andalso
mtp_metric
:
count_inc
(
[
?
APP
,
upstream_send_error
,
total
],
1
,
#
{
labels
=>
[
Reason
]}),
lager
:
warning
(
"Upstream send error:
~p
"
,
[
Reason
]),
throw
({
stop
,
normal
,
S
})
end
end
),
end
),
{
ok
,
S
#state
{
up_codec
=
UpCodec1
}}.
{
ok
,
S
#state
{
up_codec
=
UpCodec1
}}.
...
@@ -316,7 +325,16 @@ down_send(Packet, #state{down_sock = Sock,
...
@@ -316,7 +325,16 @@ down_send(Packet, #state{down_sock = Sock,
{
Encoded
,
DownCodec1
}
=
mtp_layer
:
encode_packet
(
Packet
,
DownCodec
),
{
Encoded
,
DownCodec1
}
=
mtp_layer
:
encode_packet
(
Packet
,
DownCodec
),
mtp_metric
:
rt
([
?
APP
,
downstream_send_duration
,
seconds
],
mtp_metric
:
rt
([
?
APP
,
downstream_send_duration
,
seconds
],
fun
()
->
fun
()
->
ok
=
gen_tcp
:
send
(
Sock
,
Encoded
)
case
gen_tcp
:
send
(
Sock
,
Encoded
)
of
ok
->
ok
;
{
error
,
Reason
}
->
is_atom
(
Reason
)
andalso
mtp_metric
:
count_inc
(
[
?
APP
,
downstream_send_error
,
total
],
1
,
#
{
labels
=>
[
Reason
]}),
lager
:
warning
(
"Downstream send error:
~p
"
,
[
Reason
]),
throw
({
stop
,
normal
,
S
})
end
end
),
end
),
{
ok
,
S
#state
{
down_codec
=
DownCodec1
}}.
{
ok
,
S
#state
{
down_codec
=
DownCodec1
}}.
...
...
src/mtp_metric.erl
View file @
8d9c64b5
...
@@ -146,6 +146,11 @@ active_metrics() ->
...
@@ -146,6 +146,11 @@ active_metrics() ->
#
{
duration_unit
=>
seconds
,
#
{
duration_unit
=>
seconds
,
%% buckets => ?MS_BUCKETS
%% buckets => ?MS_BUCKETS
labels
=>
[
listener
]
labels
=>
[
listener
]
}}
}},
{
count
,
[
?
APP
,
upstream_send_error
,
total
],
"Count of tcp send errors to upstream"
,
#
{
labels
=>
[
listener
,
reason
]}},
{
count
,
[
?
APP
,
downstream_send_error
,
total
],
"Count of tcp send errors to downstream"
,
#
{
labels
=>
[
listener
,
reason
]}}
].
].
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment