Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-kad-dht
Commits
bd93c313
Commit
bd93c313
authored
Jun 07, 2016
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use constants for stream reuse heuristics
License: MIT Signed-off-by:
Jeromy
<
why@ipfs.io
>
parent
5d9a529d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
dht_net.go
dht_net.go
+7
-2
No files found.
dht_net.go
View file @
bd93c313
...
...
@@ -151,6 +151,11 @@ func (ms *messageSender) prep() error {
return
nil
}
// streamReuseTries is the number of times we will try to reuse a stream to a
// given peer before giving up and reverting to the old one-message-per-stream
// behaviour.
const
streamReuseTries
=
3
func
(
ms
*
messageSender
)
SendMessage
(
ctx
context
.
Context
,
pmes
*
pb
.
Message
)
error
{
ms
.
lk
.
Lock
()
defer
ms
.
lk
.
Unlock
()
...
...
@@ -162,7 +167,7 @@ func (ms *messageSender) SendMessage(ctx context.Context, pmes *pb.Message) erro
return
err
}
if
ms
.
singleMes
>
3
{
if
ms
.
singleMes
>
streamReuseTries
{
ms
.
s
.
Close
()
ms
.
s
=
nil
}
...
...
@@ -215,7 +220,7 @@ func (ms *messageSender) SendRequest(ctx context.Context, pmes *pb.Message) (*pb
return
nil
,
err
}
if
ms
.
singleMes
>
3
{
if
ms
.
singleMes
>
streamReuseTries
{
ms
.
s
.
Close
()
ms
.
s
=
nil
}
...
...
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