fix: pluginMap uses sync.Map to avoid data race

This commit is contained in:
徐聪
2022-08-01 17:04:39 +08:00
parent 44e844829d
commit c5a0a0fc27
4 changed files with 19 additions and 14 deletions

View File

@@ -17,6 +17,7 @@ import (
"github.com/rs/zerolog/log"
"golang.org/x/net/http2"
"github.com/httprunner/funplugin"
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
)
@@ -188,11 +189,12 @@ func (r *HRPRunner) Run(testcases ...ITestCase) error {
// quit all plugins
defer func() {
if len(pluginMap) > 0 {
for _, plugin := range pluginMap {
pluginMap.Range(func(key, value interface{}) bool {
if plugin, ok := value.(funplugin.IPlugin); ok {
plugin.Quit()
}
}
return true
})
}()
var runErr error