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
7069f8af
Commit
7069f8af
authored
Dec 10, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer/rpc: update some comments
parent
00c7da94
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
packer/rpc/muxconn.go
packer/rpc/muxconn.go
+14
-4
No files found.
packer/rpc/muxconn.go
View file @
7069f8af
...
...
@@ -9,9 +9,13 @@ import (
"time"
)
// MuxConn is a connection that can be used bi-directionally for RPC. Normally,
// Go RPC only allows client-to-server connections. This allows the client
// to actually act as a server as well.
// MuxConn is able to multiplex multiple streams on top of any
// io.ReadWriteCloser. These streams act like TCP connections (Dial, Accept,
// Close, full duplex, etc.).
//
// The underlying io.ReadWriteCloser is expected to guarantee delivery
// and ordering, such as TCP. Congestion control and such aren't implemented
// by the streams, so that is also up to the underlying connection.
//
// MuxConn works using a fairly dumb multiplexing technique of simply
// framing every piece of data sent into a prefix + data format. Streams
...
...
@@ -34,6 +38,7 @@ const (
muxPacketData
)
// Create a new MuxConn around any io.ReadWriteCloser.
func
NewMuxConn
(
rwc
io
.
ReadWriteCloser
)
*
MuxConn
{
m
:=
&
MuxConn
{
rwc
:
rwc
,
...
...
@@ -57,6 +62,8 @@ func (m *MuxConn) Close() error {
}
m
.
streams
=
make
(
map
[
uint32
]
*
Stream
)
// Close the actual connection. This will also force the loop
// to end since it'll read EOF or closed connection.
return
m
.
rwc
.
Close
()
}
...
...
@@ -237,6 +244,8 @@ func (m *MuxConn) openStream(id uint32) (*Stream, error) {
}
func
(
m
*
MuxConn
)
loop
()
{
// Force close every stream that we know about when we exit so
// that they all read EOF and don't block forever.
defer
func
()
{
m
.
mu
.
Lock
()
defer
m
.
mu
.
Unlock
()
...
...
@@ -363,7 +372,8 @@ func (m *MuxConn) write(id uint32, dataType muxPacketType, p []byte) (int, error
return
m
.
rwc
.
Write
(
p
)
}
// Stream is a single stream of data and implements io.ReadWriteCloser
// Stream is a single stream of data and implements io.ReadWriteCloser.
// A Stream is full-duplex so you can write data as well as read data.
type
Stream
struct
{
id
uint32
mux
*
MuxConn
...
...
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