修复了因为锁的原因不能操作数据库的问题

This commit is contained in:
johlanse 2022-08-19 08:36:29 +08:00
parent 4e9cd9a71a
commit 6d67d64b80
1 changed files with 4 additions and 1 deletions

View File

@ -180,7 +180,7 @@ func Find(uid string) *User {
*/
func AddUser(user *User) error {
lock.Lock()
defer lock.Unlock()
ping()
count := UserCount(user.UID)
if count < 1 {
@ -188,10 +188,13 @@ func AddUser(user *User) error {
if err != nil {
log.Errorln("数据库插入失败")
log.Errorln(err.Error())
lock.Unlock()
return err
}
lock.Unlock()
return err
}
lock.Unlock()
err := UpdateUser(user)
if err != nil {
return err