Browse Source

#1494

fix
tags/v1.22.2.2^2
chenyifan01 3 years ago
parent
commit
8f59dc257c
2 changed files with 4 additions and 2 deletions
  1. +2
    -2
      modules/redis/redis_lock/lock.go
  2. +2
    -0
      routers/api/v1/api.go

+ 2
- 2
modules/redis/redis_lock/lock.go View File

@@ -18,14 +18,14 @@ func (lock *DistributeLock) Lock(lockKey string, expireTime time.Duration) bool
}

func (lock *DistributeLock) LockWithWait(lockKey string, expireTime time.Duration, waitTime time.Duration) bool {
start := time.Now().UnixMilli()
start := time.Now().Unix() * 1000
duration := waitTime.Milliseconds()
for {
isOk, _ := redis_client.Setnx(lockKey, "", expireTime)
if isOk {
return true
}
if time.Now().UnixMilli()-start > duration {
if time.Now().Unix()*1000-start > duration {
return false
}
time.Sleep(50 * time.Millisecond)


+ 2
- 0
routers/api/v1/api.go View File

@@ -999,6 +999,8 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/from_wechat", func() {
m.Get("/event", authentication.ValidEventSource)
m.Post("/event", authentication.AcceptWechatEvent)
m.Get("/prd/event", authentication.ValidEventSource)
m.Post("/prd/event", authentication.AcceptWechatEvent)
})
}, securityHeaders(), context.APIContexter(), sudo())
}


Loading…
Cancel
Save