| 43 | } |
| 44 | |
| 45 | int |
| 46 | ConnectingEntry::state_http_server_open(int event, void *data) |
| 47 | { |
| 48 | Dbg(dbg_ctl_http_connect, "entered inside ConnectingEntry::state_http_server_open"); |
| 49 | |
| 50 | switch (event) { |
| 51 | case NET_EVENT_OPEN: { |
| 52 | netvc = static_cast<NetVConnection *>(data); |
| 53 | UnixNetVConnection *vc = static_cast<UnixNetVConnection *>(netvc); |
| 54 | ink_release_assert(_pending_action == nullptr || _pending_action->continuation == vc->get_action()->continuation); |
| 55 | _pending_action = nullptr; |
| 56 | Dbg(dbg_ctl_http_connect, "ConnectingEntrysetting handler for connection handshake"); |
| 57 | // Just want to get a write-ready event so we know that the connection handshake is complete. |
| 58 | // The buffer we create will be handed over to the eventually created server session |
| 59 | _netvc_read_buffer = new_MIOBuffer(HTTP_SERVER_RESP_HDR_BUFFER_INDEX); |
| 60 | _netvc_reader = _netvc_read_buffer->alloc_reader(); |
| 61 | ink_release_assert(!connect_sms.empty()); |
| 62 | HttpSM *prime_connect_sm = *(connect_sms.begin()); |
| 63 | |
| 64 | // Perform a zero-byte read to ensure this function can be called back for |
| 65 | // VC_EVENT_READ_COMPLETE after the handshake is complete. |
| 66 | netvc->do_io_read(this, 0, _netvc_reader->mbuf); |
| 67 | int64_t nbytes = 1; |
| 68 | if (is_no_plugin_tunnel && prime_connect_sm->t_state.txn_conf->proxy_protocol_out >= 0) { |
| 69 | nbytes = do_outbound_proxy_protocol(_netvc_reader->mbuf, vc, ua_txn->get_netvc(), |
| 70 | prime_connect_sm->t_state.txn_conf->proxy_protocol_out); |
| 71 | } |
| 72 | netvc->do_io_write(this, nbytes, _netvc_reader); |
| 73 | netvc->set_inactivity_timeout(prime_connect_sm->get_server_connect_timeout()); |
| 74 | ink_release_assert(_pending_action == nullptr); |
| 75 | return 0; |
| 76 | } |
| 77 | case VC_EVENT_READ_COMPLETE: |
| 78 | case VC_EVENT_WRITE_READY: |
| 79 | case VC_EVENT_WRITE_COMPLETE: { |
| 80 | Dbg(dbg_ctl_http_connect, "Kick off %zd state machines waiting for origin", connect_sms.size()); |
| 81 | this->remove_entry(); |
| 82 | netvc->do_io_write(nullptr, 0, nullptr); |
| 83 | if (!connect_sms.empty()) { |
| 84 | auto prime_iter = connect_sms.rbegin(); |
| 85 | ink_release_assert(prime_iter != connect_sms.rend()); |
| 86 | PoolableSession *new_session = (*prime_iter)->create_server_session(*netvc, _netvc_read_buffer, _netvc_reader); |
| 87 | netvc = nullptr; |
| 88 | _netvc_read_buffer = nullptr; |
| 89 | |
| 90 | // Did we end up with a multiplexing session? |
| 91 | int count = 0; |
| 92 | if (new_session->is_multiplexing()) { |
| 93 | // Hand off to all queued up ConnectSM's. |
| 94 | while (!connect_sms.empty()) { |
| 95 | Dbg(dbg_ctl_http_connect, "ConnectingEntry Pass along CONNECT_EVENT_TXN %d", count++); |
| 96 | auto entry = connect_sms.begin(); |
| 97 | |
| 98 | SCOPED_MUTEX_LOCK(lock, (*entry)->mutex, this_ethread()); |
| 99 | (*entry)->handleEvent(CONNECT_EVENT_TXN, new_session); |
| 100 | connect_sms.erase(entry); |
| 101 | } |
| 102 | } else { |
nothing calls this directly
no test coverage detected