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-yamux
Commits
9a36404e
Unverified
Commit
9a36404e
authored
Apr 02, 2020
by
Will
Committed by
GitHub
Apr 02, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #24 from libp2p/fix/re-disable-write-coalescing
Revert "re-enable write coalescing"
parents
42b17e90
c4368703
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
35 deletions
+40
-35
session.go
session.go
+40
-35
No files found.
session.go
View file @
9a36404e
...
...
@@ -422,20 +422,25 @@ func (s *Session) sendLoop() error {
return
nil
}
writer
:=
pool
.
Writer
{
W
:
s
.
conn
}
writer
:=
s
.
conn
var
writeTimeout
*
time
.
Timer
var
writeTimeoutCh
<-
chan
time
.
Time
if
s
.
config
.
WriteCoalesceDelay
>
0
{
writeTimeout
=
time
.
NewTimer
(
s
.
config
.
WriteCoalesceDelay
)
defer
writeTimeout
.
Stop
()
// FIXME: https://github.com/libp2p/go-libp2p/issues/644
// Write coalescing is disabled for now.
writeTimeoutCh
=
writeTimeout
.
C
}
else
{
ch
:=
make
(
chan
time
.
Time
)
close
(
ch
)
writeTimeoutCh
=
ch
}
//writer := pool.Writer{W: s.conn}
//var writeTimeout *time.Timer
//var writeTimeoutCh <-chan time.Time
//if s.config.WriteCoalesceDelay > 0 {
// writeTimeout = time.NewTimer(s.config.WriteCoalesceDelay)
// defer writeTimeout.Stop()
// writeTimeoutCh = writeTimeout.C
//} else {
// ch := make(chan time.Time)
// close(ch)
// writeTimeoutCh = ch
//}
for
{
// yield after processing the last message, if we've shutdown.
...
...
@@ -453,29 +458,29 @@ func (s *Session) sendLoop() error {
case
buf
=
<-
s
.
sendCh
:
case
<-
s
.
shutdownCh
:
return
nil
default
:
select
{
case
buf
=
<-
s
.
sendCh
:
case
<-
s
.
shutdownCh
:
return
nil
case
<-
writeTimeoutCh
:
if
err
:=
writer
.
Flush
();
err
!=
nil
{
if
os
.
IsTimeout
(
err
)
{
err
=
ErrConnectionWriteTimeout
}
return
err
}
select
{
case
buf
=
<-
s
.
sendCh
:
case
<-
s
.
shutdownCh
:
return
nil
}
if
writeTimeout
!=
nil
{
writeTimeout
.
Reset
(
s
.
config
.
WriteCoalesceDelay
)
}
}
//
default:
//
select {
//
case buf = <-s.sendCh:
//
case <-s.shutdownCh:
//
return nil
//
case <-writeTimeoutCh:
//
if err := writer.Flush(); err != nil {
//
if os.IsTimeout(err) {
//
err = ErrConnectionWriteTimeout
//
}
//
return err
//
}
//
select {
//
case buf = <-s.sendCh:
//
case <-s.shutdownCh:
//
return nil
//
}
//
if writeTimeout != nil {
//
writeTimeout.Reset(s.config.WriteCoalesceDelay)
//
}
//
}
}
if
err
:=
extendWriteDeadline
();
err
!=
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