Thanks for the PR!
I would suggest to add a new field to `tcp_connection` structure, like `event`, which is set to the event type of closing the tcp connection, so what was removed by current PR:
``` - if (errno == ETIMEDOUT) { - tcp_emit_closed_event(c, TCP_CLOSED_TIMEOUT); - } else if (errno == ECONNRESET) { - tcp_emit_closed_event(c, TCP_CLOSED_RESET); - } ```
becomes like:
``` if (errno == ETIMEDOUT) { c->event = TCP_CLOSED_TIMEOUT; } else if (errno == ECONNRESET) { c->event = TCP_CLOSED_RESET; } ```
Same in other similar cases.
Then, when calling the emit function, if the `event` field is set, then it is used.