From e5ef118127e4c9728570698674e29e253137f859 Mon Sep 17 00:00:00 2001 From: Aaron Canary Date: Tue, 12 May 2020 10:37:01 -0500 Subject: [PATCH] Accept handling VIO events Keeping the VIO continuation set at all times to prevent connection leakage. --- proxy/ProtocolProbeSessionAccept.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/proxy/ProtocolProbeSessionAccept.cc b/proxy/ProtocolProbeSessionAccept.cc index ed23291fe07..d2fd1ca3304 100644 --- a/proxy/ProtocolProbeSessionAccept.cc +++ b/proxy/ProtocolProbeSessionAccept.cc @@ -66,7 +66,8 @@ struct ProtocolProbeTrampoline : public Continuation, public ProtocolProbeSessio { VIO *vio; NetVConnection *netvc; - ProtoGroupKey key = N_PROTO_GROUPS; // use this as an invalid value. + SessionAccept *acceptor = nullptr; + ProtoGroupKey key = N_PROTO_GROUPS; // use this as an invalid value. vio = static_cast(edata); netvc = static_cast(vio->vc_server); @@ -136,15 +137,17 @@ struct ProtocolProbeTrampoline : public Continuation, public ProtocolProbeSessio key = PROTO_HTTP; } - netvc->do_io_read(nullptr, 0, nullptr); // Disable the read IO that we started. - - if (probeParent->endpoint[key] == nullptr) { + acceptor = probeParent->endpoint[key]; + if (acceptor == nullptr) { Warning("Unregistered protocol type %d", key); goto done; } + // Disable the read IO that we started. + netvc->do_io_read(acceptor, 0, nullptr); + // Directly invoke the session acceptor, letting it take ownership of the input buffer. - if (!probeParent->endpoint[key]->accept(netvc, this->iobuf, reader)) { + if (!acceptor->accept(netvc, this->iobuf, reader)) { // IPAllow check fails in XxxSessionAccept::accept() if false returned. goto done; } @@ -181,7 +184,7 @@ ProtocolProbeSessionAccept::mainEvent(int event, void *data) vio->reenable(); } else { Debug("http", "probe already has data, call ioComplete directly.."); - vio = netvc->do_io_read(nullptr, 0, nullptr); + vio = netvc->do_io_read(this, 0, nullptr); probe->ioCompletionEvent(VC_EVENT_READ_COMPLETE, (void *)vio); } return EVENT_CONT;