maskit opened a new pull request, #13954:
URL: https://github.com/apache/trafficserver/pull/13954

   ## Why
   
   `ReadWriteEventIO::process_event()` calls 
`NetEvent::set_error_from_socket()` for every poll event that carries an error 
or hang-up flag, and `set_error_from_socket()` stored `getsockopt(SO_ERROR)` 
into `NetEvent::error` unconditionally. Reading `SO_ERROR` clears it.
   
   On kqueue, a socket error is reported on each registered filter. For a 
non-blocking connect to a refused port, a single poll returns a `EVFILT_WRITE` 
event and a `EVFILT_READ` event, both with `EV_EOF` and `fflags` = 
`ECONNREFUSED`. The first call to `set_error_from_socket()` recorded 
`ECONNREFUSED`; the second read 0 and overwrote it. `net_write_io()` then saw 
no error and signalled `VC_EVENT_WRITE_READY`, so `state_raw_http_server_open` 
reported the tunnel as established and a CONNECT to a refused port got a 200 
instead of a 502. `connect_handshake` fails on macOS for this reason.
   
   Edge-triggered epoll reports one combined event per socket, so 
`set_error_from_socket()` runs once and Linux is unaffected.
   
   ## Change
   
   Read `SO_ERROR` into a local and record it only when `getsockopt()` succeeds 
and the value is non-zero, so a later event in the same poll cannot erase an 
error that an earlier one recorded. `set_error_from_socket()` is the only 
writer of `NetEvent::error`, and readers only test it through `has_error()`.
   
   ## Validation
   
   On macOS with a BoringSSL build:
   
   - A standalone kqueue program that registers both filters with `EV_CLEAR`, 
as `NetHandler::startIO()` does, and connects to a closed loopback port shows 
both events in one poll with `EV_EOF` and `ECONNREFUSED`, and `SO_ERROR` 
reading 0 once it has been read.
   - `connect_handshake` passes; it got a 200 before this change.
   - The TLS, SSL, CONNECT, tunnel, PROXY protocol and timeout urtests show no 
regressions.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to