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
edccc7ae
Commit
edccc7ae
authored
Aug 19, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p: continue listening after temporary errors
parent
7d5ff770
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
6 deletions
+25
-6
server.go
p2p/server.go
+25
-6
No files found.
p2p/server.go
View file @
edccc7ae
...
@@ -542,6 +542,10 @@ func (srv *Server) encHandshakeChecks(peers map[discover.NodeID]*Peer, c *conn)
...
@@ -542,6 +542,10 @@ func (srv *Server) encHandshakeChecks(peers map[discover.NodeID]*Peer, c *conn)
}
}
}
}
type
tempError
interface
{
Temporary
()
bool
}
// listenLoop runs in its own goroutine and accepts
// listenLoop runs in its own goroutine and accepts
// inbound connections.
// inbound connections.
func
(
srv
*
Server
)
listenLoop
()
{
func
(
srv
*
Server
)
listenLoop
()
{
...
@@ -561,16 +565,31 @@ func (srv *Server) listenLoop() {
...
@@ -561,16 +565,31 @@ func (srv *Server) listenLoop() {
}
}
for
{
for
{
// Wait for a handshake slot before accepting.
<-
slots
<-
slots
fd
,
err
:=
srv
.
listener
.
Accept
()
if
err
!=
nil
{
var
(
return
fd
net
.
Conn
err
error
)
for
{
fd
,
err
=
srv
.
listener
.
Accept
()
if
tempErr
,
ok
:=
err
.
(
tempError
);
ok
&&
tempErr
.
Temporary
()
{
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Temporary read error: %v"
,
err
)
continue
}
else
if
err
!=
nil
{
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Read error: %v"
,
err
)
return
}
break
}
}
mfd
:=
newMeteredConn
(
fd
,
true
)
fd
=
newMeteredConn
(
fd
,
true
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Accepted conn %v
\n
"
,
fd
.
RemoteAddr
())
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Accepted conn %v
\n
"
,
mfd
.
RemoteAddr
())
// Spawn the handler. It will give the slot back when the connection
// has been established.
go
func
()
{
go
func
()
{
srv
.
setupConn
(
m
fd
,
inboundConn
,
nil
)
srv
.
setupConn
(
fd
,
inboundConn
,
nil
)
slots
<-
struct
{}{}
slots
<-
struct
{}{}
}()
}()
}
}
...
...
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