Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/README b/README
- index 34ea77e7d..9afabaf80 100644
- --- a/README
- +++ b/README
- @@ -100,6 +100,17 @@ plugins to build large scale web applications.
- libcurl4-openssl-dev (optional, required for e.g.: traffic_top)
- flex (optional, required for e.g. WCCP)
- + Alpine Linux
- + build-base
- + libexecinfo-dev
- + pcre-dev
- + libressl-dev
- + autoconf
- + automake
- + libtool
- + tcl-dev
- + linux-headers
- +
- OSX (we recommend HomeBrew):
- autoconf
- automake
- diff --git a/configure.ac b/configure.ac
- index 0dbdd1c29..4495d0c24 100644
- --- a/configure.ac
- +++ b/configure.ac
- @@ -444,12 +444,6 @@ AC_ARG_WITH([max-threads-per-type],
- )
- AC_SUBST(max_threads_per_type)
- -# Check Brotli
- -AC_CHECK_HEADERS([brotli/encode.h], [has_brotli=1],[has_brotli=0])
- -AC_CHECK_LIB([brotlienc],[BrotliEncoderCreateInstance],[AC_SUBST([LIB_BROTLIENC],["-lbrotlienc"])],[has_brotli=0])
- -AC_SUBST(has_brotli)
- -AM_CONDITIONAL([HAS_BROTLI], [ test "x${has_brotli}" = "x1" ])
- -
- #
- # Experimental plugins
- #
- @@ -1226,8 +1220,14 @@ if test "x${enable_pcre}" != "xyes"; then
- AC_MSG_ERROR([Cannot find pcre library. Configure --with-pcre=DIR])
- fi
- -has_backtrace=0
- +# Check Brotli
- +AC_CHECK_HEADERS([brotli/encode.h], [has_brotli=1],[has_brotli=0])
- +AC_CHECK_LIB([brotlienc],[BrotliEncoderCreateInstance],[AC_SUBST([LIB_BROTLIENC],["-lbrotlienc"])],[has_brotli=0])
- +AC_SUBST(has_brotli)
- +AM_CONDITIONAL([HAS_BROTLI], [ test "x${has_brotli}" = "x1" ])
- +
- # Check for backtrace() support
- +has_backtrace=0
- AC_CHECK_HEADERS([execinfo.h], [has_backtrace=1],[])
- if test "${has_backtrace}" = "1"; then
- # FreeBSD requires '/usr/ports/devel/libexecinfo' for gdb style backtrace() support
- diff --git a/doc/developer-guide/api/types/TSHttpStatus.en.rst b/doc/developer-guide/api/types/TSHttpStatus.en.rst
- index 9cfe9fe1a..78d2453e7 100644
- --- a/doc/developer-guide/api/types/TSHttpStatus.en.rst
- +++ b/doc/developer-guide/api/types/TSHttpStatus.en.rst
- @@ -45,6 +45,8 @@ Enumeration Members
- .. c:member:: TSHttpStatus TS_HTTP_STATUS_SWITCHING_PROTOCOL
- +.. c:member:: TSHttpStatus TS_HTTP_STATUS_EARLY_HINTS
- +
- .. c:member:: TSHttpStatus TS_HTTP_STATUS_OK
- .. c:member:: TSHttpStatus TS_HTTP_STATUS_CREATED
- diff --git a/example/thread-pool/psi.c b/example/thread-pool/psi.c
- index 970259756..a690c037c 100644
- --- a/example/thread-pool/psi.c
- +++ b/example/thread-pool/psi.c
- @@ -49,6 +49,7 @@
- #include <stdlib.h>
- #include <limits.h>
- #include <string.h>
- +#include <sys/param.h>
- #include "ts/ts.h"
- #include "thread.h"
- diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
- index 9e4263e4a..e0b633980 100644
- --- a/iocore/cache/Cache.cc
- +++ b/iocore/cache/Cache.cc
- @@ -3407,7 +3407,7 @@ HTTPInfo_v21::copy_and_upgrade_unmarshalled_to_v23(char *&dst, char *&src, size_
- // Extra data is fragment table - set that if we have it.
- if (n_frags) {
- static size_t const IFT_SIZE = HTTPCacheAlt_v23::N_INTEGRAL_FRAG_OFFSETS * sizeof(FragOffset);
- - size_t ift_actual = min(n_frags, HTTPCacheAlt_v23::N_INTEGRAL_FRAG_OFFSETS) * sizeof(FragOffset);
- + size_t ift_actual = std::min(n_frags, HTTPCacheAlt_v23::N_INTEGRAL_FRAG_OFFSETS) * sizeof(FragOffset);
- if (length < (HTTP_ALT_MARSHAL_SIZE + n_frags * sizeof(FragOffset) - IFT_SIZE))
- return false; // can't place fragment table.
- diff --git a/iocore/cache/Store.cc b/iocore/cache/Store.cc
- index e922d3bdf..06068adca 100644
- --- a/iocore/cache/Store.cc
- +++ b/iocore/cache/Store.cc
- @@ -561,7 +561,7 @@ Span::init(const char *path, int64_t size)
- // The actual size of a span always trumps the configured size.
- if (size > 0 && this->size() != size) {
- - int64_t newsz = MIN(size, this->size());
- + int64_t newsz = std::min(size, this->size());
- Note("cache %s '%s' is %" PRId64 " bytes, but the configured size is %" PRId64 " bytes, using the minimum",
- span_file_typename(sbuf.st_mode), path, this->size(), size);
- diff --git a/iocore/cluster/ClusterHandlerBase.cc b/iocore/cluster/ClusterHandlerBase.cc
- index 16d42a86f..36011d634 100644
- --- a/iocore/cluster/ClusterHandlerBase.cc
- +++ b/iocore/cluster/ClusterHandlerBase.cc
- @@ -1144,7 +1144,7 @@ ClusterHandler::startClusterEvent(int event, Event *e)
- // external_incoming_control.
- int procs_online = ink_number_of_processors();
- - int total_callbacks = min(procs_online, MAX_COMPLETION_CALLBACK_EVENTS);
- + int total_callbacks = std::min(procs_online, MAX_COMPLETION_CALLBACK_EVENTS);
- for (int n = 0; n < total_callbacks; ++n) {
- callout_cont[n] = new ClusterCalloutContinuation(this);
- callout_events[n] = eventProcessor.schedule_every(callout_cont[n], COMPLETION_CALLBACK_PERIOD, ET_NET);
- diff --git a/iocore/dns/DNS.cc b/iocore/dns/DNS.cc
- index 5c1522add..0c0c4ae14 100644
- --- a/iocore/dns/DNS.cc
- +++ b/iocore/dns/DNS.cc
- @@ -509,7 +509,7 @@ DNSHandler::startEvent(int /* event ATS_UNUSED */, Event *e)
- open_con(nullptr); // use current target address.
- n_con = 1;
- }
- - e->ethread->schedule_every(this, DNS_PERIOD);
- + e->ethread->schedule_every(this, -DNS_PERIOD);
- return EVENT_CONT;
- } else {
- @@ -532,7 +532,7 @@ DNSHandler::startEvent_sdns(int /* event ATS_UNUSED */, Event *e)
- open_con(&ip.sa, false, n_con);
- ++n_con; // TODO should n_con be zeroed?
- - e->schedule_every(DNS_PERIOD);
- + e->schedule_every(-DNS_PERIOD);
- return EVENT_CONT;
- }
- @@ -645,6 +645,8 @@ DNSHandler::failover()
- switch_named(name_server);
- } else {
- ip_text_buffer buff;
- + con[name_server].eio.stop();
- + con[name_server].close();
- Warning("failover: connection to DNS server %s lost, retrying", ats_ip_ntop(&ip.sa, buff, sizeof(buff)));
- }
- }
- @@ -1235,7 +1237,7 @@ Lretry:
- e->retries = 0;
- if (e->timeout)
- e->timeout->cancel();
- - e->timeout = h->mutex->thread_holding->schedule_in(e, DNS_PERIOD);
- + e->timeout = h->mutex->thread_holding->schedule_in(e, MUTEX_RETRY_DELAY);
- }
- int
- diff --git a/iocore/dns/P_DNSProcessor.h b/iocore/dns/P_DNSProcessor.h
- index 8fead49d5..be22b014f 100644
- --- a/iocore/dns/P_DNSProcessor.h
- +++ b/iocore/dns/P_DNSProcessor.h
- @@ -62,7 +62,7 @@ extern unsigned int dns_sequence_number;
- // Constants
- //
- -#define DNS_PERIOD HRTIME_MSECONDS(-100)
- +#define DNS_PERIOD HRTIME_MSECONDS(100)
- #define DNS_DELAY_PERIOD HRTIME_MSECONDS(10)
- #define DNS_SEQUENCE_NUMBER_RESTART_OFFSET 4000
- #define DNS_PRIMARY_RETRY_PERIOD HRTIME_SECONDS(5)
- diff --git a/iocore/eventsystem/P_UnixSocketManager.h b/iocore/eventsystem/P_UnixSocketManager.h
- index b023a8de9..b45f74562 100644
- --- a/iocore/eventsystem/P_UnixSocketManager.h
- +++ b/iocore/eventsystem/P_UnixSocketManager.h
- @@ -118,7 +118,7 @@ SocketManager::vector_io(int fd, struct iovec *vector, size_t count, int read_re
- int64_t current_request_bytes;
- for (n_vec = 0; n_vec < (int)count; n_vec += max_iovecs_per_request) {
- - current_count = min(max_iovecs_per_request, ((int)(count - n_vec)));
- + current_count = std::min(max_iovecs_per_request, ((int)(count - n_vec)));
- do {
- // coverity[tainted_data_argument]
- r = read_request ? ::readv(fd, &vector[n_vec], current_count) : ::writev(fd, &vector[n_vec], current_count);
- diff --git a/iocore/net/Connection.cc b/iocore/net/Connection.cc
- index e52af10b6..78f5a6a69 100644
- --- a/iocore/net/Connection.cc
- +++ b/iocore/net/Connection.cc
- @@ -45,7 +45,7 @@ get_listen_backlog()
- int listen_backlog;
- REC_ReadConfigInteger(listen_backlog, "proxy.config.net.listen_backlog");
- - return listen_backlog >= 0 ? listen_backlog : ats_tcp_somaxconn();
- + return (0 < listen_backlog && listen_backlog <= 65535) ? listen_backlog : ats_tcp_somaxconn();
- }
- //
- diff --git a/iocore/net/NetVCTest.cc b/iocore/net/NetVCTest.cc
- index 17401d58c..07d7c6b8c 100644
- --- a/iocore/net/NetVCTest.cc
- +++ b/iocore/net/NetVCTest.cc
- @@ -308,7 +308,7 @@ NetVCTest::write_handler(int event)
- if (write_vio->ndone < bytes_to_send) {
- int left_to_send = bytes_to_send - actual_bytes_sent;
- ink_assert(left_to_send >= 0);
- - int to_fill = MIN(left_to_send, write_bytes_to_add_per);
- + int to_fill = std::min(left_to_send, write_bytes_to_add_per);
- actual_bytes_sent += fill_buffer(write_buffer, &write_seed, to_fill);
- write_vio->reenable();
- }
- diff --git a/iocore/net/P_InkBulkIO.h b/iocore/net/P_InkBulkIO.h
- index 46df82b82..f24b95a8f 100644
- --- a/iocore/net/P_InkBulkIO.h
- +++ b/iocore/net/P_InkBulkIO.h
- @@ -141,7 +141,7 @@ struct InkBulkIORequest {
- */
- #define INKBIO_MAX_PKTS_PER_REQ_BLOCK \
- ((INKBIO_PKT_SIZE_WO_UDPHDR - (sizeof(struct InkBulkIORequest) + sizeof(struct InkBulkIOPkt))) / \
- - MAX((sizeof(struct InkBulkIORequest)), (sizeof(struct InkBulkIOPkt))))
- + std::max((sizeof(struct InkBulkIORequest)), (sizeof(struct InkBulkIOPkt))))
- /*
- * Requests are just block-ids---the block id points to the inkbio-block
- diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc
- index da5a8780b..e9fadb144 100644
- --- a/iocore/net/UnixUDPNet.cc
- +++ b/iocore/net/UnixUDPNet.cc
- @@ -668,10 +668,10 @@ UDPQueue::service(UDPNetHandler *nh)
- // insert into our queue.
- Debug("udp-send", "Adding %p", p);
- if (p->conn->lastPktStartTime == 0) {
- - pktSendStartTime = MAX(now, p->delivery_time);
- + pktSendStartTime = std::max(now, p->delivery_time);
- } else {
- pktSendTime = p->delivery_time;
- - pktSendStartTime = MAX(MAX(now, pktSendTime), p->delivery_time);
- + pktSendStartTime = std::max(std::max(now, pktSendTime), p->delivery_time);
- }
- p->conn->lastPktStartTime = pktSendStartTime;
- p->delivery_time = pktSendStartTime;
- diff --git a/lib/cppapi/include/atscppapi/HttpStatus.h b/lib/cppapi/include/atscppapi/HttpStatus.h
- index 5c2e3732d..071aef1a3 100644
- --- a/lib/cppapi/include/atscppapi/HttpStatus.h
- +++ b/lib/cppapi/include/atscppapi/HttpStatus.h
- @@ -37,6 +37,7 @@ enum HttpStatus {
- HTTP_STATUS_CONTINUE = 100,
- HTTP_STATUS_SWITCHING_PROTOCOL = 101,
- + HTTP_STATUS_EARLY_HINTS = 103,
- HTTP_STATUS_OK = 200,
- HTTP_STATUS_CREATED = 201,
- diff --git a/lib/records/RecHttp.cc b/lib/records/RecHttp.cc
- index 29ea1fa48..99f56b7af 100644
- --- a/lib/records/RecHttp.cc
- +++ b/lib/records/RecHttp.cc
- @@ -600,7 +600,7 @@ HttpProxyPort::print(char *out, size_t n)
- }
- }
- - return min(zret, n);
- + return std::min(zret, n);
- }
- void
- diff --git a/lib/ts/Makefile.am b/lib/ts/Makefile.am
- index 2e09e151f..146c06fe6 100644
- --- a/lib/ts/Makefile.am
- +++ b/lib/ts/Makefile.am
- @@ -244,6 +244,7 @@ test_tslib_CPPFLAGS = $(AM_CPPFLAGS)\
- -I$(abs_top_srcdir)/tests/include
- # add you catch based test file here for tslib
- +test_tslib_CXXFLAGS = -Wno-array-bounds $(AM_CXXFLAGS)
- test_tslib_LDADD = libtsutil.la
- test_tslib_SOURCES = \
- unit-tests/main.cpp \
- diff --git a/lib/ts/apidefs.h.in b/lib/ts/apidefs.h.in
- index 4f0ada31f..7efe01967 100644
- --- a/lib/ts/apidefs.h.in
- +++ b/lib/ts/apidefs.h.in
- @@ -155,6 +155,7 @@ typedef enum {
- TS_HTTP_STATUS_NONE = 0,
- TS_HTTP_STATUS_CONTINUE = 100,
- TS_HTTP_STATUS_SWITCHING_PROTOCOL = 101,
- + TS_HTTP_STATUS_EARLY_HINTS = 103,
- TS_HTTP_STATUS_OK = 200,
- TS_HTTP_STATUS_CREATED = 201,
- TS_HTTP_STATUS_ACCEPTED = 202,
- diff --git a/lib/ts/ink_defs.h b/lib/ts/ink_defs.h
- index 0f80a8152..f85589d3a 100644
- --- a/lib/ts/ink_defs.h
- +++ b/lib/ts/ink_defs.h
- @@ -88,33 +88,6 @@ countof(const T (&)[N])
- #define ABS(x) (((x) < 0) ? (-(x)) : (x))
- #endif
- -#ifndef MAX
- -#define MAX(x, y) (((x) >= (y)) ? (x) : (y))
- -#endif
- -
- -#ifndef MIN
- -#define MIN(x, y) (((x) <= (y)) ? (x) : (y))
- -#endif
- -
- -#ifdef __cplusplus
- -// We can't use #define for min and max because it will conflict with
- -// other declarations of min and max functions. This conflict
- -// occurs with STL
- -template <class T>
- -T
- -min(const T a, const T b)
- -{
- - return a < b ? a : b;
- -}
- -
- -template <class T>
- -T
- -max(const T a, const T b)
- -{
- - return a > b ? a : b;
- -}
- -#endif
- -
- #define ATS_UNUSED __attribute__((unused))
- #define ATS_WARN_IF_UNUSED __attribute__((warn_unused_result))
- #define ATS_UNUSED_RETURN(x) \
- diff --git a/lib/ts/ink_inet.cc b/lib/ts/ink_inet.cc
- index 01c2127bf..10d9b282c 100644
- --- a/lib/ts/ink_inet.cc
- +++ b/lib/ts/ink_inet.cc
- @@ -675,18 +675,17 @@ REGRESSION_TEST(Ink_Inet)(RegressionTest *t, int /* atype */, int *pstatus)
- int
- ats_tcp_somaxconn()
- {
- - int fd;
- int value = 0;
- /* Darwin version ... */
- #if HAVE_SYSCTLBYNAME
- size_t value_size = sizeof(value);
- - if (sysctlbyname("kern.ipc.somaxconn", &value, &value_size, nullptr, 0) == 0) {
- - return value;
- + if (sysctlbyname("kern.ipc.somaxconn", &value, &value_size, nullptr, 0) < 0) {
- + value = 0;
- }
- -#endif
- -
- - fd = open("/proc/sys/net/ipv4/tcp_max_syn_backlog", O_RDONLY);
- +#else
- + int fd;
- + fd = open("/proc/sys/net/core/somaxconn", O_RDONLY);
- if (fd != -1) {
- textBuffer text(0);
- text.slurp(fd);
- @@ -695,11 +694,12 @@ ats_tcp_somaxconn()
- }
- close(fd);
- }
- +#endif
- // Default to the compatible value we used before detection. SOMAXCONN is the right
- // macro to use, but most systems set this to 128, which is just too small.
- - if (value <= 0) {
- - return 1024;
- + if (value <= 0 || value > 65535) {
- + value = 1024;
- }
- return value;
- diff --git a/lib/ts/ink_sys_control.cc b/lib/ts/ink_sys_control.cc
- index 8cdc824dc..e1d3e715c 100644
- --- a/lib/ts/ink_sys_control.cc
- +++ b/lib/ts/ink_sys_control.cc
- @@ -30,7 +30,7 @@ ink_max_out_rlimit(int which, bool max_it, bool unlim_it)
- {
- struct rlimit rl;
- -#if defined(linux)
- +#if defined(__GLIBC__)
- #define MAGIC_CAST(x) (enum __rlimit_resource)(x)
- #else
- #define MAGIC_CAST(x) x
- diff --git a/lib/ts/mkdfa.c b/lib/ts/mkdfa.c
- index 3767b0c1b..9dcc89083 100644
- --- a/lib/ts/mkdfa.c
- +++ b/lib/ts/mkdfa.c
- @@ -138,6 +138,7 @@ info_t methods[] = {
- info_t statuses[] = {
- {"100", "HTTP_STATUS_CONTINUE", -1},
- {"101", "HTTP_STATUS_SWITCHING_PROTOCOL", -1},
- + {"103", "HTTP_STATUS_EARLY_HINTS", -1},
- {"200", "HTTP_STATUS_OK", -1},
- {"201", "HTTP_STATUS_CREATED", -1},
- {"202", "HTTP_STATUS_ACCEPTED", -1},
- diff --git a/mgmt/cluster/ClusterCom.cc b/mgmt/cluster/ClusterCom.cc
- index 496def120..263069d01 100644
- --- a/mgmt/cluster/ClusterCom.cc
- +++ b/mgmt/cluster/ClusterCom.cc
- @@ -658,7 +658,7 @@ ClusterCom::generateClusterDelta()
- // is the node alive?
- if (tmp->num_virt_addrs != -1) {
- - highest_delta = max(highest_delta, tmp->delta);
- + highest_delta = std::max(highest_delta, tmp->delta);
- }
- }
- ink_mutex_release(&(mutex));
- diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc
- index 486c343b5..5f67c697e 100644
- --- a/proxy/InkAPITest.cc
- +++ b/proxy/InkAPITest.cc
- @@ -3272,7 +3272,7 @@ REGRESSION_TEST(SDK_API_TSHttpHdr)(RegressionTest *test, int /* atype ATS_UNUSED
- }
- if (strcmp("Not Modified", TSHttpHdrReasonLookup(TS_HTTP_STATUS_NOT_MODIFIED)) != 0) {
- - SDK_RPRINT(test, "TSHttpHdrReasonLookup", "TestCase2", TC_FAIL, "TSHttpHdrReasonLookup returns Value's mismatch");
- + SDK_RPRINT(test, "TSHttpHdrReasonLookup", "TestCase4", TC_FAIL, "TSHttpHdrReasonLookup returns Value's mismatch");
- if (test_passed_Http_Hdr_Reason_Lookup == true) {
- test_passed_Http_Hdr_Reason_Lookup = false;
- }
- @@ -3280,6 +3280,15 @@ REGRESSION_TEST(SDK_API_TSHttpHdr)(RegressionTest *test, int /* atype ATS_UNUSED
- SDK_RPRINT(test, "TSHttpHdrReasonLookup", "TestCase4", TC_PASS, "ok");
- }
- + if (strcmp("Early Hints", TSHttpHdrReasonLookup(TS_HTTP_STATUS_EARLY_HINTS)) != 0) {
- + SDK_RPRINT(test, "TSHttpHdrReasonLookup", "TestCase5", TC_FAIL, "TSHttpHdrReasonLookup returns Value's mismatch");
- + if (test_passed_Http_Hdr_Reason_Lookup == true) {
- + test_passed_Http_Hdr_Reason_Lookup = false;
- + }
- + } else {
- + SDK_RPRINT(test, "TSHttpHdrReasonLookup", "TestCase5", TC_PASS, "ok");
- + }
- +
- // Copy
- if (test_passed_Http_Hdr_Create == true) {
- if (TSHttpHdrCopy(bufp3, hdr_loc3, bufp1, hdr_loc1) == TS_ERROR) {
- @@ -5488,6 +5497,7 @@ typedef enum {
- ORIG_TS_HTTP_STATUS_CONTINUE = 100,
- ORIG_TS_HTTP_STATUS_SWITCHING_PROTOCOL = 101,
- + ORIG_TS_HTTP_STATUS_EARLY_HINTS = 103,
- ORIG_TS_HTTP_STATUS_OK = 200,
- ORIG_TS_HTTP_STATUS_CREATED = 201,
- @@ -5657,6 +5667,8 @@ REGRESSION_TEST(SDK_API_TSConstant)(RegressionTest *test, int /* atype ATS_UNUSE
- PRINT_DIFF(TS_HTTP_STATUS_NONE);
- PRINT_DIFF(TS_HTTP_STATUS_CONTINUE);
- PRINT_DIFF(TS_HTTP_STATUS_SWITCHING_PROTOCOL);
- + PRINT_DIFF(TS_HTTP_STATUS_EARLY_HINTS);
- +
- PRINT_DIFF(TS_HTTP_STATUS_OK);
- PRINT_DIFF(TS_HTTP_STATUS_CREATED);
- diff --git a/proxy/InkAPITestTool.cc b/proxy/InkAPITestTool.cc
- index dd814b1ce..fc3392a68 100644
- --- a/proxy/InkAPITestTool.cc
- +++ b/proxy/InkAPITestTool.cc
- @@ -667,7 +667,7 @@ synclient_txn_write_request(TSCont contp)
- while (ntodo > 0) {
- block = TSIOBufferStart(txn->req_buffer);
- ptr_block = TSIOBufferBlockWriteStart(block, &avail);
- - towrite = MIN(ntodo, avail);
- + towrite = std::min(ntodo, avail);
- memcpy(ptr_block, txn->request + ndone, towrite);
- TSIOBufferProduce(txn->req_buffer, towrite);
- ntodo -= towrite;
- @@ -962,7 +962,7 @@ synserver_txn_write_response(TSCont contp)
- while (ntodo > 0) {
- block = TSIOBufferStart(txn->resp_buffer);
- ptr_block = TSIOBufferBlockWriteStart(block, &avail);
- - towrite = MIN(ntodo, avail);
- + towrite = std::min(ntodo, avail);
- memcpy(ptr_block, response + ndone, towrite);
- TSIOBufferProduce(txn->resp_buffer, towrite);
- ntodo -= towrite;
- diff --git a/proxy/PluginVC.cc b/proxy/PluginVC.cc
- index 7a377e723..e2e221712 100644
- --- a/proxy/PluginVC.cc
- +++ b/proxy/PluginVC.cc
- @@ -432,7 +432,7 @@ PluginVC::transfer_bytes(MIOBuffer *transfer_to, IOBufferReader *transfer_from,
- while (act_on > 0) {
- int64_t block_read_avail = transfer_from->block_read_avail();
- - int64_t to_move = MIN(act_on, block_read_avail);
- + int64_t to_move = std::min(act_on, block_read_avail);
- int64_t moved = 0;
- if (to_move <= 0) {
- @@ -507,7 +507,7 @@ PluginVC::process_write_side(bool other_side_call)
- IOBufferReader *reader = write_state.vio.get_reader();
- int64_t bytes_avail = reader->read_avail();
- - int64_t act_on = MIN(bytes_avail, ntodo);
- + int64_t act_on = std::min(bytes_avail, ntodo);
- Debug("pvc", "[%u] %s: process_write_side; act_on %" PRId64 "", core_obj->id, PVC_TYPE, act_on);
- @@ -532,7 +532,7 @@ PluginVC::process_write_side(bool other_side_call)
- Debug("pvc", "[%u] %s: process_write_side no buffer space", core_obj->id, PVC_TYPE);
- return;
- }
- - act_on = MIN(act_on, buf_space);
- + act_on = std::min(act_on, buf_space);
- int64_t added = transfer_bytes(core_buffer, reader, act_on);
- if (added < 0) {
- @@ -625,7 +625,7 @@ PluginVC::process_read_side(bool other_side_call)
- }
- int64_t bytes_avail = core_reader->read_avail();
- - int64_t act_on = MIN(bytes_avail, ntodo);
- + int64_t act_on = std::min(bytes_avail, ntodo);
- Debug("pvc", "[%u] %s: process_read_side; act_on %" PRId64 "", core_obj->id, PVC_TYPE, act_on);
- @@ -641,13 +641,13 @@ PluginVC::process_read_side(bool other_side_call)
- MIOBuffer *output_buffer = read_state.vio.get_writer();
- int64_t water_mark = output_buffer->water_mark;
- - water_mark = MAX(water_mark, PVC_DEFAULT_MAX_BYTES);
- + water_mark = std::max(water_mark, static_cast<int64_t>(PVC_DEFAULT_MAX_BYTES));
- int64_t buf_space = water_mark - output_buffer->max_read_avail();
- if (buf_space <= 0) {
- Debug("pvc", "[%u] %s: process_read_side no buffer space", core_obj->id, PVC_TYPE);
- return;
- }
- - act_on = MIN(act_on, buf_space);
- + act_on = std::min(act_on, buf_space);
- int64_t added = transfer_bytes(output_buffer, core_reader, act_on);
- if (added <= 0) {
- diff --git a/proxy/hdrs/HTTP.cc b/proxy/hdrs/HTTP.cc
- index 3be7064da..c265e1293 100644
- --- a/proxy/hdrs/HTTP.cc
- +++ b/proxy/hdrs/HTTP.cc
- @@ -756,6 +756,7 @@ http_hdr_reason_lookup(unsigned status)
- HTTP_STATUS_ENTRY(100, Continue); // [RFC2616]
- HTTP_STATUS_ENTRY(101, Switching Protocols); // [RFC2616]
- HTTP_STATUS_ENTRY(102, Processing); // [RFC2518]
- + HTTP_STATUS_ENTRY(103, Early Hints); // TODO: add RFC number
- // 103-199 Unassigned
- HTTP_STATUS_ENTRY(200, OK); // [RFC2616]
- HTTP_STATUS_ENTRY(201, Created); // [RFC2616]
- @@ -1815,6 +1816,8 @@ ClassAllocator<HTTPCacheAlt> httpCacheAltAllocator("httpCacheAltAllocator");
- /*-------------------------------------------------------------------------
- -------------------------------------------------------------------------*/
- +int constexpr HTTPCacheAlt::N_INTEGRAL_FRAG_OFFSETS;
- +
- HTTPCacheAlt::HTTPCacheAlt()
- : m_magic(CACHE_ALT_MAGIC_ALIVE),
- m_writeable(1),
- diff --git a/proxy/hdrs/HTTP.h b/proxy/hdrs/HTTP.h
- index 5891834dc..3cd61a31f 100644
- --- a/proxy/hdrs/HTTP.h
- +++ b/proxy/hdrs/HTTP.h
- @@ -43,6 +43,7 @@ enum HTTPStatus {
- HTTP_STATUS_CONTINUE = 100,
- HTTP_STATUS_SWITCHING_PROTOCOL = 101,
- + HTTP_STATUS_EARLY_HINTS = 103,
- HTTP_STATUS_OK = 200,
- HTTP_STATUS_CREATED = 201,
- @@ -1352,7 +1353,7 @@ struct HTTPCacheAlt {
- /// for the last fragment.
- FragOffset *m_frag_offsets;
- /// # of fragment offsets built in to object.
- - static int const N_INTEGRAL_FRAG_OFFSETS = 4;
- + static int constexpr N_INTEGRAL_FRAG_OFFSETS = 4;
- /// Integral fragment offset table.
- FragOffset m_integral_frag_offsets[N_INTEGRAL_FRAG_OFFSETS];
- diff --git a/proxy/hdrs/HttpCompat.cc b/proxy/hdrs/HttpCompat.cc
- index 6f69758b6..89eaa634a 100644
- --- a/proxy/hdrs/HttpCompat.cc
- +++ b/proxy/hdrs/HttpCompat.cc
- @@ -851,7 +851,7 @@ HttpCompat::determine_set_by_language(RawHashTable *table_of_sets, StrList *acpt
- // index, preferring values earlier in Accept-Language list. //
- /////////////////////////////////////////////////////////////////
- - Q = min(Ql, Qc);
- + Q = std::min(Ql, Qc);
- //////////////////////////////////////////////////////////
- // normally the Q for default pages should be slightly //
- diff --git a/proxy/hdrs/MIME.cc b/proxy/hdrs/MIME.cc
- index 418c34a67..e2b0c1bd5 100644
- --- a/proxy/hdrs/MIME.cc
- +++ b/proxy/hdrs/MIME.cc
- @@ -2802,7 +2802,7 @@ mime_mem_print(const char *src_d, int src_l, char *buf_start, int buf_length, in
- }
- }
- - copy_l = min(buf_length - *buf_index_inout, src_l);
- + copy_l = std::min(buf_length - *buf_index_inout, src_l);
- if (copy_l > 0) {
- memcpy(buf_start + *buf_index_inout, src_d, copy_l);
- *buf_index_inout += copy_l;
- diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc
- index 258d1d843..a7d3371cf 100644
- --- a/proxy/http/HttpConfig.cc
- +++ b/proxy/http/HttpConfig.cc
- @@ -1304,7 +1304,7 @@ HttpConfig::reconfigure()
- params->oride.cache_heuristic_min_lifetime = m_master.oride.cache_heuristic_min_lifetime;
- params->oride.cache_heuristic_max_lifetime = m_master.oride.cache_heuristic_max_lifetime;
- - params->oride.cache_heuristic_lm_factor = min(max(m_master.oride.cache_heuristic_lm_factor, 0.0f), 1.0f);
- + params->oride.cache_heuristic_lm_factor = std::min(std::max(m_master.oride.cache_heuristic_lm_factor, 0.0f), 1.0f);
- params->oride.cache_guaranteed_min_lifetime = m_master.oride.cache_guaranteed_min_lifetime;
- params->oride.cache_guaranteed_max_lifetime = m_master.oride.cache_guaranteed_max_lifetime;
- diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
- index 29f492e74..411c6316e 100644
- --- a/proxy/http/HttpTransact.cc
- +++ b/proxy/http/HttpTransact.cc
- @@ -2411,8 +2411,8 @@ HttpTransact::HandleCacheOpenReadHitFreshness(State *s)
- // for it. this is just to deal with the effects
- // of the skew by setting minimum and maximum times
- // so that ages are not negative, etc.
- - s->request_sent_time = min(s->client_request_time, s->request_sent_time);
- - s->response_received_time = min(s->client_request_time, s->response_received_time);
- + s->request_sent_time = std::min(s->client_request_time, s->request_sent_time);
- + s->response_received_time = std::min(s->client_request_time, s->response_received_time);
- ink_assert(s->request_sent_time <= s->response_received_time);
- @@ -4071,7 +4071,8 @@ HttpTransact::handle_forward_server_connection_open(State *s)
- // dont update the hostdb. let us try again with what we currently think.
- }
- - if (s->hdr_info.server_response.status_get() == HTTP_STATUS_CONTINUE) {
- + if (s->hdr_info.server_response.status_get() == HTTP_STATUS_CONTINUE ||
- + s->hdr_info.server_response.status_get() == HTTP_STATUS_EARLY_HINTS) {
- handle_100_continue_response(s);
- return;
- }
- @@ -4840,7 +4841,7 @@ HttpTransact::merge_and_update_headers_for_cache_update(State *s)
- // If the cached response has an Age: we should update it
- // We could use calculate_document_age but my guess is it's overkill
- // Just use 'now' - 304's Date: + Age: (response's Age: if there)
- - date_value = max(s->current.now - date_value, (ink_time_t)0);
- + date_value = std::max(s->current.now - date_value, (ink_time_t)0);
- if (s->hdr_info.server_response.presence(MIME_PRESENCE_AGE)) {
- time_t new_age = s->hdr_info.server_response.get_age();
- @@ -7267,7 +7268,7 @@ HttpTransact::calculate_document_freshness_limit(State *s, HTTPHdr *response, ti
- freshness_limit = (int)response->get_cooked_cc_max_age();
- DebugTxn("http_match", "calculate_document_freshness_limit --- max_age set, freshness_limit = %d", freshness_limit);
- }
- - freshness_limit = min(max(0, freshness_limit), (int)s->txn_conf->cache_guaranteed_max_lifetime);
- + freshness_limit = std::min(std::max(0, freshness_limit), (int)s->txn_conf->cache_guaranteed_max_lifetime);
- } else {
- date_set = last_modified_set = false;
- @@ -7304,7 +7305,7 @@ HttpTransact::calculate_document_freshness_limit(State *s, HTTPHdr *response, ti
- DebugTxn("http_match", "calculate_document_freshness_limit --- Expires: %" PRId64 ", Date: %" PRId64 ", freshness_limit = %d",
- (int64_t)expires_value, (int64_t)date_value, freshness_limit);
- - freshness_limit = min(max(0, freshness_limit), (int)s->txn_conf->cache_guaranteed_max_lifetime);
- + freshness_limit = std::min(std::max(0, freshness_limit), (int)s->txn_conf->cache_guaranteed_max_lifetime);
- } else {
- last_modified_value = 0;
- if (response->presence(MIME_PRESENCE_LAST_MODIFIED)) {
- @@ -7328,7 +7329,7 @@ HttpTransact::calculate_document_freshness_limit(State *s, HTTPHdr *response, ti
- ink_assert((f >= 0.0) && (f <= 1.0));
- ink_time_t time_since_last_modify = date_value - last_modified_value;
- int h_freshness = (int)(time_since_last_modify * f);
- - freshness_limit = max(h_freshness, 0);
- + freshness_limit = std::max(h_freshness, 0);
- DebugTxn("http_match", "calculate_document_freshness_limit --- heuristic: date=%" PRId64 ", lm=%" PRId64
- ", time_since_last_modify=%" PRId64 ", f=%g, freshness_limit = %d",
- (int64_t)date_value, (int64_t)last_modified_value, (int64_t)time_since_last_modify, f, freshness_limit);
- @@ -7340,13 +7341,13 @@ HttpTransact::calculate_document_freshness_limit(State *s, HTTPHdr *response, ti
- }
- // The freshness limit must always fall within the min and max guaranteed bounds.
- - min_freshness_bounds = max((MgmtInt)0, s->txn_conf->cache_guaranteed_min_lifetime);
- + min_freshness_bounds = std::max((MgmtInt)0, s->txn_conf->cache_guaranteed_min_lifetime);
- max_freshness_bounds = s->txn_conf->cache_guaranteed_max_lifetime;
- // Heuristic freshness can be more strict.
- if (*heuristic) {
- - min_freshness_bounds = max(min_freshness_bounds, s->txn_conf->cache_heuristic_min_lifetime);
- - max_freshness_bounds = min(max_freshness_bounds, s->txn_conf->cache_heuristic_max_lifetime);
- + min_freshness_bounds = std::max(min_freshness_bounds, s->txn_conf->cache_heuristic_min_lifetime);
- + max_freshness_bounds = std::min(max_freshness_bounds, s->txn_conf->cache_heuristic_max_lifetime);
- }
- // Now clip the freshness limit.
- if (freshness_limit > max_freshness_bounds) {
- @@ -7387,12 +7388,12 @@ HttpTransact::calculate_freshness_fuzz(State *s, int fresh_limit)
- if (s->txn_conf->freshness_fuzz_min_time > 0) {
- // Complicated calculations to try to find a reasonable fuzz time between fuzz_min_time and fuzz_time
- int fresh_small = (int)rint((double)s->txn_conf->freshness_fuzz_min_time *
- - pow(2, min((double)fresh_limit / (double)s->txn_conf->freshness_fuzz_time,
- - sqrt((double)s->txn_conf->freshness_fuzz_time))));
- - int fresh_large = max((int)s->txn_conf->freshness_fuzz_min_time,
- - (int)rint(s->txn_conf->freshness_fuzz_time *
- - log10((double)(fresh_limit - s->txn_conf->freshness_fuzz_min_time) / LOG_YEAR)));
- - result = min(fresh_small, fresh_large);
- + pow(2, std::min((double)fresh_limit / (double)s->txn_conf->freshness_fuzz_time,
- + sqrt((double)s->txn_conf->freshness_fuzz_time))));
- + int fresh_large = std::max((int)s->txn_conf->freshness_fuzz_min_time,
- + (int)rint(s->txn_conf->freshness_fuzz_time *
- + log10((double)(fresh_limit - s->txn_conf->freshness_fuzz_min_time) / LOG_YEAR)));
- + result = std::min(fresh_small, fresh_large);
- DebugTxn("http_match", "calculate_freshness_fuzz using min/max --- freshness fuzz = %d", result);
- } else {
- result = s->txn_conf->freshness_fuzz_time;
- @@ -7472,8 +7473,8 @@ HttpTransact::what_is_document_freshness(State *s, HTTPHdr *client_request, HTTP
- // documents at the same time
- if ((s->txn_conf->freshness_fuzz_time > 0) && (s->txn_conf->freshness_fuzz_prob > 0.0)) {
- fresh_limit = fresh_limit - calculate_freshness_fuzz(s, fresh_limit);
- - fresh_limit = max(0, fresh_limit);
- - fresh_limit = min((int)s->txn_conf->cache_guaranteed_max_lifetime, fresh_limit);
- + fresh_limit = std::max(0, fresh_limit);
- + fresh_limit = std::min((int)s->txn_conf->cache_guaranteed_max_lifetime, fresh_limit);
- }
- current_age = HttpTransactHeaders::calculate_document_age(s->request_sent_time, s->response_received_time, cached_obj_response,
- @@ -7483,7 +7484,7 @@ HttpTransact::what_is_document_freshness(State *s, HTTPHdr *client_request, HTTP
- if (current_age < 0) {
- current_age = s->txn_conf->cache_guaranteed_max_lifetime;
- } else {
- - current_age = min((time_t)s->txn_conf->cache_guaranteed_max_lifetime, current_age);
- + current_age = std::min((time_t)s->txn_conf->cache_guaranteed_max_lifetime, current_age);
- }
- DebugTxn("http_match", "[what_is_document_freshness] fresh_limit: %d current_age: %" PRId64, fresh_limit, (int64_t)current_age);
- @@ -7560,7 +7561,7 @@ HttpTransact::what_is_document_freshness(State *s, HTTPHdr *client_request, HTTP
- // if min-fresh set, constrain the freshness limit //
- /////////////////////////////////////////////////////
- if (cooked_cc_mask & MIME_COOKED_MASK_CC_MIN_FRESH) {
- - age_limit = min(age_limit, fresh_limit - client_request->get_cooked_cc_min_fresh());
- + age_limit = std::min(age_limit, fresh_limit - client_request->get_cooked_cc_min_fresh());
- DebugTxn("http_match", "[..._document_freshness] min_fresh set, age limit: %d", age_limit);
- }
- ///////////////////////////////////////////////////
- @@ -7571,7 +7572,7 @@ HttpTransact::what_is_document_freshness(State *s, HTTPHdr *client_request, HTTP
- if (age_val == 0) {
- do_revalidate = true;
- }
- - age_limit = min(age_limit, age_val);
- + age_limit = std::min(age_limit, age_val);
- DebugTxn("http_match", "[..._document_freshness] min_fresh set, age limit: %d", age_limit);
- }
- }
- @@ -8870,7 +8871,7 @@ HttpTransact::update_size_and_time_stats(State *s, ink_hrtime total_time, ink_hr
- switch (s->state_machine->background_fill) {
- case BACKGROUND_FILL_COMPLETED: {
- int64_t bg_size = origin_server_response_body_size - user_agent_response_body_size;
- - bg_size = max((int64_t)0, bg_size);
- + bg_size = std::max((int64_t)0, bg_size);
- HTTP_SUM_DYN_STAT(http_background_fill_bytes_completed_stat, bg_size);
- break;
- }
- diff --git a/proxy/http/HttpTransactHeaders.cc b/proxy/http/HttpTransactHeaders.cc
- index d3844c7a9..eba47c207 100644
- --- a/proxy/http/HttpTransactHeaders.cc
- +++ b/proxy/http/HttpTransactHeaders.cc
- @@ -409,7 +409,7 @@ HttpTransactHeaders::calculate_document_age(ink_time_t request_time, ink_time_t
- // Deal with clock skew. Sigh.
- //
- // TODO solve this global clock problem
- - now_value = max(now, response_time);
- + now_value = std::max(now, response_time);
- ink_assert(response_time >= 0);
- ink_assert(request_time >= 0);
- @@ -417,12 +417,12 @@ HttpTransactHeaders::calculate_document_age(ink_time_t request_time, ink_time_t
- ink_assert(now_value >= response_time);
- if (date_value > 0) {
- - apparent_age = max((time_t)0, (response_time - date_value));
- + apparent_age = std::max((time_t)0, (response_time - date_value));
- }
- if (age_value < 0) {
- current_age = -1; // Overflow from Age: header
- } else {
- - corrected_received_age = max(apparent_age, age_value);
- + corrected_received_age = std::max(apparent_age, age_value);
- response_delay = response_time - request_time;
- corrected_initial_age = corrected_received_age + response_delay;
- resident_time = now_value - response_time;
- diff --git a/proxy/http/HttpTunnel.cc b/proxy/http/HttpTunnel.cc
- index d9fc59d18..d21e79dc7 100644
- --- a/proxy/http/HttpTunnel.cc
- +++ b/proxy/http/HttpTunnel.cc
- @@ -233,7 +233,7 @@ ChunkedHandler::transfer_bytes()
- // Handle the case where we are doing chunked passthrough.
- if (!dechunked_buffer) {
- - moved = MIN(bytes_left, chunked_reader->read_avail());
- + moved = std::min(bytes_left, chunked_reader->read_avail());
- chunked_reader->consume(moved);
- bytes_left = bytes_left - moved;
- return moved;
- @@ -242,7 +242,7 @@ ChunkedHandler::transfer_bytes()
- while (bytes_left > 0) {
- block_read_avail = chunked_reader->block_read_avail();
- - to_move = MIN(bytes_left, block_read_avail);
- + to_move = std::min(bytes_left, block_read_avail);
- if (to_move <= 0) {
- break;
- }
- @@ -374,7 +374,7 @@ ChunkedHandler::generate_chunked_content()
- }
- while ((r_avail = dechunked_reader->read_avail()) > 0 && state != CHUNK_WRITE_DONE) {
- - int64_t write_val = MIN(max_chunk_size, r_avail);
- + int64_t write_val = std::min(max_chunk_size, r_avail);
- state = CHUNK_WRITE_CHUNK;
- Debug("http_chunk", "creating a chunk of size %" PRId64 " bytes", write_val);
- diff --git a/proxy/http2/HTTP2.cc b/proxy/http2/HTTP2.cc
- index 67af7b695..85c10b5c8 100644
- --- a/proxy/http2/HTTP2.cc
- +++ b/proxy/http2/HTTP2.cc
- @@ -586,7 +586,7 @@ http2_encode_header_blocks(HTTPHdr *in, uint8_t *out, uint32_t out_len, uint32_t
- int32_t maximum_table_size)
- {
- // Limit the maximum table size to 64kB, which is the size advertised by major clients
- - maximum_table_size = min(maximum_table_size, HTTP2_MAX_TABLE_SIZE_LIMIT);
- + maximum_table_size = std::min(maximum_table_size, HTTP2_MAX_TABLE_SIZE_LIMIT);
- // Set maximum table size only if it is different from current maximum size
- if (maximum_table_size == hpack_get_maximum_table_size(handle)) {
- maximum_table_size = -1;
- @@ -661,7 +661,11 @@ http2_decode_header_blocks(HTTPHdr *hdr, const uint8_t *buf_start, const uint32_
- // rfc7540,sec8.1.2.2: Any message containing connection-specific header
- // fields MUST be treated as malformed
- - if (hdr->field_find(MIME_FIELD_CONNECTION, MIME_LEN_CONNECTION) != nullptr) {
- + if (hdr->field_find(MIME_FIELD_CONNECTION, MIME_LEN_CONNECTION) != nullptr ||
- + hdr->field_find(MIME_FIELD_KEEP_ALIVE, MIME_LEN_KEEP_ALIVE) != nullptr ||
- + hdr->field_find(MIME_FIELD_PROXY_CONNECTION, MIME_LEN_PROXY_CONNECTION) != nullptr ||
- + hdr->field_find(MIME_FIELD_TRANSFER_ENCODING, MIME_LEN_TRANSFER_ENCODING) != nullptr ||
- + hdr->field_find(MIME_FIELD_UPGRADE, MIME_LEN_UPGRADE) != nullptr) {
- return Http2ErrorCode::HTTP2_ERROR_PROTOCOL_ERROR;
- }
- diff --git a/proxy/http2/Http2ConnectionState.cc b/proxy/http2/Http2ConnectionState.cc
- index 2e684c490..c38c919ba 100644
- --- a/proxy/http2/Http2ConnectionState.cc
- +++ b/proxy/http2/Http2ConnectionState.cc
- @@ -30,7 +30,7 @@
- #define DebugHttp2Con(ua_session, fmt, ...) \
- DebugSsn(ua_session, "http2_con", "[%" PRId64 "] " fmt, ua_session->connection_id(), ##__VA_ARGS__);
- -#define DebugHttp2Stream(ua_session, stream_id, fmt, ...) \
- +#define Http2StreamDebug(ua_session, stream_id, fmt, ...) \
- DebugSsn(ua_session, "http2_con", "[%" PRId64 "] [%u] " fmt, ua_session->connection_id(), stream_id, ##__VA_ARGS__);
- using http2_frame_dispatch = Http2Error (*)(Http2ConnectionState &, const Http2Frame &);
- @@ -71,7 +71,7 @@ rcv_data_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- uint8_t pad_length = 0;
- const uint32_t payload_length = frame.header().length;
- - DebugHttp2Stream(cstate.ua_session, id, "Received DATA frame");
- + Http2StreamDebug(cstate.ua_session, id, "Received DATA frame");
- // If a DATA frame is received whose stream identifier field is 0x0, the
- // recipient MUST
- @@ -167,7 +167,7 @@ rcv_data_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- myreader->writer()->dealloc_reader(myreader);
- uint32_t initial_rwnd = cstate.server_settings.get(HTTP2_SETTINGS_INITIAL_WINDOW_SIZE);
- - uint32_t min_rwnd = min(initial_rwnd, cstate.server_settings.get(HTTP2_SETTINGS_MAX_FRAME_SIZE));
- + uint32_t min_rwnd = std::min(initial_rwnd, cstate.server_settings.get(HTTP2_SETTINGS_MAX_FRAME_SIZE));
- // Connection level WINDOW UPDATE
- if (cstate.server_rwnd <= min_rwnd) {
- Http2WindowSize diff_size = initial_rwnd - cstate.server_rwnd;
- @@ -199,7 +199,7 @@ rcv_headers_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- const Http2StreamId stream_id = frame.header().streamid;
- const uint32_t payload_length = frame.header().length;
- - DebugHttp2Stream(cstate.ua_session, stream_id, "Received HEADERS frame");
- + Http2StreamDebug(cstate.ua_session, stream_id, "Received HEADERS frame");
- if (!http2_is_client_streamid(stream_id)) {
- return Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_CONNECTION, Http2ErrorCode::HTTP2_ERROR_PROTOCOL_ERROR,
- @@ -284,7 +284,7 @@ rcv_headers_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- stream->priority_node = node;
- node->t = stream;
- } else {
- - DebugHttp2Stream(cstate.ua_session, stream_id, "PRIORITY - dep: %d, weight: %d, excl: %d, tree size: %d",
- + Http2StreamDebug(cstate.ua_session, stream_id, "HEADER PRIORITY - dep: %d, weight: %d, excl: %d, tree size: %d",
- params.priority.stream_dependency, params.priority.weight, params.priority.exclusive_flag,
- cstate.dependency_tree->size());
- @@ -343,7 +343,7 @@ rcv_headers_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- } else {
- // NOTE: Expect CONTINUATION Frame. Do NOT change state of stream or decode
- // Header Blocks.
- - DebugHttp2Stream(cstate.ua_session, stream_id, "No END_HEADERS flag, expecting CONTINUATION frame");
- + Http2StreamDebug(cstate.ua_session, stream_id, "No END_HEADERS flag, expecting CONTINUATION frame");
- cstate.set_continued_stream_id(stream_id);
- }
- @@ -360,7 +360,7 @@ rcv_priority_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- const Http2StreamId stream_id = frame.header().streamid;
- const uint32_t payload_length = frame.header().length;
- - DebugHttp2Stream(cstate.ua_session, stream_id, "Received PRIORITY frame");
- + Http2StreamDebug(cstate.ua_session, stream_id, "Received PRIORITY frame");
- // If a PRIORITY frame is received with a stream identifier of 0x0, the
- // recipient MUST respond with a connection error of type PROTOCOL_ERROR.
- @@ -395,14 +395,14 @@ rcv_priority_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- "PRIORITY frame depends on itself");
- }
- - DebugHttp2Stream(cstate.ua_session, stream_id, "PRIORITY - dep: %d, weight: %d, excl: %d, tree size: %d",
- + Http2StreamDebug(cstate.ua_session, stream_id, "PRIORITY - dep: %d, weight: %d, excl: %d, tree size: %d",
- priority.stream_dependency, priority.weight, priority.exclusive_flag, cstate.dependency_tree->size());
- Http2DependencyTree::Node *node = cstate.dependency_tree->find(stream_id);
- if (node != nullptr) {
- // [RFC 7540] 5.3.3 Reprioritization
- - DebugHttp2Stream(cstate.ua_session, stream_id, "Reprioritize");
- + Http2StreamDebug(cstate.ua_session, stream_id, "Reprioritize");
- cstate.dependency_tree->reprioritize(node, priority.stream_dependency, priority.exclusive_flag);
- } else {
- // PRIORITY frame is received before HEADERS frame.
- @@ -425,7 +425,7 @@ rcv_rst_stream_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- char *end;
- const Http2StreamId stream_id = frame.header().streamid;
- - DebugHttp2Stream(cstate.ua_session, frame.header().streamid, "Received RST_STREAM frame");
- + Http2StreamDebug(cstate.ua_session, frame.header().streamid, "Received RST_STREAM frame");
- // RST_STREAM frames MUST be associated with a stream. If a RST_STREAM
- // frame is received with a stream identifier of 0x0, the recipient MUST
- @@ -468,7 +468,7 @@ rcv_rst_stream_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- }
- if (stream != nullptr) {
- - DebugHttp2Stream(cstate.ua_session, stream_id, "RST_STREAM: Error Code: %u", rst_stream.error_code);
- + Http2StreamDebug(cstate.ua_session, stream_id, "RST_STREAM: Error Code: %u", rst_stream.error_code);
- cstate.delete_stream(stream);
- }
- @@ -484,7 +484,7 @@ rcv_settings_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- unsigned nbytes = 0;
- const Http2StreamId stream_id = frame.header().streamid;
- - DebugHttp2Stream(cstate.ua_session, stream_id, "Received SETTINGS frame");
- + Http2StreamDebug(cstate.ua_session, stream_id, "Received SETTINGS frame");
- // [RFC 7540] 6.5. The stream identifier for a SETTINGS frame MUST be zero.
- // If an endpoint receives a SETTINGS frame whose stream identifier field is
- @@ -533,7 +533,7 @@ rcv_settings_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- }
- }
- - DebugHttp2Stream(cstate.ua_session, stream_id, " %s : %u", Http2DebugNames::get_settings_param_name(param.id), param.value);
- + Http2StreamDebug(cstate.ua_session, stream_id, " %s : %u", Http2DebugNames::get_settings_param_name(param.id), param.value);
- // [RFC 7540] 6.9.2. When the value of SETTINGS_INITIAL_WINDOW_SIZE
- // changes, a receiver MUST adjust the size of all stream flow control
- @@ -557,7 +557,7 @@ rcv_settings_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- static Http2Error
- rcv_push_promise_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- {
- - DebugHttp2Stream(cstate.ua_session, frame.header().streamid, "Received PUSH_PROMISE frame");
- + Http2StreamDebug(cstate.ua_session, frame.header().streamid, "Received PUSH_PROMISE frame");
- // [RFC 7540] 8.2. A client cannot push. Thus, servers MUST treat the receipt of a
- // PUSH_PROMISE frame as a connection error of type PROTOCOL_ERROR.
- @@ -571,7 +571,7 @@ rcv_ping_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- uint8_t opaque_data[HTTP2_PING_LEN];
- const Http2StreamId stream_id = frame.header().streamid;
- - DebugHttp2Stream(cstate.ua_session, stream_id, "Received PING frame");
- + Http2StreamDebug(cstate.ua_session, stream_id, "Received PING frame");
- // If a PING frame is received with a stream identifier field value other
- // than 0x0, the recipient MUST respond with a connection error of type
- @@ -608,7 +608,7 @@ rcv_goaway_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- unsigned nbytes = 0;
- const Http2StreamId stream_id = frame.header().streamid;
- - DebugHttp2Stream(cstate.ua_session, stream_id, "Received GOAWAY frame");
- + Http2StreamDebug(cstate.ua_session, stream_id, "Received GOAWAY frame");
- // An endpoint MUST treat a GOAWAY frame with a stream identifier other
- // than 0x0 as a connection error of type PROTOCOL_ERROR.
- @@ -626,7 +626,7 @@ rcv_goaway_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- }
- }
- - DebugHttp2Stream(cstate.ua_session, stream_id, "GOAWAY: last stream id=%d, error code=%d", goaway.last_streamid,
- + Http2StreamDebug(cstate.ua_session, stream_id, "GOAWAY: last stream id=%d, error code=%d", goaway.last_streamid,
- static_cast<int>(goaway.error_code));
- cstate.handleEvent(HTTP2_SESSION_EVENT_FINI, nullptr);
- @@ -645,7 +645,7 @@ rcv_window_update_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- // A WINDOW_UPDATE frame with a length other than 4 octets MUST be
- // treated as a connection error of type FRAME_SIZE_ERROR.
- if (frame.header().length != HTTP2_WINDOW_UPDATE_LEN) {
- - DebugHttp2Stream(cstate.ua_session, stream_id, "Received WINDOW_UPDATE frame - length incorrect");
- + Http2StreamDebug(cstate.ua_session, stream_id, "Received WINDOW_UPDATE frame - length incorrect");
- return Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_CONNECTION, Http2ErrorCode::HTTP2_ERROR_FRAME_SIZE_ERROR,
- "window update bad length");
- }
- @@ -667,7 +667,7 @@ rcv_window_update_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- if (stream_id == 0) {
- // Connection level window update
- - DebugHttp2Stream(cstate.ua_session, stream_id, "Received WINDOW_UPDATE frame - updated to: %zd delta: %u",
- + Http2StreamDebug(cstate.ua_session, stream_id, "Received WINDOW_UPDATE frame - updated to: %zd delta: %u",
- (cstate.client_rwnd + size), size);
- // A sender MUST NOT allow a flow-control window to exceed 2^31-1
- @@ -697,7 +697,7 @@ rcv_window_update_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- }
- }
- - DebugHttp2Stream(cstate.ua_session, stream_id, "Received WINDOW_UPDATE frame - updated to: %zd delta: %u",
- + Http2StreamDebug(cstate.ua_session, stream_id, "Received WINDOW_UPDATE frame - updated to: %zd delta: %u",
- (stream->client_rwnd + size), size);
- // A sender MUST NOT allow a flow-control window to exceed 2^31-1
- @@ -713,7 +713,7 @@ rcv_window_update_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- }
- stream->client_rwnd += size;
- - ssize_t wnd = min(cstate.client_rwnd, stream->client_rwnd);
- + ssize_t wnd = std::min(cstate.client_rwnd, stream->client_rwnd);
- if (!stream->is_closed() && stream->get_state() == Http2StreamState::HTTP2_STREAM_STATE_HALF_CLOSED_REMOTE && wnd > 0) {
- stream->send_response_body();
- @@ -736,7 +736,7 @@ rcv_continuation_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- const Http2StreamId stream_id = frame.header().streamid;
- const uint32_t payload_length = frame.header().length;
- - DebugHttp2Stream(cstate.ua_session, stream_id, "Received CONTINUATION frame");
- + Http2StreamDebug(cstate.ua_session, stream_id, "Received CONTINUATION frame");
- if (!http2_is_client_streamid(stream_id)) {
- return Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_CONNECTION, Http2ErrorCode::HTTP2_ERROR_PROTOCOL_ERROR,
- @@ -814,7 +814,7 @@ rcv_continuation_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
- stream->send_request(cstate);
- } else {
- // NOTE: Expect another CONTINUATION Frame. Do nothing.
- - DebugHttp2Stream(cstate.ua_session, stream_id, "No END_HEADERS flag, expecting CONTINUATION frame");
- + Http2StreamDebug(cstate.ua_session, stream_id, "No END_HEADERS flag, expecting CONTINUATION frame");
- }
- return Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_NONE);
- @@ -890,7 +890,7 @@ Http2ConnectionState::main_event_handler(int event, void *edata)
- // [RFC 7540] 5.5. Extending HTTP/2
- // Implementations MUST discard frames that have unknown or unsupported types.
- if (frame->header().type >= HTTP2_FRAME_TYPE_MAX) {
- - DebugHttp2Stream(ua_session, stream_id, "Discard a frame which has unknown type, type=%x", frame->header().type);
- + Http2StreamDebug(ua_session, stream_id, "Discard a frame which has unknown type, type=%x", frame->header().type);
- break;
- }
- @@ -1067,7 +1067,7 @@ Http2ConnectionState::restart_streams()
- s = next;
- }
- if (!s->is_closed() && s->get_state() == Http2StreamState::HTTP2_STREAM_STATE_HALF_CLOSED_REMOTE &&
- - min(this->client_rwnd, s->client_rwnd) > 0) {
- + std::min(this->client_rwnd, s->client_rwnd) > 0) {
- s->send_response_body();
- }
- @@ -1100,13 +1100,14 @@ bool
- Http2ConnectionState::delete_stream(Http2Stream *stream)
- {
- ink_assert(nullptr != stream);
- + SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
- // If stream has already been removed from the list, just go on
- if (!stream_list.in(stream)) {
- return false;
- }
- - DebugHttp2Stream(ua_session, stream->get_id(), "Delete stream");
- + Http2StreamDebug(ua_session, stream->get_id(), "Delete stream");
- if (Http2::stream_priority_enabled) {
- Http2DependencyTree::Node *node = stream->priority_node;
- @@ -1115,10 +1116,12 @@ Http2ConnectionState::delete_stream(Http2Stream *stream)
- dependency_tree->deactivate(node, 0);
- }
- dependency_tree->remove(node);
- + // ink_release_assert(dependency_tree->find(stream->get_id()) == nullptr);
- }
- + stream->priority_node = nullptr;
- }
- - if (stream->get_state() == Http2StreamState::HTTP2_STREAM_STATE_HALF_CLOSED_LOCAL) {
- + if (stream->get_state() != Http2StreamState::HTTP2_STREAM_STATE_CLOSED) {
- send_rst_stream_frame(stream->get_id(), Http2ErrorCode::HTTP2_ERROR_NO_ERROR);
- }
- @@ -1141,7 +1144,6 @@ Http2ConnectionState::release_stream(Http2Stream *stream)
- ink_assert(client_streams_out_count > 0);
- --client_streams_out_count;
- }
- - stream_list.remove(stream);
- }
- if (ua_session) {
- @@ -1177,7 +1179,7 @@ Http2ConnectionState::update_initial_rwnd(Http2WindowSize new_size)
- void
- Http2ConnectionState::schedule_stream(Http2Stream *stream)
- {
- - DebugHttp2Stream(ua_session, stream->get_id(), "Scheduled");
- + Http2StreamDebug(ua_session, stream->get_id(), "Scheduled");
- Http2DependencyTree::Node *node = stream->priority_node;
- ink_release_assert(node != nullptr);
- @@ -1205,13 +1207,13 @@ Http2ConnectionState::send_data_frames_depends_on_priority()
- Http2Stream *stream = static_cast<Http2Stream *>(node->t);
- ink_release_assert(stream != nullptr);
- - DebugHttp2Stream(ua_session, stream->get_id(), "top node, point=%d", node->point);
- + Http2StreamDebug(ua_session, stream->get_id(), "top node, point=%d", node->point);
- - size_t len = 0;
- - Http2SendADataFrameResult result = send_a_data_frame(stream, len);
- + size_t len = 0;
- + Http2SendDataFrameResult result = send_a_data_frame(stream, len);
- switch (result) {
- - case HTTP2_SEND_A_DATA_FRAME_NO_ERROR: {
- + case Http2SendDataFrameResult::NO_ERROR: {
- // No response body to send
- if (len == 0 && !stream->is_body_done()) {
- dependency_tree->deactivate(node, len);
- @@ -1220,7 +1222,7 @@ Http2ConnectionState::send_data_frames_depends_on_priority()
- }
- break;
- }
- - case HTTP2_SEND_A_DATA_FRAME_DONE: {
- + case Http2SendDataFrameResult::DONE: {
- dependency_tree->deactivate(node, len);
- delete_stream(stream);
- break;
- @@ -1235,12 +1237,12 @@ Http2ConnectionState::send_data_frames_depends_on_priority()
- return;
- }
- -Http2SendADataFrameResult
- +Http2SendDataFrameResult
- Http2ConnectionState::send_a_data_frame(Http2Stream *stream, size_t &payload_length)
- {
- - const ssize_t window_size = min(this->client_rwnd, stream->client_rwnd);
- + const ssize_t window_size = std::min(this->client_rwnd, stream->client_rwnd);
- const size_t buf_len = BUFFER_SIZE_FOR_INDEX(buffer_size_index[HTTP2_FRAME_TYPE_DATA]);
- - const size_t write_available_size = min(buf_len, static_cast<size_t>(window_size));
- + const size_t write_available_size = std::min(buf_len, static_cast<size_t>(window_size));
- size_t read_available_size = 0;
- uint8_t flags = 0x00;
- @@ -1257,7 +1259,7 @@ Http2ConnectionState::send_a_data_frame(Http2Stream *stream, size_t &payload_len
- if (read_available_size > 0) {
- // We only need to check for window size when there is a payload
- if (window_size <= 0) {
- - return HTTP2_SEND_A_DATA_FRAME_NO_WINDOW;
- + return Http2SendDataFrameResult::NO_WINDOW;
- }
- // Copy into the payload buffer. Seems like we should be able to skip this copy step
- payload_length = current_reader->read(payload_buffer, write_available_size);
- @@ -1269,7 +1271,7 @@ Http2ConnectionState::send_a_data_frame(Http2Stream *stream, size_t &payload_len
- // If we return here, we never send the END_STREAM in the case of a early terminating OS.
- // OK if there is no body yet. Otherwise continue on to send a DATA frame and delete the stream
- if (!stream->is_body_done() && payload_length == 0) {
- - return HTTP2_SEND_A_DATA_FRAME_NO_PAYLOAD;
- + return Http2SendDataFrameResult::NO_PAYLOAD;
- }
- if (stream->is_body_done() && read_available_size <= write_available_size) {
- @@ -1281,7 +1283,7 @@ Http2ConnectionState::send_a_data_frame(Http2Stream *stream, size_t &payload_len
- stream->client_rwnd -= payload_length;
- // Create frame
- - DebugHttp2Stream(ua_session, stream->get_id(), "Send a DATA frame - client window con: %zd stream: %zd payload: %zd", client_rwnd,
- + Http2StreamDebug(ua_session, stream->get_id(), "Send a DATA frame - client window con: %zd stream: %zd payload: %zd", client_rwnd,
- stream->client_rwnd, payload_length);
- Http2Frame data(HTTP2_FRAME_TYPE_DATA, stream->get_id(), flags);
- @@ -1296,47 +1298,45 @@ Http2ConnectionState::send_a_data_frame(Http2Stream *stream, size_t &payload_len
- this->ua_session->handleEvent(HTTP2_SESSION_EVENT_XMIT, &data);
- if (flags & HTTP2_FLAGS_DATA_END_STREAM) {
- - DebugHttp2Stream(ua_session, stream->get_id(), "End of DATA frame");
- + Http2StreamDebug(ua_session, stream->get_id(), "End of DATA frame");
- stream->send_end_stream = true;
- // Setting to the same state shouldn't be erroneous
- stream->change_state(data.header().type, data.header().flags);
- - return HTTP2_SEND_A_DATA_FRAME_DONE;
- + return Http2SendDataFrameResult::DONE;
- }
- - return HTTP2_SEND_A_DATA_FRAME_NO_ERROR;
- + return Http2SendDataFrameResult::NO_ERROR;
- }
- -void
- +Http2SendDataFrameResult
- Http2ConnectionState::send_data_frames(Http2Stream *stream)
- {
- // To follow RFC 7540 must not send more frames other than priority on
- // a closed stream. So we return without sending
- if (stream->get_state() == Http2StreamState::HTTP2_STREAM_STATE_HALF_CLOSED_LOCAL ||
- stream->get_state() == Http2StreamState::HTTP2_STREAM_STATE_CLOSED) {
- - DebugSsn(this->ua_session, "http2_cs", "Shutdown half closed local stream %d", stream->get_id());
- + Http2StreamDebug(this->ua_session, stream->get_id(), "Shutdown half closed local stream");
- this->delete_stream(stream);
- - return;
- + return Http2SendDataFrameResult::NO_ERROR;
- }
- - size_t len = 0;
- - while (true) {
- - Http2SendADataFrameResult result = send_a_data_frame(stream, len);
- + size_t len = 0;
- + Http2SendDataFrameResult result = Http2SendDataFrameResult::NO_ERROR;
- + while (result == Http2SendDataFrameResult::NO_ERROR) {
- + result = send_a_data_frame(stream, len);
- - if (result == HTTP2_SEND_A_DATA_FRAME_DONE) {
- + if (result == Http2SendDataFrameResult::DONE) {
- // Delete a stream immediately
- // TODO its should not be deleted for a several time to handling
- // RST_STREAM and WINDOW_UPDATE.
- // See 'closed' state written at [RFC 7540] 5.1.
- - DebugSsn(this->ua_session, "http2_cs", "Shutdown stream %d", stream->get_id());
- + Http2StreamDebug(this->ua_session, stream->get_id(), "Shutdown stream");
- this->delete_stream(stream);
- - break;
- - } else if (result == HTTP2_SEND_A_DATA_FRAME_NO_ERROR) {
- - continue;
- - } else {
- - break;
- }
- }
- +
- + return result;
- }
- void
- @@ -1351,7 +1351,7 @@ Http2ConnectionState::send_headers_frame(Http2Stream *stream)
- HTTPHdr *resp_header = &stream->response_header;
- - DebugHttp2Stream(ua_session, stream->get_id(), "Send HEADERS frame");
- + Http2StreamDebug(ua_session, stream->get_id(), "Send HEADERS frame");
- HTTPHdr h2_hdr;
- http2_generate_h2_header_from_1_1(resp_header, &h2_hdr);
- @@ -1405,9 +1405,9 @@ Http2ConnectionState::send_headers_frame(Http2Stream *stream)
- // Send CONTINUATION frames
- flags = 0;
- while (sent < header_blocks_size) {
- - DebugHttp2Stream(ua_session, stream->get_id(), "Send CONTINUATION frame");
- - payload_length = MIN(static_cast<uint32_t>(BUFFER_SIZE_FOR_INDEX(buffer_size_index[HTTP2_FRAME_TYPE_CONTINUATION])),
- - header_blocks_size - sent);
- + Http2StreamDebug(ua_session, stream->get_id(), "Send CONTINUATION frame");
- + payload_length = std::min(static_cast<uint32_t>(BUFFER_SIZE_FOR_INDEX(buffer_size_index[HTTP2_FRAME_TYPE_CONTINUATION])),
- + static_cast<uint32_t>(header_blocks_size - sent));
- if (sent + payload_length == header_blocks_size) {
- flags |= HTTP2_FLAGS_CONTINUATION_END_HEADERS;
- }
- @@ -1441,7 +1441,7 @@ Http2ConnectionState::send_push_promise_frame(Http2Stream *stream, URL &url)
- return;
- }
- - DebugHttp2Stream(ua_session, stream->get_id(), "Send PUSH_PROMISE frame");
- + Http2StreamDebug(ua_session, stream->get_id(), "Send PUSH_PROMISE frame");
- h1_hdr.create(HTTP_TYPE_REQUEST);
- h1_hdr.url_set(&url);
- @@ -1487,9 +1487,9 @@ Http2ConnectionState::send_push_promise_frame(Http2Stream *stream, URL &url)
- // Send CONTINUATION frames
- flags = 0;
- while (sent < header_blocks_size) {
- - DebugHttp2Stream(ua_session, stream->get_id(), "Send CONTINUATION frame");
- - payload_length = MIN(static_cast<uint32_t>(BUFFER_SIZE_FOR_INDEX(buffer_size_index[HTTP2_FRAME_TYPE_CONTINUATION])),
- - header_blocks_size - sent);
- + Http2StreamDebug(ua_session, stream->get_id(), "Send CONTINUATION frame");
- + payload_length = std::min(static_cast<uint32_t>(BUFFER_SIZE_FOR_INDEX(buffer_size_index[HTTP2_FRAME_TYPE_CONTINUATION])),
- + static_cast<uint32_t>(header_blocks_size - sent));
- if (sent + payload_length == header_blocks_size) {
- flags |= HTTP2_FLAGS_CONTINUATION_END_HEADERS;
- }
- @@ -1515,7 +1515,7 @@ Http2ConnectionState::send_push_promise_frame(Http2Stream *stream, URL &url)
- if (node != nullptr) {
- stream->priority_node = node;
- } else {
- - DebugHttp2Stream(this->ua_session, id, "PRIORITY - dep: %d, weight: %d, excl: %d, tree size: %d",
- + Http2StreamDebug(this->ua_session, id, "PRIORITY - dep: %d, weight: %d, excl: %d, tree size: %d",
- HTTP2_PRIORITY_DEFAULT_STREAM_DEPENDENCY, HTTP2_PRIORITY_DEFAULT_WEIGHT, false,
- this->dependency_tree->size());
- @@ -1534,7 +1534,7 @@ Http2ConnectionState::send_push_promise_frame(Http2Stream *stream, URL &url)
- void
- Http2ConnectionState::send_rst_stream_frame(Http2StreamId id, Http2ErrorCode ec)
- {
- - DebugHttp2Stream(ua_session, id, "Send RST_STREAM frame");
- + Http2StreamDebug(ua_session, id, "Send RST_STREAM frame");
- if (ec != Http2ErrorCode::HTTP2_ERROR_NO_ERROR) {
- HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_STREAM_ERRORS_COUNT, this_ethread());
- @@ -1568,7 +1568,7 @@ Http2ConnectionState::send_settings_frame(const Http2ConnectionSettings &new_set
- {
- const Http2StreamId stream_id = 0;
- - DebugHttp2Stream(ua_session, stream_id, "Send SETTINGS frame");
- + Http2StreamDebug(ua_session, stream_id, "Send SETTINGS frame");
- Http2Frame settings(HTTP2_FRAME_TYPE_SETTINGS, stream_id, 0);
- settings.alloc(buffer_size_index[HTTP2_FRAME_TYPE_SETTINGS]);
- @@ -1599,7 +1599,7 @@ Http2ConnectionState::send_settings_frame(const Http2ConnectionSettings &new_set
- // Update current settings
- server_settings.set(id, new_settings.get(id));
- - DebugHttp2Stream(ua_session, stream_id, " %s : %u", Http2DebugNames::get_settings_param_name(param.id), param.value);
- + Http2StreamDebug(ua_session, stream_id, " %s : %u", Http2DebugNames::get_settings_param_name(param.id), param.value);
- }
- }
- @@ -1611,7 +1611,7 @@ Http2ConnectionState::send_settings_frame(const Http2ConnectionSettings &new_set
- void
- Http2ConnectionState::send_ping_frame(Http2StreamId id, uint8_t flag, const uint8_t *opaque_data)
- {
- - DebugHttp2Stream(ua_session, id, "Send PING frame");
- + Http2StreamDebug(ua_session, id, "Send PING frame");
- Http2Frame ping(HTTP2_FRAME_TYPE_PING, id, flag);
- @@ -1655,7 +1655,7 @@ Http2ConnectionState::send_goaway_frame(Http2StreamId id, Http2ErrorCode ec)
- void
- Http2ConnectionState::send_window_update_frame(Http2StreamId id, uint32_t size)
- {
- - DebugHttp2Stream(ua_session, id, "Send WINDOW_UPDATE frame");
- + Http2StreamDebug(ua_session, id, "Send WINDOW_UPDATE frame");
- // Create WINDOW_UPDATE frame
- Http2Frame window_update(HTTP2_FRAME_TYPE_WINDOW_UPDATE, id, 0x0);
- diff --git a/proxy/http2/Http2ConnectionState.h b/proxy/http2/Http2ConnectionState.h
- index ceabb1de6..2bd63a76f 100644
- --- a/proxy/http2/Http2ConnectionState.h
- +++ b/proxy/http2/Http2ConnectionState.h
- @@ -31,11 +31,11 @@
- class Http2ClientSession;
- -enum Http2SendADataFrameResult {
- - HTTP2_SEND_A_DATA_FRAME_NO_ERROR = 0,
- - HTTP2_SEND_A_DATA_FRAME_NO_WINDOW = 1,
- - HTTP2_SEND_A_DATA_FRAME_NO_PAYLOAD = 2,
- - HTTP2_SEND_A_DATA_FRAME_DONE = 3,
- +enum class Http2SendDataFrameResult {
- + NO_ERROR = 0,
- + NO_WINDOW = 1,
- + NO_PAYLOAD = 2,
- + DONE = 3,
- };
- class Http2ConnectionSettings
- @@ -234,8 +234,8 @@ public:
- // HTTP/2 frame sender
- void schedule_stream(Http2Stream *stream);
- void send_data_frames_depends_on_priority();
- - void send_data_frames(Http2Stream *stream);
- - Http2SendADataFrameResult send_a_data_frame(Http2Stream *stream, size_t &payload_length);
- + Http2SendDataFrameResult send_data_frames(Http2Stream *stream);
- + Http2SendDataFrameResult send_a_data_frame(Http2Stream *stream, size_t &payload_length);
- void send_headers_frame(Http2Stream *stream);
- void send_push_promise_frame(Http2Stream *stream, URL &url);
- void send_rst_stream_frame(Http2StreamId id, Http2ErrorCode ec);
- diff --git a/proxy/http2/Http2DependencyTree.h b/proxy/http2/Http2DependencyTree.h
- index f0a569257..39b21659c 100644
- --- a/proxy/http2/Http2DependencyTree.h
- +++ b/proxy/http2/Http2DependencyTree.h
- @@ -118,6 +118,7 @@ public:
- void activate(Node *node);
- void deactivate(Node *node, uint32_t sent);
- void update(Node *node, uint32_t sent);
- + bool in(Node *current, Node *node);
- uint32_t size() const;
- private:
- @@ -201,6 +202,7 @@ Tree<T>::add(uint32_t parent_id, uint32_t id, uint32_t weight, bool exclusive, T
- parent->children.push(node);
- if (!node->queue->empty()) {
- + ink_release_assert(!node->queued);
- parent->queue->push(node->entry);
- node->queued = true;
- }
- @@ -210,6 +212,27 @@ Tree<T>::add(uint32_t parent_id, uint32_t id, uint32_t weight, bool exclusive, T
- }
- template <typename T>
- +bool
- +Tree<T>::in(Node *current, Node *node)
- +{
- + bool retval = false;
- + if (current == nullptr)
- + current = _root;
- + if (current->queue->in(node->entry)) {
- + return true;
- + } else {
- + Node *child = current->children.head;
- + while (child) {
- + if (in(child, node)) {
- + return true;
- + }
- + child = child->link.next;
- + }
- + }
- + return retval;
- +}
- +
- +template <typename T>
- void
- Tree<T>::remove(Node *node)
- {
- @@ -241,6 +264,8 @@ Tree<T>::remove(Node *node)
- remove(parent);
- }
- + // ink_release_assert(!this->in(nullptr, node));
- +
- --_node_count;
- delete node;
- }
- diff --git a/proxy/http2/Http2Stream.cc b/proxy/http2/Http2Stream.cc
- index dc30e7800..7b5ed4a21 100644
- --- a/proxy/http2/Http2Stream.cc
- +++ b/proxy/http2/Http2Stream.cc
- @@ -26,6 +26,9 @@
- #include "Http2ClientSession.h"
- #include "../http/HttpSM.h"
- +#define Http2StreamDebug(fmt, ...) \
- + DebugSsn(parent, "http2_stream", "[%" PRId64 "] [%u] " fmt, parent->connection_id(), this->get_id(), ##__VA_ARGS__);
- +
- ClassAllocator<Http2Stream> http2StreamAllocator("http2StreamAllocator");
- int
- @@ -123,9 +126,7 @@ Http2Stream::main_event_handler(int event, void *edata)
- }
- reentrancy_count--;
- // Clean stream up if the terminate flag is set and we are at the bottom of the handler stack
- - if (terminate_stream && reentrancy_count == 0) {
- - destroy();
- - }
- + terminate_if_possible();
- return 0;
- }
- @@ -263,7 +264,7 @@ Http2Stream::change_state(uint8_t type, uint8_t flags)
- return false;
- }
- - Debug("http2_stream", "%s", Http2DebugNames::get_state_name(_state));
- + Http2StreamDebug("%s", Http2DebugNames::get_state_name(_state));
- return true;
- }
- @@ -314,26 +315,32 @@ void
- Http2Stream::do_io_close(int /* flags */)
- {
- SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
- - super::release(nullptr);
- +
- if (!closed) {
- - Debug("http2_stream", "do_io_close stream %d", this->get_id());
- + if (parent && this->is_client_state_writeable()) {
- + // Make sure any trailing end of stream frames are sent
- + // Wee will be removed at send_data_frames or closing connection phase
- + Http2SendDataFrameResult result = static_cast<Http2ClientSession *>(parent)->connection_state.send_data_frames(this);
- + if (result == Http2SendDataFrameResult::NO_WINDOW) {
- + Http2StreamDebug("cancel closing");
- + return;
- + } else {
- + Http2StreamDebug("continue closing");
- + }
- + }
- // When we get here, the SM has initiated the shutdown. Either it received a WRITE_COMPLETE, or it is shutting down. Any
- // remaining IO operations back to client should be abandoned. The SM-side buffers backing these operations will be deleted
- // by the time this is called from transaction_done.
- closed = true;
- - if (parent && this->is_client_state_writeable()) {
- - // Make sure any trailing end of stream frames are sent
- - // Wee will be removed at send_data_frames or closing connection phase
- - static_cast<Http2ClientSession *>(parent)->connection_state.send_data_frames(this);
- - }
- -
- clear_timers();
- clear_io_events();
- // Wait until transaction_done is called from HttpSM to signal that the TXN_CLOSE hook has been executed
- }
- +
- + super::release(nullptr);
- }
- /*
- @@ -358,9 +365,18 @@ Http2Stream::transaction_done()
- ink_assert(cross_thread_event == nullptr);
- // Schedule the destroy to occur after we unwind here. IF we call directly, may delete with reference on the stack.
- terminate_stream = true;
- - if (terminate_stream && reentrancy_count == 0) {
- - destroy();
- - }
- + terminate_if_possible();
- + }
- +}
- +
- +void
- +Http2Stream::terminate_if_possible()
- +{
- + if (terminate_stream && reentrancy_count == 0) {
- + Http2ClientSession *h2_parent = static_cast<Http2ClientSession *>(parent);
- + SCOPED_MUTEX_LOCK(lock, h2_parent->connection_state.mutex, this_ethread());
- + h2_parent->connection_state.delete_stream(this);
- + destroy();
- }
- }
- @@ -370,7 +386,7 @@ Http2Stream::initiating_close()
- {
- if (!closed) {
- SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
- - Debug("http2_stream", "initiating_close stream %d", this->get_id());
- + Http2StreamDebug("initiating_close");
- // Set the state of the connection to closed
- // TODO - these states should be combined
- @@ -398,11 +414,11 @@ Http2Stream::initiating_close()
- SCOPED_MUTEX_LOCK(lock, write_vio.mutex, this_ethread());
- // Are we done?
- if (write_vio.nbytes == write_vio.ndone) {
- - Debug("http2_stream", "handle write from destroy stream=%d event=%d", this->_id, VC_EVENT_WRITE_COMPLETE);
- + Http2StreamDebug("handle write from destroy (event=%d)", VC_EVENT_WRITE_COMPLETE);
- write_event = send_tracked_event(write_event, VC_EVENT_WRITE_COMPLETE, &write_vio);
- } else {
- write_event = send_tracked_event(write_event, VC_EVENT_EOS, &write_vio);
- - Debug("http2_stream", "handle write from destroy stream=%d event=%d", this->_id, VC_EVENT_EOS);
- + Http2StreamDebug("handle write from destroy (event=%d)", VC_EVENT_EOS);
- }
- sent_write_complete = true;
- }
- @@ -412,7 +428,7 @@ Http2Stream::initiating_close()
- // Only bother with the EOS if we haven't sent the write complete
- if (!sent_write_complete) {
- SCOPED_MUTEX_LOCK(lock, read_vio.mutex, this_ethread());
- - Debug("http2_stream", "send EOS to read cont stream=%d", this->_id);
- + Http2StreamDebug("send EOS to read cont");
- read_event = send_tracked_event(read_event, VC_EVENT_EOS, &read_vio);
- }
- } else if (current_reader) {
- @@ -607,7 +623,7 @@ Http2Stream::update_write_request(IOBufferReader *buf_reader, int64_t write_len,
- }
- }
- - Debug("http2_stream", "write update stream_id=%d event=%d", this->get_id(), send_event);
- + Http2StreamDebug("write update (event=%d)", send_event);
- }
- return retval;
- @@ -651,7 +667,7 @@ Http2Stream::reenable(VIO *vio)
- void
- Http2Stream::destroy()
- {
- - Debug("http2_stream", "Destroy stream %d, sent %" PRIu64 " bytes", this->_id, this->bytes_sent);
- + Http2StreamDebug("Destroy stream, sent %" PRIu64 " bytes", this->bytes_sent);
- SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
- // Clean up after yourself if this was an EOS
- ink_release_assert(this->closed);
- @@ -659,21 +675,14 @@ Http2Stream::destroy()
- // Safe to initiate SSN_CLOSE if this is the last stream
- if (parent) {
- - // release_stream and delete_stream indirectly call each other and seem to have a lot of commonality
- - // Should get resolved at somepoint.
- Http2ClientSession *h2_parent = static_cast<Http2ClientSession *>(parent);
- SCOPED_MUTEX_LOCK(lock, h2_parent->connection_state.mutex, this_ethread());
- - h2_parent->connection_state.release_stream(this);
- + // Make sure the stream is removed from the stream list and priority tree
- + // In many cases, this has been called earlier, so this call is a no-op
- + h2_parent->connection_state.delete_stream(this);
- - // Current Http2ConnectionState implementation uses a memory pool for instantiating streams and DLL<> stream_list for storing
- - // active streams. Destroying a stream before deleting it from stream_list and then creating a new one + reusing the same chunk
- - // from the memory pool right away always leads to destroying the DLL structure (deadlocks, inconsistencies).
- - // The following is meant as a safety net since the consequences are disastrous. Until the design/implementation changes it
- - // seems
- - // less error prone to (double) delete before destroying (noop if already deleted).
- - if (h2_parent->connection_state.delete_stream(this)) {
- - Warning("Http2Stream was about to be deallocated without removing it from the active stream list");
- - }
- + // Update session's stream counts, so it accurately goes into keep-alive state
- + h2_parent->connection_state.release_stream(this);
- }
- // Clean up the write VIO in case of inactivity timeout
- @@ -731,7 +740,7 @@ Http2Stream::response_initialize_data_handling(bool &is_done)
- int chunked_index = response_header.value_get_index(name, strlen(name), value, strlen(value));
- // -1 means this value was not found for this field
- if (chunked_index >= 0) {
- - Debug("http2_stream", "Response is chunked");
- + Http2StreamDebug("Response is chunked");
- chunked = true;
- this->chunked_handler.init_by_action(this->response_reader, ChunkedHandler::ACTION_DECHUNK);
- this->chunked_handler.state = ChunkedHandler::CHUNK_READ_SIZE;
- diff --git a/proxy/http2/Http2Stream.h b/proxy/http2/Http2Stream.h
- index ed28b545c..2261377c6 100644
- --- a/proxy/http2/Http2Stream.h
- +++ b/proxy/http2/Http2Stream.h
- @@ -168,6 +168,7 @@ public:
- VIO *do_io_write(Continuation *c, int64_t nbytes, IOBufferReader *abuffer, bool owner = false);
- void do_io_close(int lerrno = -1);
- void initiating_close();
- + void terminate_if_possible();
- void do_io_shutdown(ShutdownHowTo_t) {}
- void update_read_request(int64_t read_len, bool send_update);
- bool update_write_request(IOBufferReader *buf_reader, int64_t write_len, bool send_update);
- diff --git a/tools/jtest/jtest.cc b/tools/jtest/jtest.cc
- index 774a6ddff..730a88176 100644
- --- a/tools/jtest/jtest.cc
- +++ b/tools/jtest/jtest.cc
- @@ -516,7 +516,7 @@ max_limit_fd()
- if (getrlimit(RLIMIT_NOFILE, &rl) >= 0) {
- #ifdef OPEN_MAX
- // Darwin
- - rl.rlim_cur = MIN(OPEN_MAX, rl.rlim_max);
- + rl.rlim_cur = std::min(static_cast<rlim_t>(OPEN_MAX), rl.rlim_max);
- #else
- rl.rlim_cur = rl.rlim_max;
- #endif
- @@ -1962,7 +1962,7 @@ compose_all_urls(const char *tag, char *buf, char *start, char *end, int buflen,
- char old;
- while ((start = find_href_start(tag, end, buflen - (end - buf)))) {
- char newurl[512];
- - end = (char *)find_href_end(start, MIN(buflen - (start - buf), 512 - 10));
- + end = (char *)find_href_end(start, std::min(static_cast<int>(buflen - (start - buf)), 512 - 10));
- if (!end) {
- end = start + strlen(tag);
- continue;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement