Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
LDIF 3.10 KB | None | 0 0
  1. diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
  2. index c74d888..b5f3269 100644
  3. --- a/proxy/http/HttpSM.cc
  4. +++ b/proxy/http/HttpSM.cc
  5. @@ -2751,25 +2751,39 @@ HttpSM::tunnel_handler_post(int event, void *data)
  6.      return 0; // Cannot do anything if there is no producer
  7.    }
  8.  
  9. -  if (event != HTTP_TUNNEL_EVENT_DONE) {
  10. -    if ((event == VC_EVENT_WRITE_COMPLETE) || (event == VC_EVENT_EOS)) {
  11. -      if (ua_entry->write_buffer) {
  12. -        free_MIOBuffer(ua_entry->write_buffer);
  13. -        ua_entry->write_buffer = nullptr;
  14. -      }
  15. -    }
  16. +  switch (event) {
  17. +  case HTTP_TUNNEL_EVENT_DONE: // Tunnel done.
  18. +    break;
  19. +  case VC_EVENT_WRITE_READY: // iocore may callback first before send.
  20. +    return 0;
  21. +  case VC_EVENT_EOS:                // SSLNetVC may callback EOS during write error (6.0.x or early)
  22. +  case VC_EVENT_ERROR:              // Send HTTP 408 error
  23. +  case VC_EVENT_WRITE_COMPLETE:     // tunnel_handler_post_ua has sent HTTP 408 response
  24. +  case VC_EVENT_INACTIVITY_TIMEOUT: // ua_session timeout during sending the HTTP 408 response
  25. +  case VC_EVENT_ACTIVE_TIMEOUT:     // ua_session timeout
  26. +    if (ua_entry->write_buffer) {
  27. +      free_MIOBuffer(ua_entry->write_buffer);
  28. +      ua_entry->write_buffer = nullptr;
  29. +      ua_entry->vc->do_io_write(this, 0, NULL);
  30. +    }
  31. +    // The if statement will always true since these codes are all for HTTP 408 response sending. - by oknet xu
  32.      if (p->handler_state == HTTP_SM_POST_UA_FAIL) {
  33.        Debug("http_tunnel", "cleanup tunnel in tunnel_handler_post");
  34.        hsm_release_assert(ua_entry->in_tunnel == true);
  35. -      ink_assert((event == VC_EVENT_WRITE_COMPLETE) || (event == VC_EVENT_EOS));
  36. +      tunnel_handler_post_or_put(p);
  37.        vc_table.cleanup_all();
  38.        tunnel.chain_abort_all(p);
  39.        p->read_vio = nullptr;
  40.        p->vc->do_io_close(EHTTP_ERROR);
  41. -      tunnel_handler_post_or_put(p);
  42.        tunnel.kill_tunnel();
  43.        return 0;
  44.      }
  45. +    break;
  46. +  case VC_EVENT_READ_READY:
  47. +  case VC_EVENT_READ_COMPLETE:
  48. +  default:
  49. +    ink_assert(!"not reached");
  50. +    return 0;
  51.    }
  52.  
  53.    ink_assert(event == HTTP_TUNNEL_EVENT_DONE);
  54. @@ -3501,7 +3515,12 @@ HttpSM::tunnel_handler_post_ua(int event, HttpTunnelProducer *p)
  55.        nbytes = ua_entry->write_buffer->write(str_408_request_timeout_response, len_408_request_timeout_response);
  56.        nbytes += ua_entry->write_buffer->write(t_state.internal_msg_buffer, t_state.internal_msg_buffer_size);
  57.  
  58. -      p->vc->do_io_write(this, nbytes, buf_start);
  59. +      // The HttpSM default handler still is HttpSM::state_request_wait_for_transform_read.
  60. +      // However, WRITE_COMPLETE/TIMEOUT/ERROR event should be managed/handled by tunnel_handler_post.
  61. +      ua_entry->vc_handler = &HttpSM::tunnel_handler_post;
  62. +      ua_entry->write_vio  = p->vc->do_io_write(this, nbytes, buf_start);
  63. +      // Reset the inactivity timeout, otherwise the InactivityCop will callback again in the next second.
  64. +      ua_session->set_inactivity_timeout(HRTIME_SECONDS(t_state.txn_conf->transaction_no_activity_timeout_in));
  65.        p->vc->do_io_shutdown(IO_SHUTDOWN_READ);
  66.        return 0;
  67.      }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement