summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-03-06 07:36:20 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-03-07 00:08:04 -0800
commit0561c11889edab709a51fff7dc82bf25044f51bb (patch)
tree60a06d5b2160943096b36952e70f988ba5600cbc /server/server.go
parent74c79d99a87ce626cb7fee2e97396daa822a2514 (diff)
server: make rx goroutine reading from socket never sleep
Currently, the rx goroutine reading from socket (recvMessageloop funciton) sleeps if msgCh is full. The problem is that if the rx goroutine stops reading from a socket, keepalives are ignored, the holdtime on gobgp expires even if a peer properly sends keepalives. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/server/server.go b/server/server.go
index a24cea26..a7245198 100644
--- a/server/server.go
+++ b/server/server.go
@@ -20,6 +20,7 @@ import (
"fmt"
log "github.com/Sirupsen/logrus"
"github.com/armon/go-radix"
+ "github.com/eapache/channels"
api "github.com/osrg/gobgp/api"
"github.com/osrg/gobgp/config"
"github.com/osrg/gobgp/packet"
@@ -93,7 +94,7 @@ type BgpServer struct {
addedPeerCh chan config.Neighbor
deletedPeerCh chan config.Neighbor
updatedPeerCh chan config.Neighbor
- fsmincomingCh chan *FsmMsg
+ fsmincomingCh *channels.InfiniteChannel
fsmStateCh chan *FsmMsg
rpkiConfigCh chan []config.RpkiServer
@@ -296,7 +297,7 @@ func (server *BgpServer) Serve() {
}
}
- server.fsmincomingCh = make(chan *FsmMsg, 4096)
+ server.fsmincomingCh = channels.NewInfiniteChannel()
server.fsmStateCh = make(chan *FsmMsg, 4096)
var senderMsgs []*SenderMsg
@@ -465,8 +466,11 @@ func (server *BgpServer) Serve() {
peer := server.neighborMap[addr]
peer.conf = config
server.setPolicyByConfig(peer.ID(), config.ApplyPolicy)
- case e := <-server.fsmincomingCh:
- handleFsmMsg(e)
+ case e, ok := <-server.fsmincomingCh.Out():
+ if !ok {
+ continue
+ }
+ handleFsmMsg(e.(*FsmMsg))
case e := <-server.fsmStateCh:
handleFsmMsg(e)
case sCh <- firstMsg:
@@ -1180,6 +1184,7 @@ func (server *BgpServer) Shutdown() {
for _, p := range server.neighborMap {
p.fsm.adminStateCh <- ADMIN_STATE_DOWN
}
+ // TODO: call fsmincomingCh.Close()
}
func (server *BgpServer) UpdatePolicy(policy config.RoutingPolicy) {