We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
func (server *Server) handleRequest(cc codec.Codec, req *request, sendMutex *sync.Mutex, wg *sync.WaitGroup, timeout time.Duration) { defer wg.Done() finished := make(chan struct{}) var timeoutFlag int32 go func() { defer func() { close(finished) }() err := req.svc.call(req.mtype, req.argv, req.replyv) // 执行出错 if err != nil { req.h.Error = err.Error() server.sendResponse(cc, req.h, invalidRequest, sendMutex) return } // 超时 if atomic.LoadInt32(&timeoutFlag) == 1 { req.h.Error = "server handle timeout" server.sendResponse(cc, req.h, invalidRequest, sendMutex) return } server.sendResponse(cc, req.h, req.replyv.Interface(), sendMutex) }() // 没有超时控制 if timeout == 0 { <-finished return } // 有超时控制 select { case <-time.After(timeout): atomic.StoreInt32(&timeoutFlag, 1) return case <-finished: return } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: