Commit c47d134
authored
x-pack/filebeat/input/http_endpoint: decouple shared server lifetime from individual inputs (#49415)
The http_endpoint input lets multiple inputs share a single HTTP
listener on the same host:port. The server's context was derived
from the creator input's cancellation context, causing two bugs:
1. Joiner deadlock: when only a joiner's context was cancelled,
its Run goroutine blocked forever on the server context because
it never monitored its own cancellation signal.
2. Creator kills everyone: when the creator was cancelled, the
shared server was closed, taking down all other inputs on the
same port even though they were still wanted.
Replace http.ServeMux with a mutable mux that supports dynamic
handler removal. Give the server an independent context tied to
its own lifetime rather than any single input's. Both creator and
joiner now select on their own cancellation and the server context,
deregistering cleanly when stopped. The server shuts down only
when the last input deregisters or the listener returns an error.
Each handler receives a per-input context derived from that input's
cancellation, so in-flight ACK waits abort before the pipeline
client is closed during deregistration.1 parent 641c324 commit c47d134
3 files changed
Lines changed: 796 additions & 87 deletions
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
0 commit comments