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
bf01459b
Unverified
Commit
bf01459b
authored
Jan 20, 2019
by
Сергей Прохоров
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle some of 'unknown_upstream' errors as expected race-condition
parent
8026fb55
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
3 deletions
+19
-3
mtp_handler.erl
src/mtp_handler.erl
+19
-3
No files found.
src/mtp_handler.erl
View file @
bf01459b
...
...
@@ -129,7 +129,7 @@ handle_cast({proxy_ans, Down, Data}, #state{down = Down} = S) ->
handle_cast
({
close_ext
,
Down
},
#state
{
down
=
Down
,
sock
=
USock
,
transport
=
UTrans
}
=
S
)
->
lager
:
debug
(
"asked to close connection by downstream"
),
ok
=
UTrans
:
close
(
USock
),
{
stop
,
normal
,
S
};
{
stop
,
normal
,
S
#state
{
down
=
undefined
}
};
handle_cast
({
simple_ack
,
Down
,
Confirm
},
#state
{
down
=
Down
}
=
S
)
->
lager
:
info
(
"Simple ack:
~p
,
~p
"
,
[
Down
,
Confirm
]),
{
noreply
,
S
};
...
...
@@ -289,8 +289,24 @@ up_send(Packet, #state{stage = tunnel,
down_send
(
Packet
,
#state
{
down
=
Down
}
=
S
)
->
%% lager:debug(">Down: ~p", [Packet]),
ok
=
mtp_down_conn
:
send
(
Down
,
Packet
),
{
ok
,
S
}.
case
mtp_down_conn
:
send
(
Down
,
Packet
)
of
ok
->
{
ok
,
S
};
{
error
,
unknown_upstream
}
->
handle_unknown_upstream
(
S
)
end
.
handle_unknown_upstream
(
#state
{
down
=
Down
,
sock
=
USock
,
transport
=
UTrans
}
=
S
)
->
%% there might be a race-condition between packets from upstream socket and
%% downstream's 'close_ext' message. Most likely because of slow up_send
ok
=
UTrans
:
close
(
USock
),
receive
{
'$gen_cast'
,
{
close_ext
,
Down
}}
->
lager
:
debug
(
"asked to close connection by downstream"
),
throw
({
stop
,
normal
,
S
#state
{
down
=
undefined
}})
after
0
->
throw
({
stop
,
got_unknown_upstream
,
S
})
end
.
%% Internal
...
...
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