From d6c1c22a08ec38c6343c43c1aa48aef7c19a9ce3 Mon Sep 17 00:00:00 2001 From: Masaori Koshiba Date: Thu, 7 Jul 2022 08:50:27 +0900 Subject: [PATCH] Setup UA consumer only if ua_entry is not nullptr --- proxy/http/HttpSM.cc | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index ded6448013d..e75d0f3fe3c 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -6673,18 +6673,22 @@ HttpSM::setup_internal_transfer(HttpSMHandler handler_arg) HTTP_SM_SET_DEFAULT_HANDLER(handler_arg); - // Clear the decks before we setup the new producers - // As things stand, we cannot have two static producers operating at - // once - tunnel.reset(); + if (ua_entry && ua_entry->vc) { + // Clear the decks before we setup the new producers + // As things stand, we cannot have two static producers operating at + // once + tunnel.reset(); - // Setup the tunnel to the client - HttpTunnelProducer *p = - tunnel.add_producer(HTTP_TUNNEL_STATIC_PRODUCER, nbytes, buf_start, (HttpProducerHandler) nullptr, HT_STATIC, "internal msg"); - tunnel.add_consumer(ua_entry->vc, HTTP_TUNNEL_STATIC_PRODUCER, &HttpSM::tunnel_handler_ua, HT_HTTP_CLIENT, "user agent"); + // Setup the tunnel to the client + HttpTunnelProducer *p = + tunnel.add_producer(HTTP_TUNNEL_STATIC_PRODUCER, nbytes, buf_start, (HttpProducerHandler) nullptr, HT_STATIC, "internal msg"); + tunnel.add_consumer(ua_entry->vc, HTTP_TUNNEL_STATIC_PRODUCER, &HttpSM::tunnel_handler_ua, HT_HTTP_CLIENT, "user agent"); - ua_entry->in_tunnel = true; - tunnel.tunnel_run(p); + ua_entry->in_tunnel = true; + tunnel.tunnel_run(p); + } else { + (this->*default_handler)(HTTP_TUNNEL_EVENT_DONE, &tunnel); + } } // int HttpSM::find_http_resp_buffer_size(int cl)