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
dms3
go-dms3
Commits
d47115bc
Commit
d47115bc
authored
Oct 18, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swarm: msg wrapping
parent
afed188d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
net/swarm/conn.go
net/swarm/conn.go
+7
-7
No files found.
net/swarm/conn.go
View file @
d47115bc
...
...
@@ -126,7 +126,7 @@ func (s *Swarm) connVersionExchange(r conn.Conn) error {
return
err
}
r
.
Msg
Out
()
<-
msg
.
New
(
rpeer
,
myVerBytes
)
r
.
Out
()
<-
myVerBytes
log
.
Debug
(
"Sent my version(%s) [to = %s]"
,
localH
,
rpeer
)
select
{
...
...
@@ -136,13 +136,13 @@ func (s *Swarm) connVersionExchange(r conn.Conn) error {
// case <-remote.Done():
// return errors.New("remote closed connection during version exchange")
case
data
,
ok
:=
<-
r
.
Msg
In
()
:
case
data
,
ok
:=
<-
r
.
In
()
:
if
!
ok
{
return
fmt
.
Errorf
(
"Error retrieving from conn: %v"
,
rpeer
)
}
remoteH
=
new
(
handshake
.
Handshake1
)
err
=
proto
.
Unmarshal
(
data
.
Data
()
,
remoteH
)
err
=
proto
.
Unmarshal
(
data
,
remoteH
)
if
err
!=
nil
{
s
.
Close
()
return
fmt
.
Errorf
(
"connSetup: could not decode remote version: %q"
,
err
)
...
...
@@ -174,7 +174,7 @@ func (s *Swarm) fanOut() {
}
s
.
connsLock
.
RLock
()
c
onn
,
found
:=
s
.
conns
[
msg
.
Peer
()
.
Key
()]
c
,
found
:=
s
.
conns
[
msg
.
Peer
()
.
Key
()]
s
.
connsLock
.
RUnlock
()
if
!
found
{
...
...
@@ -187,7 +187,7 @@ func (s *Swarm) fanOut() {
// log.Debug("[peer: %s] Sent message [to = %s]", s.local, msg.Peer())
// queue it in the connection's buffer
c
onn
.
Msg
Out
()
<-
msg
c
.
Out
()
<-
msg
.
Data
()
}
}
}
...
...
@@ -202,7 +202,7 @@ func (s *Swarm) fanIn(c conn.Conn) {
c
.
Close
()
goto
out
case
data
,
ok
:=
<-
c
.
Msg
In
()
:
case
data
,
ok
:=
<-
c
.
In
()
:
if
!
ok
{
e
:=
fmt
.
Errorf
(
"Error retrieving from conn: %v"
,
c
.
RemotePeer
())
s
.
errChan
<-
e
...
...
@@ -210,7 +210,7 @@ func (s *Swarm) fanIn(c conn.Conn) {
}
// log.Debug("[peer: %s] Received message [from = %s]", s.local, c.Peer)
s
.
Incoming
<-
data
s
.
Incoming
<-
msg
.
New
(
c
.
RemotePeer
(),
data
)
}
}
...
...
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