add dynamic tls record patch
This commit is contained in:
@@ -1677,6 +1677,7 @@ ngx_ssl_create_connection(ngx_ssl_t *ssl, ngx_connection_t *c, ngx_uint_t flags)
|
||||
|
||||
sc->buffer = ((flags & NGX_SSL_BUFFER) != 0);
|
||||
sc->buffer_size = ssl->buffer_size;
|
||||
sc->dyn_rec = ssl->dyn_rec;
|
||||
|
||||
sc->session_ctx = ssl->ctx;
|
||||
|
||||
@@ -2643,6 +2644,41 @@ ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
||||
|
||||
for ( ;; ) {
|
||||
|
||||
/* Dynamic record resizing:
|
||||
We want the initial records to fit into one TCP segment
|
||||
so we don't get TCP HoL blocking due to TCP Slow Start.
|
||||
A connection always starts with small records, but after
|
||||
a given amount of records sent, we make the records larger
|
||||
to reduce header overhead.
|
||||
After a connection has idled for a given timeout, begin
|
||||
the process from the start. The actual parameters are
|
||||
configurable. If dyn_rec_timeout is 0, we assume dyn_rec is off. */
|
||||
|
||||
if (c->ssl->dyn_rec.timeout > 0 ) {
|
||||
|
||||
if (ngx_current_msec - c->ssl->dyn_rec_last_write >
|
||||
c->ssl->dyn_rec.timeout)
|
||||
{
|
||||
buf->end = buf->start + c->ssl->dyn_rec.size_lo;
|
||||
c->ssl->dyn_rec_records_sent = 0;
|
||||
|
||||
} else {
|
||||
if (c->ssl->dyn_rec_records_sent >
|
||||
c->ssl->dyn_rec.threshold * 2)
|
||||
{
|
||||
buf->end = buf->start + c->ssl->buffer_size;
|
||||
|
||||
} else if (c->ssl->dyn_rec_records_sent >
|
||||
c->ssl->dyn_rec.threshold)
|
||||
{
|
||||
buf->end = buf->start + c->ssl->dyn_rec.size_hi;
|
||||
|
||||
} else {
|
||||
buf->end = buf->start + c->ssl->dyn_rec.size_lo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (in && buf->last < buf->end && send < limit) {
|
||||
if (in->buf->last_buf || in->buf->flush) {
|
||||
flush = 1;
|
||||
@@ -2782,6 +2818,9 @@ ngx_ssl_write(ngx_connection_t *c, u_char *data, size_t size)
|
||||
|
||||
if (n > 0) {
|
||||
|
||||
c->ssl->dyn_rec_records_sent++;
|
||||
c->ssl->dyn_rec_last_write = ngx_current_msec;
|
||||
|
||||
if (c->ssl->saved_read_handler) {
|
||||
|
||||
c->read->handler = c->ssl->saved_read_handler;
|
||||
|
||||
Reference in New Issue
Block a user