Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
duniter
Commits
c283df5b
Commit
c283df5b
authored
7 years ago
by
Éloïs
Browse files
Options
Downloads
Plain Diff
Merge branch '1278-memory-leak-on-ws2p' into '1.6'
Resolve "Memory leak on WS2P" Closes
#1278
See merge request
!1247
parents
019a4a7a
d5a5aafd
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1247
Resolve "Memory leak on WS2P"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/modules/ws2p/lib/WS2PConnection.ts
+23
-13
23 additions, 13 deletions
app/modules/ws2p/lib/WS2PConnection.ts
app/modules/ws2p/lib/interface/WS2PServerMessageHandler.ts
+8
-1
8 additions, 1 deletion
app/modules/ws2p/lib/interface/WS2PServerMessageHandler.ts
with
31 additions
and
14 deletions
app/modules/ws2p/lib/WS2PConnection.ts
+
23
−
13
View file @
c283df5b
...
...
@@ -20,7 +20,7 @@ import {MembershipDTO} from "../../../lib/dto/MembershipDTO"
import
{
TransactionDTO
}
from
"
../../../lib/dto/TransactionDTO
"
import
{
PeerDTO
}
from
"
../../../lib/dto/PeerDTO
"
import
{
WS2PConstants
}
from
'
./constants
'
;
import
{
ProxiesConf
}
from
'
../../../lib/proxy
'
;
const
ws
=
require
(
'
ws
'
)
const
SocksProxyAgent
=
require
(
'
socks-proxy-agent
'
);
const
nuuid
=
require
(
'
node-uuid
'
);
...
...
@@ -253,6 +253,20 @@ export interface WS2PRequest {
params
?:
any
}
export
class
WS2PMessageExchange
{
promise
:
Promise
<
any
>
extras
:
{
resolve
:
(
data
:
any
)
=>
void
reject
:
(
err
:
any
)
=>
void
}
constructor
(
extras
:
{
resolve
:
()
=>
void
;
reject
:
()
=>
void
},
race
:
any
)
{
this
.
promise
=
race
this
.
extras
=
extras
}
}
/**
* The handler of a WS2P connection.
*
...
...
@@ -271,13 +285,7 @@ export class WS2PConnection {
private
nbPushsToRemoteCount
=
0
private
nbPushsByRemoteCount
=
0
private
exchanges
:
{
[
uuid
:
string
]:
{
promise
:
Promise
<
any
>
,
extras
:
{
resolve
:
(
data
:
any
)
=>
void
reject
:
(
err
:
any
)
=>
void
}
}
[
uuid
:
string
]:
WS2PMessageExchange
}
=
{}
constructor
(
...
...
@@ -575,9 +583,9 @@ export class WS2PConnection {
resolve
:
()
=>
{
console
.
error
(
'
resolution not implemented
'
)
},
reject
:
()
=>
{
console
.
error
(
'
rejection not implemented
'
)
}
}
this
.
exchanges
[
uuid
]
=
{
this
.
exchanges
[
uuid
]
=
new
WS2PMessageExchange
(
extras
,
promise
:
Promise
.
race
([
Promise
.
race
([
// The answer
new
Promise
((
res
,
rej
)
=>
{
extras
.
resolve
=
res
...
...
@@ -593,11 +601,13 @@ export class WS2PConnection {
},
this
.
options
.
requestTimeout
)
})
])
}
)
try
{
resolve
(
await
this
.
exchanges
[
uuid
].
promise
)
}
catch
(
e
)
{
reject
(
e
)
}
finally
{
delete
this
.
exchanges
[
uuid
]
}
}
})
...
...
This diff is collapsed.
Click to expand it.
app/modules/ws2p/lib/interface/WS2PServerMessageHandler.ts
+
8
−
1
View file @
c283df5b
...
...
@@ -115,6 +115,11 @@ export class WS2PServerMessageHandler implements WS2PMessageHandler {
}
this
.
server
.
logger
.
warn
(
message
)
}
setTimeout
(()
=>
{
if
(
this
.
errors
[
documentHash
])
{
delete
this
.
errors
[
documentHash
]
}
},
1000
*
WS2PConstants
.
ERROR_RECALL_DURATION_IN_SECONDS
)
}
else
{
// Remember the error for some time
if
(
!
this
.
errors
[
documentHash
])
{
...
...
@@ -125,7 +130,9 @@ export class WS2PServerMessageHandler implements WS2PMessageHandler {
}
this
.
errors
[
documentHash
].
pubkeys
[
c
.
pubkey
]
=
[
json
.
body
]
setTimeout
(()
=>
{
if
(
this
.
errors
[
documentHash
])
{
delete
this
.
errors
[
documentHash
]
}
},
1000
*
WS2PConstants
.
ERROR_RECALL_DURATION_IN_SECONDS
)
}
if
(
e
!==
"
Block already known
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment