Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
145330fd
Commit
145330fd
authored
Apr 10, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p: properly decrement peer wait group counter for setup errors
parent
f1d710af
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
server.go
p2p/server.go
+11
-0
No files found.
p2p/server.go
View file @
145330fd
...
@@ -344,6 +344,10 @@ func (srv *Server) dialNode(dest *discover.Node) {
...
@@ -344,6 +344,10 @@ func (srv *Server) dialNode(dest *discover.Node) {
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Dialing %v
\n
"
,
dest
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Dialing %v
\n
"
,
dest
)
conn
,
err
:=
srv
.
Dialer
.
Dial
(
"tcp"
,
addr
.
String
())
conn
,
err
:=
srv
.
Dialer
.
Dial
(
"tcp"
,
addr
.
String
())
if
err
!=
nil
{
if
err
!=
nil
{
// dialLoop adds to the wait group counter when launching
// dialNode, so we need to count it down again. startPeer also
// does that when an error occurs.
srv
.
peerWG
.
Done
()
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"dial error: %v"
,
err
)
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"dial error: %v"
,
err
)
return
return
}
}
...
@@ -356,11 +360,17 @@ func (srv *Server) Self() *discover.Node {
...
@@ -356,11 +360,17 @@ func (srv *Server) Self() *discover.Node {
func
(
srv
*
Server
)
startPeer
(
fd
net
.
Conn
,
dest
*
discover
.
Node
)
{
func
(
srv
*
Server
)
startPeer
(
fd
net
.
Conn
,
dest
*
discover
.
Node
)
{
// TODO: handle/store session token
// TODO: handle/store session token
// Run setupFunc, which should create an authenticated connection
// and run the capability exchange. Note that any early error
// returns during that exchange need to call peerWG.Done because
// the callers of startPeer added the peer to the wait group already.
fd
.
SetDeadline
(
time
.
Now
()
.
Add
(
handshakeTimeout
))
fd
.
SetDeadline
(
time
.
Now
()
.
Add
(
handshakeTimeout
))
conn
,
err
:=
srv
.
setupFunc
(
fd
,
srv
.
PrivateKey
,
srv
.
ourHandshake
,
dest
)
conn
,
err
:=
srv
.
setupFunc
(
fd
,
srv
.
PrivateKey
,
srv
.
ourHandshake
,
dest
)
if
err
!=
nil
{
if
err
!=
nil
{
fd
.
Close
()
fd
.
Close
()
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Handshake with %v failed: %v"
,
fd
.
RemoteAddr
(),
err
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Handshake with %v failed: %v"
,
fd
.
RemoteAddr
(),
err
)
srv
.
peerWG
.
Done
()
return
return
}
}
conn
.
MsgReadWriter
=
&
netWrapper
{
conn
.
MsgReadWriter
=
&
netWrapper
{
...
@@ -371,6 +381,7 @@ func (srv *Server) startPeer(fd net.Conn, dest *discover.Node) {
...
@@ -371,6 +381,7 @@ func (srv *Server) startPeer(fd net.Conn, dest *discover.Node) {
if
ok
,
reason
:=
srv
.
addPeer
(
conn
.
ID
,
p
);
!
ok
{
if
ok
,
reason
:=
srv
.
addPeer
(
conn
.
ID
,
p
);
!
ok
{
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"Not adding %v (%v)
\n
"
,
p
,
reason
)
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"Not adding %v (%v)
\n
"
,
p
,
reason
)
p
.
politeDisconnect
(
reason
)
p
.
politeDisconnect
(
reason
)
srv
.
peerWG
.
Done
()
return
return
}
}
// The handshakes are done and it passed all checks.
// The handshakes are done and it passed all checks.
...
...
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