mirror of https://github.com/grpc/grpc-go.git
				
				
				
			transport: implement GoString on Stream (#1167)
So context.String() won't race when printing %#v. It is not thread-safe to call context.String() on any context with a stream value since valueCtx will use %#v to access all of the Stream fields without holding a lock. Instead, print the Stream's pointer and method for its GoString.
This commit is contained in:
		
							parent
							
								
									9f9c190692
								
							
						
					
					
						commit
						087f3d6e02
					
				|  | @ -341,6 +341,12 @@ func (s *Stream) finish(st *status.Status) { | |||
| 	close(s.done) | ||||
| } | ||||
| 
 | ||||
| // GoString is implemented by Stream so context.String() won't
 | ||||
| // race when printing %#v.
 | ||||
| func (s *Stream) GoString() string { | ||||
| 	return fmt.Sprintf("<stream: %p, %v>", s, s.method) | ||||
| } | ||||
| 
 | ||||
| // The key to save transport.Stream in the context.
 | ||||
| type streamKey struct{} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue