#743 refactor to improve the performance

This commit is contained in:
smallnest
2022-07-11 20:46:40 +08:00
parent 5055993d67
commit adafbb9fa9
2 changed files with 5 additions and 2 deletions

View File

@@ -502,7 +502,10 @@ func (s *Server) serveConn(conn net.Conn) {
func (s *Server) processOneRequest(ctx *share.Context, req *protocol.Message, conn net.Conn, writeCh chan *[]byte) {
defer func() {
if r := recover(); r != nil {
log.Errorf("failed to handle the request: %v", r)
buf := make([]byte, 1024)
buf = buf[:runtime.Stack(buf, true)]
log.Errorf("failed to handle the request: %v stacks: %s", r, buf)
}
}()

View File

@@ -82,7 +82,7 @@ func WithValue(parent context.Context, key, val interface{}) *Context {
tags := make(map[interface{}]interface{})
tags[key] = val
return &Context{Context: parent, tags: tags}
return &Context{Context: parent, tags: tags, tagsLock: &sync.Mutex{}}
}
func WithLocalValue(ctx *Context, key, val interface{}) *Context {