Files
mediamtx/internal/api/api_config_global.go
T
Alessandro RosandGitHub a56c635f8e fix deadlock when changing configuration through file and API (#6077) (#6101)
When changing configuration in parallel by editing the configuration
file and calling the API, the server could get into a deadlock that
prevented any further action. This is fixed.
2026-08-17 11:14:01 +00:00

34 lines
705 B
Go

package api //nolint:revive
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/conf/jsonwrapper"
)
func (a *API) onConfigGlobalGet(ctx *gin.Context) {
c := a.Parent.APIConfigSnapshot()
ctx.JSON(http.StatusOK, c.Global())
}
func (a *API) onConfigGlobalPatch(ctx *gin.Context) {
var c conf.OptionalGlobal
err := jsonwrapper.Decode(&customLimitReader{ctx.Request.Body, maxInboundConfigSize}, &c)
if err != nil {
a.writeError(ctx, http.StatusBadRequest, err)
return
}
err = a.Parent.APIConfigGlobalPatch(c)
if err != nil {
a.writeError(ctx, http.StatusBadRequest, err)
return
}
a.writeOK(ctx)
}