diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-06-10 09:13:40 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-06-10 09:33:02 +0900 |
commit | 42234c30bc98af1339752477539938d462c9969d (patch) | |
tree | ed64b53c0a8f6146e9db100a6108d8a7143d6cf3 /server | |
parent | 0d42ad45e3799ab73f29813aa87cd6bf5016f8a4 (diff) |
server: avoid to be blocked due to accepted conn passing
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/peer.go | 10 |
1 files changed, 9 insertions, 1 deletions
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) { |