Files
mediamtx/internal/api/api_config_pathdefaults.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
725 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) onConfigPathDefaultsGet(ctx *gin.Context) {
c := a.Parent.APIConfigSnapshot()
ctx.JSON(http.StatusOK, c.PathDefaults)
}
func (a *API) onConfigPathDefaultsPatch(ctx *gin.Context) {
var p conf.OptionalPath
err := jsonwrapper.Decode(&customLimitReader{ctx.Request.Body, maxInboundConfigSize}, &p)
if err != nil {
a.writeError(ctx, http.StatusBadRequest, err)
return
}
err = a.Parent.APIConfigPathDefaultsPatch(p)
if err != nil {
a.writeError(ctx, http.StatusBadRequest, err)
return
}
a.writeOK(ctx)
}