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
|
|
@ -1,12 +1,12 @@
|
||||||
/**
|
/**
|
||||||
* Copyright 2023 ByteDance Inc.
|
* Copyright 2023 ByteDance Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
|
@ -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