mirror of
https://github.com/jech/galene.git
synced 2024-12-22 23:35:46 +01:00
Ensure that replaced down tracks are closed even on failure.
Thanks to Ludovic Rateau.
This commit is contained in:
parent
9b8d868647
commit
053067548a
1 changed files with 33 additions and 33 deletions
|
@ -225,7 +225,7 @@ func delUpConn(c *webClient, id string, userId string, push bool) error {
|
|||
return ErrUserMismatch
|
||||
}
|
||||
|
||||
replace := conn.getReplace(true)
|
||||
replace := conn.getReplace(false)
|
||||
|
||||
delete(c.up, id)
|
||||
g := c.group
|
||||
|
@ -976,45 +976,45 @@ func handleAction(c *webClient, a interface{}) error {
|
|||
tracks = requestedTracks(c, override, a.conn, a.tracks)
|
||||
}
|
||||
|
||||
if len(tracks) == 0 {
|
||||
closeDownConn(c, a.id, "")
|
||||
if a.replace != "" {
|
||||
closeDownConn(
|
||||
c, a.replace, "",
|
||||
)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
down, _, err := addDownConn(c, a.conn)
|
||||
if err != nil {
|
||||
if err == os.ErrClosed {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
done, err := replaceTracks(down, tracks, a.conn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !done {
|
||||
return nil
|
||||
}
|
||||
if a.replace != "" {
|
||||
err := delDownConn(c, a.replace)
|
||||
if err != nil {
|
||||
log.Printf("Replace: %v", err)
|
||||
}
|
||||
}
|
||||
err = negotiate(
|
||||
c, down, false, a.replace,
|
||||
)
|
||||
|
||||
if len(tracks) == 0 {
|
||||
closeDownConn(c, a.id, "")
|
||||
if a.replace != "" {
|
||||
closeDownConn(c, a.replace, "")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
down, _, err := addDownConn(c, a.conn)
|
||||
if err != nil {
|
||||
log.Printf(
|
||||
"Negotiation failed: %v",
|
||||
err)
|
||||
closeDownConn(c, down.id,
|
||||
"negotiation failed")
|
||||
if a.replace != "" {
|
||||
closeDownConn(c, a.replace, "")
|
||||
}
|
||||
if err == os.ErrClosed {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
done, err := replaceTracks(down, tracks, a.conn)
|
||||
if err != nil || !done {
|
||||
if a.replace != "" {
|
||||
closeDownConn(c, a.replace, "")
|
||||
}
|
||||
return err
|
||||
}
|
||||
err = negotiate(c, down, false, a.replace)
|
||||
if err != nil {
|
||||
log.Printf("Negotiation failed: %v", err)
|
||||
if a.replace != "" {
|
||||
closeDownConn(c, a.replace, "")
|
||||
}
|
||||
closeDownConn(c, down.id, "negotiation failed")
|
||||
}
|
||||
case requestConnsAction:
|
||||
g := c.group
|
||||
|
|
Loading…
Reference in a new issue