Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
d811f6b0
Commit
d811f6b0
authored
Dec 11, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer/rpc: allow data to be sent even in FinWait [GH-705]
parent
63f957cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
2 deletions
+52
-2
packer/rpc/muxconn.go
packer/rpc/muxconn.go
+7
-2
packer/rpc/muxconn_test.go
packer/rpc/muxconn_test.go
+45
-0
No files found.
packer/rpc/muxconn.go
View file @
d811f6b0
...
...
@@ -339,13 +339,18 @@ func (m *MuxConn) loop() {
case
muxPacketData
:
stream
.
mu
.
Lock
()
if
stream
.
state
==
streamStateEstablished
{
switch
stream
.
state
{
case
streamStateFinWait1
:
fallthrough
case
streamStateFinWait2
:
fallthrough
case
streamStateEstablished
:
select
{
case
stream
.
writeCh
<-
data
:
default
:
panic
(
fmt
.
Sprintf
(
"Failed to write data, buffer full for stream %d"
,
id
))
}
}
else
{
default
:
log
.
Printf
(
"[ERR] Data received for stream in state: %d"
,
stream
.
state
)
}
stream
.
mu
.
Unlock
()
...
...
packer/rpc/muxconn_test.go
View file @
d811f6b0
...
...
@@ -114,6 +114,51 @@ func TestMuxConn(t *testing.T) {
<-
doneCh
}
// This tests that even when the client end is closed, data can be
// read from the server.
func
TestMuxConn_clientCloseRead
(
t
*
testing
.
T
)
{
client
,
server
:=
testMux
(
t
)
defer
client
.
Close
()
defer
server
.
Close
()
// This channel will be closed when we close
waitCh
:=
make
(
chan
struct
{})
go
func
()
{
conn
,
err
:=
server
.
Accept
(
0
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
<-
waitCh
_
,
err
=
conn
.
Write
([]
byte
(
"foo"
))
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
conn
.
Close
()
}()
s0
,
err
:=
client
.
Dial
(
0
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
err
:=
s0
.
Close
();
err
!=
nil
{
t
.
Fatalf
(
"bad: %s"
,
err
)
}
// Close this to continue on on the server-side
close
(
waitCh
)
var
data
[
1024
]
byte
n
,
err
:=
s0
.
Read
(
data
[
:
])
if
string
(
data
[
:
n
])
!=
"foo"
{
t
.
Fatalf
(
"bad: %#v"
,
string
(
data
[
:
n
]))
}
}
func
TestMuxConn_socketClose
(
t
*
testing
.
T
)
{
client
,
server
:=
testMux
(
t
)
defer
client
.
Close
()
...
...
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