mirror of
https://github.com/openlibrecommunity/olcrtc.git
synced 2026-06-02 06:23:37 +02:00
fix: close sessions before connections on shutdown
This commit is contained in:
@@ -388,15 +388,15 @@ func (c *Client) handleReconnect(ctx context.Context, cfg Config, cancel context
|
||||
if oldControlStop != nil {
|
||||
oldControlStop()
|
||||
}
|
||||
if oldControl != nil {
|
||||
_ = oldControl.Close()
|
||||
}
|
||||
if oldSess != nil {
|
||||
_ = oldSess.Close()
|
||||
}
|
||||
if oldConn != nil {
|
||||
_ = oldConn.Close()
|
||||
}
|
||||
if oldControl != nil {
|
||||
_ = oldControl.Close()
|
||||
}
|
||||
|
||||
// Server-side may still be tearing down its own session when our callback
|
||||
// fires — carriers don't guarantee reconnect callbacks are delivered to both
|
||||
@@ -587,6 +587,9 @@ func (c *Client) shutdown() {
|
||||
if controlStop != nil {
|
||||
controlStop()
|
||||
}
|
||||
if sess != nil {
|
||||
_ = sess.Close()
|
||||
}
|
||||
if conn != nil {
|
||||
_ = conn.Close()
|
||||
}
|
||||
@@ -596,9 +599,6 @@ func (c *Client) shutdown() {
|
||||
if control != nil {
|
||||
_ = control.Close()
|
||||
}
|
||||
if sess != nil {
|
||||
_ = sess.Close()
|
||||
}
|
||||
}
|
||||
|
||||
func setupCipher(keyHex string) (*crypto.Cipher, error) {
|
||||
|
||||
@@ -415,12 +415,12 @@ func (s *Server) closeSession() {
|
||||
if controlStop != nil {
|
||||
controlStop()
|
||||
}
|
||||
if conn != nil {
|
||||
_ = conn.Close()
|
||||
}
|
||||
if sess != nil {
|
||||
_ = sess.Close()
|
||||
}
|
||||
if conn != nil {
|
||||
_ = conn.Close()
|
||||
}
|
||||
if oldSID != "" {
|
||||
s.onClose(oldSID, "closed")
|
||||
}
|
||||
|
||||
@@ -98,6 +98,9 @@ func Run(ctx context.Context, cfg Config, run Runner) error {
|
||||
if err := runCycle(ctx, cfg, run, state, cycle, &lastErr); err != nil {
|
||||
return err
|
||||
}
|
||||
if ctx.Err() != nil {
|
||||
return nil //nolint:nilerr // context cancellation is normal supervisor shutdown
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user