Skip to content

Commit

Permalink
change the order of grpc shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Sep 22, 2018
1 parent a486d39 commit c7805de
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion server/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (c *Cluster) Master(msg *ClusterReq, rejected *bool) error {
return nil
}

sess, _ = globals.sessionStore.Create(node, msg.Sess.Sid)
sess, _ = globals.sessionStore.NewSession(node, msg.Sess.Sid)
go sess.rpcWriteLoop()
}

Expand Down
2 changes: 1 addition & 1 deletion server/hdl_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (sess *Session) closeGrpc() {

// Equivalent of starting a new session and a read loop in one
func (*grpcNodeServer) MessageLoop(stream pbx.Node_MessageLoopServer) error {
sess, _ := globals.sessionStore.Create(stream, "")
sess, _ := globals.sessionStore.NewSession(stream, "")

defer func() {
sess.closeGrpc()
Expand Down
2 changes: 1 addition & 1 deletion server/hdl_longpoll.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func serveLongPoll(wrt http.ResponseWriter, req *http.Request) {
if sid == "" {
// New session
var count int
sess, count = globals.sessionStore.Create(wrt, "")
sess, count = globals.sessionStore.NewSession(wrt, "")
log.Println("lp: session started", sess.sid, count)
wrt.WriteHeader(http.StatusCreated)
pkt := NoErrCreated(req.FormValue("id"), "", now)
Expand Down
2 changes: 1 addition & 1 deletion server/hdl_websock.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func serveWebSocket(wrt http.ResponseWriter, req *http.Request) {
return
}

sess, count := globals.sessionStore.Create(ws, "")
sess, count := globals.sessionStore.NewSession(ws, "")

log.Println("ws: session started", sess.sid, count)

Expand Down
6 changes: 3 additions & 3 deletions server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ loop:
// Shutdown local cluster node, if it's a part of a cluster.
globals.cluster.shutdown()

// Terminate plugin connections
pluginsShutdown()

// Shutdown gRPC server, if one is configured
if globals.grpcServer != nil {
globals.grpcServer.GracefulStop()
}

// Terminate plugin connections
pluginsShutdown()

// Shutdown the hub. The hub will shutdown topics
hubdone := make(chan bool)
globals.hub.shutdown <- hubdone
Expand Down
2 changes: 1 addition & 1 deletion server/sessionstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type SessionStore struct {
}

// Create creates a new session and adds it to store.
func (ss *SessionStore) Create(conn interface{}, sid string) (*Session, int) {
func (ss *SessionStore) NewSession(conn interface{}, sid string) (*Session, int) {
var s Session

s.sid = sid
Expand Down

0 comments on commit c7805de

Please sign in to comment.