diff --git a/server/server.go b/server/server.go index 025e493173..2d88d319af 100644 --- a/server/server.go +++ b/server/server.go @@ -45,6 +45,7 @@ import ( "github.com/cloudwego/kitex/pkg/rpcinfo" "github.com/cloudwego/kitex/pkg/serviceinfo" "github.com/cloudwego/kitex/pkg/stats" + "github.com/cloudwego/kitex/pkg/utils" ) // Server is an abstraction of an RPC server. It accepts connections and dispatches them to the service @@ -377,6 +378,8 @@ func (s *server) buildCoreMiddleware() endpoint.Middleware { func (s *server) invokeHandleEndpoint() endpoint.Endpoint { return func(ctx context.Context, args, resp interface{}) (err error) { + utils.GoroutineLock() + defer utils.GoroutineUnlock() ri := rpcinfo.GetRPCInfo(ctx) methodName := ri.Invocation().MethodName() serviceName := ri.Invocation().ServiceName()