Auto-initialize per-addr keys in SMTPErrors
This commit is contained in:
		
							parent
							
								
									c35e01f640
								
							
						
					
					
						commit
						25ebafa427
					
				| @ -133,12 +133,8 @@ type SMTPRunner struct { | ||||
| 
 | ||||
| func (r SMTPRunner) smtp_error(err error) { | ||||
| 	key := net.JoinHostPort(r.addr, r.port) | ||||
| 	errors, exists := r.tk.SMTPErrors[key] | ||||
| 	if exists { | ||||
| 		r.tk.SMTPErrors[key] = append(errors, tracex.NewFailure(err)) | ||||
| 	} else { | ||||
| 		r.tk.SMTPErrors[key] = []*string{tracex.NewFailure(err)} | ||||
| 	} | ||||
| 	// Key is initialized in conn() no need to check here | ||||
| 	r.tk.SMTPErrors[key] = append(r.tk.SMTPErrors[key], tracex.NewFailure(err)) | ||||
| } | ||||
| 
 | ||||
| func (r SMTPRunner) resolve(host string) ([]string, bool) { | ||||
| @ -156,7 +152,13 @@ func (r SMTPRunner) resolve(host string) ([]string, bool) { | ||||
| } | ||||
| 
 | ||||
| func (r SMTPRunner) conn(addr string) (net.Conn, bool) { | ||||
| 	// Initialize addr field and corresponding errors in TestKeys | ||||
| 	r.addr = addr | ||||
| 	if r.tk.SMTPErrors == nil { | ||||
| 		r.tk.SMTPErrors = make(map[string][]*string) | ||||
| 	} | ||||
| 	r.tk.SMTPErrors[net.JoinHostPort(addr, r.port)] = []*string{} | ||||
| 
 | ||||
| 	dialer := r.trace.NewDialerWithoutResolver(r.logger) | ||||
| 	conn, err := dialer.DialContext(r.ctx, "tcp", net.JoinHostPort(r.addr, r.port)) | ||||
| 	r.tk.TCPConnect = append(r.tk.TCPConnect, r.trace.TCPConnects()...) | ||||
| @ -243,8 +245,6 @@ func (m Measurer) Run( | ||||
| 	} | ||||
| 
 | ||||
| 	tk := new(TestKeys) | ||||
| 	// TODO: make it so we don't forget it | ||||
| 	tk.SMTPErrors = make(map[string][]*string) | ||||
| 	measurement.TestKeys = tk | ||||
| 
 | ||||
| 	ctx, cancel := context.WithTimeout(ctx, 60*time.Second) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user