mirror of https://github.com/grpc/grpc-go.git
				
				
				
			resolver_wrapper: remove serializerScheduleLocked; the lock is unnecessary (#6803)
This commit is contained in:
		
							parent
							
								
									914ca65947
								
							
						
					
					
						commit
						7935c4f759
					
				|  | @ -140,14 +140,6 @@ func (ccr *ccResolverWrapper) close() { | ||||||
| 	go r.Close() | 	go r.Close() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // serializerScheduleLocked is a convenience method to schedule a function to be
 |  | ||||||
| // run on the serializer while holding ccr.mu.
 |  | ||||||
| func (ccr *ccResolverWrapper) serializerScheduleLocked(f func(context.Context)) { |  | ||||||
| 	ccr.mu.Lock() |  | ||||||
| 	ccr.serializer.Schedule(f) |  | ||||||
| 	ccr.mu.Unlock() |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // UpdateState is called by resolver implementations to report new state to gRPC
 | // UpdateState is called by resolver implementations to report new state to gRPC
 | ||||||
| // which includes addresses and service config.
 | // which includes addresses and service config.
 | ||||||
| func (ccr *ccResolverWrapper) UpdateState(s resolver.State) error { | func (ccr *ccResolverWrapper) UpdateState(s resolver.State) error { | ||||||
|  | @ -181,7 +173,7 @@ func (ccr *ccResolverWrapper) UpdateState(s resolver.State) error { | ||||||
| // ReportError is called by resolver implementations to report errors
 | // ReportError is called by resolver implementations to report errors
 | ||||||
| // encountered during name resolution to gRPC.
 | // encountered during name resolution to gRPC.
 | ||||||
| func (ccr *ccResolverWrapper) ReportError(err error) { | func (ccr *ccResolverWrapper) ReportError(err error) { | ||||||
| 	ccr.serializerScheduleLocked(func(_ context.Context) { | 	ccr.serializer.Schedule(func(_ context.Context) { | ||||||
| 		channelz.Warningf(logger, ccr.channelzID, "ccResolverWrapper: reporting error to cc: %v", err) | 		channelz.Warningf(logger, ccr.channelzID, "ccResolverWrapper: reporting error to cc: %v", err) | ||||||
| 		ccr.cc.updateResolverState(resolver.State{}, err) | 		ccr.cc.updateResolverState(resolver.State{}, err) | ||||||
| 	}) | 	}) | ||||||
|  | @ -190,7 +182,7 @@ func (ccr *ccResolverWrapper) ReportError(err error) { | ||||||
| // NewAddress is called by the resolver implementation to send addresses to
 | // NewAddress is called by the resolver implementation to send addresses to
 | ||||||
| // gRPC.
 | // gRPC.
 | ||||||
| func (ccr *ccResolverWrapper) NewAddress(addrs []resolver.Address) { | func (ccr *ccResolverWrapper) NewAddress(addrs []resolver.Address) { | ||||||
| 	ccr.serializerScheduleLocked(func(_ context.Context) { | 	ccr.serializer.Schedule(func(_ context.Context) { | ||||||
| 		ccr.addChannelzTraceEvent(resolver.State{Addresses: addrs, ServiceConfig: ccr.curState.ServiceConfig}) | 		ccr.addChannelzTraceEvent(resolver.State{Addresses: addrs, ServiceConfig: ccr.curState.ServiceConfig}) | ||||||
| 		ccr.curState.Addresses = addrs | 		ccr.curState.Addresses = addrs | ||||||
| 		ccr.cc.updateResolverState(ccr.curState, nil) | 		ccr.cc.updateResolverState(ccr.curState, nil) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue