Skip to content

Commit

Permalink
fix(server): add goroutine locks in rpc handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
sainnhe committed Jan 10, 2025
1 parent 6d967d1 commit 7aa6fbd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 7aa6fbd

Please sign in to comment.