This commit is contained in:
aozhiwei 2021-08-12 15:48:30 +08:00
parent 9790bfdd6e
commit 73e720ae91

View File

@ -79,12 +79,14 @@ func (this *HttpServer) dispatchRequest(c *Context) {
handle := this.getHandle(handleName) handle := this.getHandle(handleName)
if handle != nil { if handle != nil {
beginTick := q5.GetTickCount() beginTick := q5.GetTickCount()
defer func() {
endTick := q5.GetTickCount()
if oldVal := atomic.LoadInt64(&this.maxHandleTime); beginTick - endTick > oldVal {
atomic.CompareAndSwapInt64(&this.maxHandleTime, oldVal, endTick - beginTick)
}
atomic.AddInt64(&this.okTimes, 1)
}()
handle(c) handle(c)
endTick := q5.GetTickCount()
if oldVal := atomic.LoadInt64(&this.maxHandleTime); beginTick - endTick > oldVal {
atomic.CompareAndSwapInt64(&this.maxHandleTime, oldVal, endTick - beginTick)
}
atomic.AddInt64(&this.okTimes, 1)
} else { } else {
c.Response(`{"errcode":404, "errmsg":"接口不存在"}`) c.Response(`{"errcode":404, "errmsg":"接口不存在"}`)
atomic.AddInt64(&this.pageNotFoundTimes, 1) atomic.AddInt64(&this.pageNotFoundTimes, 1)