From 42234c30bc98af1339752477539938d462c9969d Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Wed, 10 Jun 2015 09:13:40 +0900 Subject: server: avoid to be blocked due to accepted conn passing Signed-off-by: FUJITA Tomonori --- server/peer.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'server/peer.go') diff --git a/server/peer.go b/server/peer.go index 226f21d1..ff85ad28 100644 --- a/server/peer.go +++ b/server/peer.go @@ -191,7 +191,15 @@ func (peer *Peer) startFSMHandler(incoming chan *fsmMsg) { } func (peer *Peer) PassConn(conn *net.TCPConn) { - peer.fsm.connCh <- conn + select { + case peer.fsm.connCh <- conn: + default: + conn.Close() + log.WithFields(log.Fields{ + "Topic": "Peer", + "Key": peer.config.NeighborAddress, + }).Warn("accepted conn is closed to avoid be blocked") + } } func (peer *Peer) MarshalJSON() ([]byte, error) { -- cgit v1.2.3