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
0af1923c
Unverified
Commit
0af1923c
authored
Oct 27, 2018
by
Сергей Прохоров
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor cleanups
parent
120bf6a4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
mtp_dc_pool.erl
src/mtp_dc_pool.erl
+2
-2
mtp_down_conn.erl
src/mtp_down_conn.erl
+2
-2
No files found.
src/mtp_dc_pool.erl
View file @
0af1923c
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
-
record
(
state
,
-
record
(
state
,
{
dc_id
::
mtp_config
:
dc_id
(),
{
dc_id
::
mtp_config
:
dc_id
(),
%% This one might be really big:
%% This one might be really big:
upstreams
=
#
{}
::
#
{
upstream
()
=>
downstream
()
},
upstreams
=
#
{}
::
#
{
upstream
()
=>
{
downstream
(),
Monitor
::
reference
()}
},
%% On-demand downstreams are started asynchronously;
%% On-demand downstreams are started asynchronously;
pending_downstreams
=
[]
::
[
pid
()],
pending_downstreams
=
[]
::
[
pid
()],
%% Downstream storage that allows to choose the one with minimal
%% Downstream storage that allows to choose the one with minimal
...
@@ -142,7 +142,6 @@ handle_get(Upstream, Opts, #state{downstreams = Ds,
...
@@ -142,7 +142,6 @@ handle_get(Upstream, Opts, #state{downstreams = Ds,
upstreams
=
Us
}
=
St
)
->
upstreams
=
Us
}
=
St
)
->
{
Downstream
,
N
,
Ds1
}
=
ds_get
(
Ds
),
{
Downstream
,
N
,
Ds1
}
=
ds_get
(
Ds
),
MonRef
=
erlang
:
monitor
(
process
,
Upstream
),
MonRef
=
erlang
:
monitor
(
process
,
Upstream
),
%% if N > X and len(pending) < Y -> connect()
Us1
=
Us
#
{
Upstream
=>
{
Downstream
,
MonRef
}},
Us1
=
Us
#
{
Upstream
=>
{
Downstream
,
MonRef
}},
ok
=
mtp_down_conn
:
upstream_new
(
Downstream
,
Upstream
,
Opts
),
ok
=
mtp_down_conn
:
upstream_new
(
Downstream
,
Upstream
,
Opts
),
{
Downstream
,
maybe_spawn_connection
(
{
Downstream
,
maybe_spawn_connection
(
...
@@ -186,6 +185,7 @@ handle_down(MonRef, Pid, #state{downstreams = Ds,
...
@@ -186,6 +185,7 @@ handle_down(MonRef, Pid, #state{downstreams = Ds,
end
.
end
.
maybe_spawn_connection
(
CurrentMin
,
#state
{
pending_downstreams
=
Pending
}
=
St
)
->
maybe_spawn_connection
(
CurrentMin
,
#state
{
pending_downstreams
=
Pending
}
=
St
)
->
%% if N > X and len(pending) < Y -> connect()
%% TODO: shrinking (by timer)
%% TODO: shrinking (by timer)
ToSpawn
=
ToSpawn
=
case
application
:
get_env
(
?
APP
,
clients_per_dc_connection
)
of
case
application
:
get_env
(
?
APP
,
clients_per_dc_connection
)
of
...
...
src/mtp_down_conn.erl
View file @
0af1923c
...
@@ -41,13 +41,13 @@
...
@@ -41,13 +41,13 @@
-
record
(
state
,
{
stage
=
init
::
stage
(),
-
record
(
state
,
{
stage
=
init
::
stage
(),
stage_state
=
[]
::
any
(),
stage_state
=
[]
::
any
(),
sock
::
gen_tcp
:
socket
()
|
undefined
,
sock
::
gen_tcp
:
socket
()
|
undefined
,
addr_bin
::
binary
(),
% my external ip:port
addr_bin
::
binary
()
|
undefined
,
% my external ip:port
codec
::
mtp_layer
:
layer
()
|
undefined
,
codec
::
mtp_layer
:
layer
()
|
undefined
,
upstreams
=
#
{}
::
#
{
mtp_handler
:
handle
()
=>
upstream
()},
upstreams
=
#
{}
::
#
{
mtp_handler
:
handle
()
=>
upstream
()},
upstreams_rev
=
#
{}
::
#
{
mtp_rpc
:
conn_id
()
=>
mtp_handler
:
handle
()},
upstreams_rev
=
#
{}
::
#
{
mtp_rpc
:
conn_id
()
=>
mtp_handler
:
handle
()},
pool
::
pid
(),
pool
::
pid
(),
dc_id
::
mtp_config
:
dc_id
(),
dc_id
::
mtp_config
:
dc_id
(),
netloc
::
mtp_config
:
netloc
()
% telegram server ip:port
netloc
::
mtp_config
:
netloc
()
|
undefined
% telegram server ip:port
}).
}).
start_link
(
Pool
,
DcId
)
->
start_link
(
Pool
,
DcId
)
->
...
...
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