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
edbdee5d
Commit
edbdee5d
authored
Dec 20, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer/rpc: accept/dial stream IDs are unique [GH-727]
parent
629f3eee
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
205 additions
and
128 deletions
+205
-128
packer/rpc/client.go
packer/rpc/client.go
+1
-1
packer/rpc/communicator.go
packer/rpc/communicator.go
+3
-4
packer/rpc/muxconn.go
packer/rpc/muxconn.go
+196
-118
packer/rpc/muxconn_test.go
packer/rpc/muxconn_test.go
+4
-4
packer/rpc/server.go
packer/rpc/server.go
+1
-1
No files found.
packer/rpc/client.go
View file @
edbdee5d
...
...
@@ -17,7 +17,7 @@ type Client struct {
}
func
NewClient
(
rwc
io
.
ReadWriteCloser
)
(
*
Client
,
error
)
{
result
,
err
:=
newClientWithMux
(
NewMuxConn
(
rwc
,
0
),
0
)
result
,
err
:=
newClientWithMux
(
NewMuxConn
(
rwc
),
0
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
packer/rpc/communicator.go
View file @
edbdee5d
...
...
@@ -164,7 +164,7 @@ func (c *CommunicatorServer) Start(args *CommunicatorStartArgs, reply *interface
}
}()
if
args
.
StdinStreamId
>
0
{
if
args
.
StdinStreamId
>
=
0
{
conn
,
err
:=
c
.
mux
.
Dial
(
args
.
StdinStreamId
)
if
err
!=
nil
{
close
(
doneCh
)
...
...
@@ -175,7 +175,7 @@ func (c *CommunicatorServer) Start(args *CommunicatorStartArgs, reply *interface
cmd
.
Stdin
=
conn
}
if
args
.
StdoutStreamId
>
0
{
if
args
.
StdoutStreamId
>
=
0
{
conn
,
err
:=
c
.
mux
.
Dial
(
args
.
StdoutStreamId
)
if
err
!=
nil
{
close
(
doneCh
)
...
...
@@ -186,7 +186,7 @@ func (c *CommunicatorServer) Start(args *CommunicatorStartArgs, reply *interface
cmd
.
Stdout
=
conn
}
if
args
.
StderrStreamId
>
0
{
if
args
.
StderrStreamId
>
=
0
{
conn
,
err
:=
c
.
mux
.
Dial
(
args
.
StderrStreamId
)
if
err
!=
nil
{
close
(
doneCh
)
...
...
@@ -253,7 +253,6 @@ func (c *CommunicatorServer) Download(args *CommunicatorDownloadArgs, reply *int
}
func
serveSingleCopy
(
name
string
,
mux
*
MuxConn
,
id
uint32
,
dst
io
.
Writer
,
src
io
.
Reader
)
{
log
.
Printf
(
"[DEBUG] %s: Connecting to stream %d"
,
name
,
id
)
conn
,
err
:=
mux
.
Accept
(
id
)
if
err
!=
nil
{
log
.
Printf
(
"[ERR] '%s' accept error: %s"
,
name
,
err
)
...
...
packer/rpc/muxconn.go
View file @
edbdee5d
This diff is collapsed.
Click to expand it.
packer/rpc/muxconn_test.go
View file @
edbdee5d
...
...
@@ -33,7 +33,7 @@ func testMux(t *testing.T) (client *MuxConn, server *MuxConn) {
t
.
Fatalf
(
"err: %s"
,
err
)
}
server
=
NewMuxConn
(
conn
,
1
)
server
=
NewMuxConn
(
conn
)
}()
// Client side
...
...
@@ -41,7 +41,7 @@ func testMux(t *testing.T) (client *MuxConn, server *MuxConn) {
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
client
=
NewMuxConn
(
conn
,
0
)
client
=
NewMuxConn
(
conn
)
// Wait for the server
<-
doneCh
...
...
@@ -241,14 +241,14 @@ func TestMuxConnNextId(t *testing.T) {
a
:=
client
.
NextId
()
b
:=
client
.
NextId
()
if
a
!=
0
||
b
!=
2
{
if
a
!=
0
||
b
!=
1
{
t
.
Fatalf
(
"IDs should increment"
)
}
a
=
server
.
NextId
()
b
=
server
.
NextId
()
if
a
!=
1
||
b
!=
3
{
if
a
!=
0
||
b
!=
1
{
t
.
Fatalf
(
"IDs should increment: %d %d"
,
a
,
b
)
}
}
packer/rpc/server.go
View file @
edbdee5d
...
...
@@ -36,7 +36,7 @@ type Server struct {
// NewServer returns a new Packer RPC server.
func
NewServer
(
conn
io
.
ReadWriteCloser
)
*
Server
{
result
:=
newServerWithMux
(
NewMuxConn
(
conn
,
1
),
0
)
result
:=
newServerWithMux
(
NewMuxConn
(
conn
),
0
)
result
.
closeMux
=
true
return
result
}
...
...
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