mirror of
https://github.com/caddyserver/caddy.git
synced 2025-10-19 15:53:17 +00:00
replacer: use RWMutex to protect static provider (#6184)
This commit is contained in:
parent
97a56d860a
commit
e7336cc3bf
2 changed files with 18 additions and 3 deletions
|
@ -19,6 +19,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -238,6 +239,7 @@ func TestReplacerSet(t *testing.T) {
|
|||
|
||||
func TestReplacerReplaceKnown(t *testing.T) {
|
||||
rep := Replacer{
|
||||
mapMutex: &sync.RWMutex{},
|
||||
providers: []ReplacerFunc{
|
||||
// split our possible vars to two functions (to test if both functions are called)
|
||||
func(key string) (val any, ok bool) {
|
||||
|
@ -310,6 +312,7 @@ func TestReplacerReplaceKnown(t *testing.T) {
|
|||
|
||||
func TestReplacerDelete(t *testing.T) {
|
||||
rep := Replacer{
|
||||
mapMutex: &sync.RWMutex{},
|
||||
static: map[string]any{
|
||||
"key1": "val1",
|
||||
"key2": "val2",
|
||||
|
@ -463,5 +466,6 @@ func testReplacer() Replacer {
|
|||
return Replacer{
|
||||
providers: make([]ReplacerFunc, 0),
|
||||
static: make(map[string]any),
|
||||
mapMutex: &sync.RWMutex{},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue