mirror of
https://github.com/jech/galene.git
synced 2024-11-26 02:25:58 +01:00
Protect webClient.actions with its own mutex.
(*webClient).action may be called with the group mutex taken, and therefore cannot take the client mutex.
This commit is contained in:
parent
0e85552ea7
commit
39976d6d0d
1 changed files with 12 additions and 8 deletions
|
@ -67,6 +67,10 @@ type webClient struct {
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
down map[string]*rtpDownConnection
|
down map[string]*rtpDownConnection
|
||||||
up map[string]*rtpUpConnection
|
up map[string]*rtpUpConnection
|
||||||
|
|
||||||
|
// action may be called with the group mutex taken, and therefore
|
||||||
|
// actions needs to use its own mutex.
|
||||||
|
actionMu sync.Mutex
|
||||||
actions []interface{}
|
actions []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -948,10 +952,10 @@ func clientLoop(c *webClient, ws *websocket.Conn) error {
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
case <-c.actionCh:
|
case <-c.actionCh:
|
||||||
c.mu.Lock()
|
c.actionMu.Lock()
|
||||||
actions := c.actions
|
actions := c.actions
|
||||||
c.actions = nil
|
c.actions = nil
|
||||||
c.mu.Unlock()
|
c.actionMu.Unlock()
|
||||||
for _, a := range actions {
|
for _, a := range actions {
|
||||||
err := handleAction(c, a)
|
err := handleAction(c, a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1759,10 +1763,10 @@ func (c *webClient) Warn(oponly bool, message string) error {
|
||||||
var ErrClientDead = errors.New("client is dead")
|
var ErrClientDead = errors.New("client is dead")
|
||||||
|
|
||||||
func (c *webClient) action(a interface{}) error {
|
func (c *webClient) action(a interface{}) error {
|
||||||
c.mu.Lock()
|
c.actionMu.Lock()
|
||||||
empty := len(c.actions) == 0
|
empty := len(c.actions) == 0
|
||||||
c.actions = append(c.actions, a)
|
c.actions = append(c.actions, a)
|
||||||
c.mu.Unlock()
|
c.actionMu.Unlock()
|
||||||
|
|
||||||
if empty {
|
if empty {
|
||||||
select {
|
select {
|
||||||
|
|
Loading…
Reference in a new issue