MCPcopy Create free account
hub / github.com/apache/trafficserver / load_buffer_and_write

Method load_buffer_and_write

src/iocore/net/SSLNetVConnection.cc:696–836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

694}
695
696int64_t
697SSLNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &buf, int64_t &total_written, int &needs)
698{
699 int64_t try_to_write;
700 int64_t num_really_written = 0;
701 int64_t l = 0;
702 uint32_t dynamic_tls_record_size = 0;
703 ssl_error_t err = SSL_ERROR_NONE;
704
705 // Dynamic TLS record sizing
706 ink_hrtime now = 0;
707 if (SSLConfigParams::ssl_maxrecord == -1) {
708 now = ink_get_hrtime();
709 int msec_since_last_write = ink_hrtime_diff_msec(now, sslLastWriteTime);
710
711 if (msec_since_last_write > SSL_DEF_TLS_RECORD_MSEC_THRESHOLD) {
712 // reset sslTotalBytesSent upon inactivity for SSL_DEF_TLS_RECORD_MSEC_THRESHOLD
713 sslTotalBytesSent = 0;
714 }
715 Dbg(dbg_ctl_ssl, "now=%" PRId64 " lastwrite=%" PRId64 " msec_since_last_write=%d", now, sslLastWriteTime,
716 msec_since_last_write);
717 }
718
719 if (HttpProxyPort::TRANSPORT_BLIND_TUNNEL == this->attributes) {
720 return this->super::load_buffer_and_write(towrite, buf, total_written, needs);
721 }
722
723 Dbg(dbg_ctl_ssl, "towrite=%" PRId64, towrite);
724
725 ERR_clear_error();
726 do {
727 // What is remaining left in the next block?
728 l = buf.reader()->block_read_avail();
729 char *current_block = buf.reader()->start();
730
731 // check if to amount to write exceeds that in this buffer
732 int64_t wavail = towrite - total_written;
733
734 if (l > wavail) {
735 l = wavail;
736 }
737
738 // TS-2365: If the SSL max record size is set and we have
739 // more data than that, break this into smaller write
740 // operations.
741 //
742 // TS-4424: Don't mess with record size if last SSL_write failed with
743 // needs write
744 if (redoWriteSize) {
745 l = redoWriteSize;
746 redoWriteSize = 0;
747 } else {
748 if (SSLConfigParams::ssl_maxrecord > 0 && l > SSLConfigParams::ssl_maxrecord) {
749 l = SSLConfigParams::ssl_maxrecord;
750 } else if (SSLConfigParams::ssl_maxrecord == -1) {
751 if (sslTotalBytesSent < SSL_DEF_TLS_RECORD_BYTE_THRESHOLD) {
752 dynamic_tls_record_size = SSL_DEF_TLS_RECORD_SIZE;
753 Metrics::Counter::increment(ssl_rsb.total_dyn_def_tls_record_count);

Callers

nothing calls this directly

Calls 8

_ssl_write_bufferMethod · 0.95
ink_get_hrtimeFunction · 0.85
ink_hrtime_diff_msecFunction · 0.85
incrementFunction · 0.85
block_read_availMethod · 0.80
readerMethod · 0.45
startMethod · 0.45
consumeMethod · 0.45

Tested by

no test coverage detected