Browse Source
Merge pull request #481 from songzhibin97/gva_gormv2_dev
fix casbin datarace
main
奇淼(piexlmax
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
5 additions and
2 deletions
-
server/service/sys_casbin.go
|
@ -93,6 +93,7 @@ func ClearCasbin(v int, p ...string) bool { |
|
|
var ( |
|
|
var ( |
|
|
e *casbin.Enforcer |
|
|
e *casbin.Enforcer |
|
|
once sync.Once |
|
|
once sync.Once |
|
|
|
|
|
eLock sync.Mutex |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
func Casbin() *casbin.Enforcer { |
|
|
func Casbin() *casbin.Enforcer { |
|
@ -101,7 +102,9 @@ func Casbin() *casbin.Enforcer { |
|
|
e, _ = casbin.NewEnforcer(global.GVA_CONFIG.Casbin.ModelPath, a) |
|
|
e, _ = casbin.NewEnforcer(global.GVA_CONFIG.Casbin.ModelPath, a) |
|
|
e.AddFunction("ParamsMatch", ParamsMatchFunc) |
|
|
e.AddFunction("ParamsMatch", ParamsMatchFunc) |
|
|
}) |
|
|
}) |
|
|
|
|
|
eLock.Lock() |
|
|
_ = e.LoadPolicy() |
|
|
_ = e.LoadPolicy() |
|
|
|
|
|
eLock.Unlock() |
|
|
return e |
|
|
return e |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|