summaryrefslogtreecommitdiffhomepage
path: root/server/fsm.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-06-10 09:32:39 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-06-10 09:32:39 +0900
commit0d42ad45e3799ab73f29813aa87cd6bf5016f8a4 (patch)
tree5c90dd90f3b64457288fffd958934984464ac552 /server/fsm.go
parentf2f6a230ac300f3ca9b774e0f0e52bf36655fb9e (diff)
server: use write deadline
Seems that write() is blocked forever when a connection is not cleanly closed. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/fsm.go')
-rw-r--r--server/fsm.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/server/fsm.go b/server/fsm.go
index b40305f6..7bced26c 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -682,9 +682,20 @@ func (h *FSMHandler) sendMessageloop() error {
fsm.bgpMessageStateUpdate(0, false)
return nil
}
+ if err := conn.SetWriteDeadline(time.Now().Add(time.Second * 30)); err != nil {
+ h.errorCh <- true
+ conn.Close()
+ return fmt.Errorf("failed to set write deadline")
+ }
_, err = conn.Write(b)
if err != nil {
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": fsm.peerConfig.NeighborAddress,
+ "Data": err,
+ }).Warn("failed to send")
h.errorCh <- true
+ conn.Close()
return fmt.Errorf("closed")
}
fsm.bgpMessageStateUpdate(m.Header.Type, false)