* fix webconn shutdown race

* make sure writePump returns promptly if readPump returns first

* fix app shutdown race

* minor improvement
Этот коммит содержится в:
Chris
2017-10-16 14:02:33 -07:00
коммит произвёл GitHub
родитель 868bd76f40
Коммит ce314425d1
3 изменённых файлов: 31 добавлений и 7 удалений

Просмотреть файл

@@ -59,7 +59,7 @@ func (a *App) NewWebConn(ws *websocket.Conn, session model.Session, t goi18n.Tra
UserId: session.UserId,
T: t,
Locale: locale,
endWritePump: make(chan struct{}, 1),
endWritePump: make(chan struct{}, 2),
pumpFinished: make(chan struct{}, 1),
}
@@ -111,13 +111,14 @@ func (c *WebConn) Pump() {
ch <- struct{}{}
}()
c.readPump()
c.endWritePump <- struct{}{}
<-ch
c.App.HubUnregister(c)
c.pumpFinished <- struct{}{}
}
func (c *WebConn) readPump() {
defer func() {
c.App.HubUnregister(c)
c.WebSocket.Close()
}()
c.WebSocket.SetReadLimit(model.SOCKET_MAX_MESSAGE_SIZE_KB)