diff --git a/runtime/http.go b/runtime/http.go index f006869..84ecaf7 100644 --- a/runtime/http.go +++ b/runtime/http.go @@ -38,7 +38,9 @@ func serve(host string) error { func (*httpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Ensures the server(runtime) doesn't panic due to the execution of - // panic failpoints during processing of the HTTP request + // panic failpoints during processing of the HTTP request, as the + // sender of the HTTP request should not be affected by the execution + // of the panic failpoints and crash as a side effect panicMu.Lock() defer panicMu.Unlock() diff --git a/runtime/runtime.go b/runtime/runtime.go index 3230fb6..f6e1589 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -25,11 +25,17 @@ var ( ErrNoExist = fmt.Errorf("failpoint: failpoint does not exist") ErrDisabled = fmt.Errorf("failpoint: failpoint is disabled") - failpoints map[string]*Failpoint + failpoints map[string]*Failpoint + // failpointsMu protects the failpoints map, preventing concurrent + // accesses during commands such as Enabling and Disabling failpointsMu sync.RWMutex envTerms map[string]string + // panicMu (panic mutex) ensures that the action of panic failpoints + // and serving of the HTTP requests won't be executed at the same time, + // avoiding the possibility that the server runtime panics during processing + // requests panicMu sync.Mutex )