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
eb797706
Commit
eb797706
authored
Jan 28, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p/net: cleaned up dial events
+ fixed race
parent
b4af146f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
11 deletions
+11
-11
p2p/net/conn/dial.go
p2p/net/conn/dial.go
+0
-1
p2p/net/swarm/swarm_dial.go
p2p/net/swarm/swarm_dial.go
+11
-9
util/eventlog/loggables/loggables.go
util/eventlog/loggables/loggables.go
+0
-1
No files found.
p2p/net/conn/dial.go
View file @
eb797706
...
...
@@ -60,7 +60,6 @@ func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) (
c2
,
err
:=
newSecureConn
(
ctx
,
d
.
PrivateKey
,
c
)
if
err
!=
nil
{
logdial
[
"error"
]
=
err
errOut
=
err
c
.
Close
()
return
...
...
p2p/net/swarm/swarm_dial.go
View file @
eb797706
...
...
@@ -266,17 +266,18 @@ func (s *Swarm) gatedDialAttempt(ctx context.Context, p peer.ID) (*Conn, error)
// dial is the actual swarm's dial logic, gated by Dial.
func
(
s
*
Swarm
)
dial
(
ctx
context
.
Context
,
p
peer
.
ID
)
(
*
Conn
,
error
)
{
var
logdial
=
lgbl
.
Dial
(
"swarm"
,
s
.
LocalPeer
(),
p
,
nil
,
nil
)
defer
log
.
EventBegin
(
ctx
,
"swarmDialDo"
,
logdial
)
.
Done
()
if
p
==
s
.
local
{
log
.
Event
(
ctx
,
"swarmDialDoDialSelf"
,
logdial
)
return
nil
,
ErrDialToSelf
}
defer
log
.
EventBegin
(
ctx
,
"swarmDialDo"
,
logdial
)
.
Done
()
logdial
[
"dial"
]
=
"failure"
// start off with failure. set to "success" at the end.
sk
:=
s
.
peers
.
PrivKey
(
s
.
local
)
logdial
[
"encrypted"
]
=
(
sk
!=
nil
)
// log wether this will be an encrypted dial or not.
if
sk
==
nil
{
//
may be
fine for sk to be nil, just log.
// fine for sk to be nil, just log.
log
.
Debug
(
"Dial not given PrivateKey, so WILL NOT SECURE conn."
)
log
.
Event
(
ctx
,
"swarmDialDoInsecure"
,
logdial
)
}
// get our own addrs. try dialing out from our listener addresses (reusing ports)
...
...
@@ -298,7 +299,9 @@ func (s *Swarm) dial(ctx context.Context, p peer.ID) (*Conn, error) {
remoteAddrs
=
addrutil
.
Subtract
(
remoteAddrs
,
s
.
peers
.
Addresses
(
s
.
local
))
log
.
Debugf
(
"%s swarm dialing %s -- remote:%s local:%s"
,
s
.
local
,
p
,
remoteAddrs
,
s
.
ListenAddresses
())
if
len
(
remoteAddrs
)
==
0
{
return
nil
,
errors
.
New
(
"peer has no addresses"
)
err
:=
errors
.
New
(
"peer has no addresses"
)
logdial
[
"error"
]
=
err
return
nil
,
err
}
// open connection to peer
...
...
@@ -316,20 +319,21 @@ func (s *Swarm) dial(ctx context.Context, p peer.ID) (*Conn, error) {
// try to get a connection to any addr
connC
,
err
:=
s
.
dialAddrs
(
ctx
,
d
,
p
,
remoteAddrs
)
if
err
!=
nil
{
logdial
[
"error"
]
=
err
return
nil
,
err
}
logdial
[
"netconn"
]
=
lgbl
.
NetConn
(
connC
)
// ok try to setup the new connection.
defer
log
.
EventBegin
(
ctx
,
"swarmDialDoSetup"
,
logdial
,
lgbl
.
NetConn
(
connC
))
.
Done
()
swarmC
,
err
:=
dialConnSetup
(
ctx
,
s
,
connC
)
if
err
!=
nil
{
log
.
Debug
(
"Dial newConnSetup failed. disconnecting."
)
log
.
Event
(
ctx
,
"swarmDialDoSetupFailed"
,
logdial
,
lgbl
.
NetConn
(
connC
),
lgbl
.
Error
(
err
))
logdial
[
"error"
]
=
err
connC
.
Close
()
// close the connection. didn't work out :(
return
nil
,
err
}
log
.
Event
(
ctx
,
"swarmDialDoSuccess"
,
logdial
,
lgbl
.
NetConn
(
connC
))
log
dial
[
"dial"
]
=
"success"
return
swarmC
,
nil
}
...
...
@@ -428,8 +432,6 @@ func dialConnSetup(ctx context.Context, s *Swarm, connC conn.Conn) (*Conn, error
// ok try to setup the new connection. (newConnSetup will add to group)
swarmC
,
err
:=
s
.
newConnSetup
(
ctx
,
psC
)
if
err
!=
nil
{
log
.
Debug
(
"Dial newConnSetup failed. disconnecting."
)
log
.
Event
(
ctx
,
"dialFailureDisconnect"
,
lgbl
.
NetConn
(
connC
),
lgbl
.
Error
(
err
))
psC
.
Close
()
// we need to make sure psC is Closed.
return
nil
,
err
}
...
...
util/eventlog/loggables/loggables.go
View file @
eb797706
...
...
@@ -37,7 +37,6 @@ func Dial(sys string, lid, rid peer.ID, laddr, raddr ma.Multiaddr) DeferredMap {
m
[
"subsystem"
]
=
sys
if
lid
!=
""
{
m
[
"localPeer"
]
=
func
()
interface
{}
{
return
lid
.
Pretty
()
}
_
=
m
[
"localPeer"
]
.
(
func
()
interface
{})
}
if
laddr
!=
nil
{
m
[
"localAddr"
]
=
func
()
interface
{}
{
return
laddr
.
String
()
}
...
...
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