Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions services/webdav/pkg/service/v0/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ var (
}
)

// register the WebDAV REPORT method with chi at package init time.
// chi.RegisterMethod mutates a package-global map in github.com/go-chi/chi/v5
// (methodMap) which is also read by (*node).setEndpoint during route insertion.
// When opencloud runs services concurrently via the suture supervisor, calling
// chi.RegisterMethod inside NewService races with route registration in other
// services (e.g. settings) and triggers a "concurrent map iteration and map
// write" runtime panic in chi/tree.go:setEndpoint. Doing it in init() runs
// before any service goroutine is spawned and is safe.
func init() {
chi.RegisterMethod("REPORT")
}

// Service defines the extension handlers.
type Service interface {
ServeHTTP(w http.ResponseWriter, r *http.Request)
Expand Down Expand Up @@ -93,9 +105,6 @@ func NewService(opts ...Option) (Service, error) {
svc.thumbnailsClient = nil
}

// register method with chi before any routing is set up
chi.RegisterMethod("REPORT")

m.Route(options.Config.HTTP.Root, func(r chi.Router) {

if !svc.config.DisablePreviews {
Expand Down