(t *testing.T)
| 196 | } |
| 197 | |
| 198 | func TestYieldAfterStop(t *testing.T) { |
| 199 | s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { |
| 200 | ret := new(dns.Msg) |
| 201 | ret.SetReply(r) |
| 202 | w.WriteMsg(ret) |
| 203 | }) |
| 204 | defer s.Close() |
| 205 | |
| 206 | tr := newTransport("TestYieldAfterStop", s.Addr) |
| 207 | tr.Start() |
| 208 | |
| 209 | // Dial a connection while transport is running |
| 210 | c1, _, err := tr.Dial("udp") |
| 211 | if err != nil { |
| 212 | t.Fatalf("Failed to dial: %v", err) |
| 213 | } |
| 214 | |
| 215 | // Stop the transport |
| 216 | tr.Stop() |
| 217 | |
| 218 | // Give cleanup goroutine time to exit |
| 219 | time.Sleep(50 * time.Millisecond) |
| 220 | |
| 221 | // Yield the connection after stop - should close it, not pool it |
| 222 | tr.Yield(c1) |
| 223 | |
| 224 | // Verify pool is empty (connection was closed, not added) |
| 225 | tr.mu.Lock() |
| 226 | poolSize := len(tr.conns[typeUDP]) |
| 227 | tr.mu.Unlock() |
| 228 | |
| 229 | if poolSize != 0 { |
| 230 | t.Errorf("Expected pool size 0 after stop, got %d", poolSize) |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | // TestMaxAgeExpireByCreation verifies that a connection is rejected when its |
| 235 | // creation time exceeds max_age, even if it was recently yielded (fresh used time). |
nothing calls this directly
no test coverage detected
searching dependent graphs…