mirror of
https://github.com/ii64/sonic.git
synced 2026-06-23 18:06:44 +08:00
fix:(loader) add mutex lock for registerModule (#388)
This commit is contained in:
parent
114b8168d4
commit
ddd5cd6c12
1 changed files with 9 additions and 4 deletions
|
|
@ -17,16 +17,21 @@
|
||||||
package loader
|
package loader
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ `unsafe`
|
`sync`
|
||||||
|
_ `unsafe`
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:linkname lastmoduledatap runtime.lastmoduledatap
|
//go:linkname lastmoduledatap runtime.lastmoduledatap
|
||||||
//goland:noinspection GoUnusedGlobalVariable
|
//goland:noinspection GoUnusedGlobalVariable
|
||||||
var lastmoduledatap *moduledata
|
var lastmoduledatap *moduledata
|
||||||
|
|
||||||
|
var moduledataMux sync.Mutex
|
||||||
|
|
||||||
func registerModule(mod *moduledata) {
|
func registerModule(mod *moduledata) {
|
||||||
|
moduledataMux.Lock()
|
||||||
lastmoduledatap.next = mod
|
lastmoduledatap.next = mod
|
||||||
lastmoduledatap = mod
|
lastmoduledatap = mod
|
||||||
|
moduledataMux.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:linkname moduledataverify1 runtime.moduledataverify1
|
//go:linkname moduledataverify1 runtime.moduledataverify1
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue