mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-20 02:00:05 -08:00
api, hls, metrics, pprof: always close HTTP listeners
due to a race condition, HTTP listeners could remain open even after the closure of a component.
This commit is contained in:
parent
3790af946f
commit
f25e14183d
4 changed files with 8 additions and 8 deletions
|
|
@ -189,6 +189,7 @@ type api struct {
|
|||
hlsServer apiHLSServer
|
||||
parent apiParent
|
||||
|
||||
ln net.Listener
|
||||
mutex sync.Mutex
|
||||
s *http.Server
|
||||
}
|
||||
|
|
@ -218,6 +219,7 @@ func newAPI(
|
|||
rtmpsServer: rtmpsServer,
|
||||
hlsServer: hlsServer,
|
||||
parent: parent,
|
||||
ln: ln,
|
||||
}
|
||||
|
||||
router := gin.New()
|
||||
|
|
@ -268,6 +270,7 @@ func newAPI(
|
|||
|
||||
func (a *api) close() {
|
||||
a.log(logger.Info, "listener is closing")
|
||||
a.ln.Close() // in case Shutdown() is called before Serve()
|
||||
a.s.Shutdown(context.Background())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue