connection_handle_write_impl() should handle orconns properly if getsockopt() fails
The function connection_handle_write_impl() in connection.c contains this code:
/* Sometimes, "writable" means "connected". */
if (connection_state_is_connecting(conn)) {
if (getsockopt(conn->s, SOL_SOCKET, SO_ERROR, (void*)&e, &len) < 0) {
log_warn(LD_BUG, "getsockopt() syscall failed");
if (CONN_IS_EDGE(conn))
connection_edge_end_errno(TO_EDGE_CONN(conn));
connection_mark_for_close(conn);
return -1;
}
This might close an orconn out from under the channel layer improperly. It should test for orconns and call connection_or_connect_failed() in that case rather than connection_mark_for_close() directly. Created pursuant to connection_mark_for_close() audit task legacy/trac#7472 (moved).