From 8b7c7b6de39adb21d09b4c24b8ed0fd1288e8924 Mon Sep 17 00:00:00 2001 From: "duanyi.aster" Date: Wed, 30 Oct 2024 12:18:17 +0800 Subject: [PATCH] test --- loader/register_tango.go | 1 + loader/register_test.go | 15 ++++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/loader/register_tango.go b/loader/register_tango.go index 1c1c14fce..08abfb5a8 100644 --- a/loader/register_tango.go +++ b/loader/register_tango.go @@ -29,5 +29,6 @@ var pluginsMu sync.Mutex func registerModule(mod *moduledata) { pluginsMu.Lock() defer pluginsMu.Unlock() + lastmoduledatap.next = mod lastmoduledatap = mod } diff --git a/loader/register_test.go b/loader/register_test.go index eb9b964a9..fcf63d5eb 100644 --- a/loader/register_test.go +++ b/loader/register_test.go @@ -1,5 +1,3 @@ -// +build !bytedance_tango - /* * Copyright 2023 ByteDance Inc. * @@ -23,17 +21,16 @@ import ( "sync" ) -func Test_registerModuleLockFree(t *testing.T) { - n, parallel := 1000, 8 - head := moduledata{} - tail := &head +func Test_registerModuleRace(t *testing.T) { + n, parallel := 100, 8 + s := &moduledata{} + registerModule(s) wg := sync.WaitGroup{} wg.Add(parallel) filler := func(n int) { defer wg.Done() for i := 0; i < n; i++ { - m := &moduledata{} - registerModuleLockFree(&tail, m) + registerModule(&moduledata{}) } } for i := 0; i < parallel; i++ { @@ -41,7 +38,7 @@ func Test_registerModuleLockFree(t *testing.T) { } wg.Wait() i := 0 - for p := head.next; p != nil; p = p.next { + for p := s.next; p != nil; p = p.next { i += 1 } if i != parallel * n {