Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/tscore/EnumDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
limitations under the License.
*/

#pragma once

#include <string_view>
#include <unordered_map>

Expand Down
2 changes: 1 addition & 1 deletion iocore/eventsystem/IOBuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ MIOBuffer::write(IOBufferBlock const *b, int64_t alen, int64_t offset)
continue;
}
int64_t bytes;
if (len < 0 || len >= max_bytes) {
if (len >= max_bytes) {
bytes = max_bytes;
} else {
bytes = len;
Expand Down
4 changes: 2 additions & 2 deletions iocore/hostdb/HostDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2209,7 +2209,7 @@ ParseHostLine(Ptr<RefCountedHostsFileMap> &map, char *l)
}

void
ParseHostFile(const char *path, unsigned int hostdb_hostfile_check_interval)
ParseHostFile(const char *path, unsigned int hostdb_hostfile_check_interval_parse)
{
Ptr<RefCountedHostsFileMap> parsed_hosts_file_ptr;

Expand All @@ -2229,7 +2229,7 @@ ParseHostFile(const char *path, unsigned int hostdb_hostfile_check_interval)
int64_t size = info.st_size + 1;

parsed_hosts_file_ptr = new RefCountedHostsFileMap;
parsed_hosts_file_ptr->next_sync_time = ink_time() + hostdb_hostfile_check_interval;
parsed_hosts_file_ptr->next_sync_time = ink_time() + hostdb_hostfile_check_interval_parse;
parsed_hosts_file_ptr->HostFileText = static_cast<char *>(ats_malloc(size));
if (parsed_hosts_file_ptr->HostFileText) {
char *base = parsed_hosts_file_ptr->HostFileText;
Expand Down
14 changes: 7 additions & 7 deletions iocore/net/SSLUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ ssl_client_hello_callback(SSL *s, int *al, void *arg)
* The list in practice only has a single element, so we only consider
* the first one.
*/
if (remaining != 0 && *p++ == TLSEXT_NAMETYPE_host_name) {
if (*p++ == TLSEXT_NAMETYPE_host_name) {
remaining--;
/* Now we can finally pull out the byte array with the actual hostname. */
if (remaining > 2) {
Expand Down Expand Up @@ -1734,10 +1734,10 @@ SSLWriteBuffer(SSL *ssl, const void *buf, int64_t nbytes, int64_t &nwritten)
}
int ssl_error = SSL_get_error(ssl, ret);
if (ssl_error == SSL_ERROR_SSL && is_debug_tag_set("ssl.error.write")) {
char buf[512];
char tempbuf[512];
unsigned long e = ERR_peek_last_error();
ERR_error_string_n(e, buf, sizeof(buf));
Debug("ssl.error.write", "SSL write returned %d, ssl_error=%d, ERR_get_error=%ld (%s)", ret, ssl_error, e, buf);
ERR_error_string_n(e, tempbuf, sizeof(tempbuf));
Debug("ssl.error.write", "SSL write returned %d, ssl_error=%d, ERR_get_error=%ld (%s)", ret, ssl_error, e, tempbuf);
}
return ssl_error;
}
Expand Down Expand Up @@ -1815,10 +1815,10 @@ SSLReadBuffer(SSL *ssl, void *buf, int64_t nbytes, int64_t &nread)
}
int ssl_error = SSL_get_error(ssl, ret);
if (ssl_error == SSL_ERROR_SSL && is_debug_tag_set("ssl.error.read")) {
char buf[512];
char tempbuf[512];
unsigned long e = ERR_peek_last_error();
ERR_error_string_n(e, buf, sizeof(buf));
Debug("ssl.error.read", "SSL read returned %d, ssl_error=%d, ERR_get_error=%ld (%s)", ret, ssl_error, e, buf);
ERR_error_string_n(e, tempbuf, sizeof(tempbuf));
Debug("ssl.error.read", "SSL read returned %d, ssl_error=%d, ERR_get_error=%ld (%s)", ret, ssl_error, e, tempbuf);
}

return ssl_error;
Expand Down
6 changes: 3 additions & 3 deletions iocore/net/UnixNetAccept.cc
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,11 @@ NetAccept::do_blocking_accept(EThread *t)
#endif
SET_CONTINUATION_HANDLER(vc, (NetVConnHandler)&UnixNetVConnection::acceptEvent);

EThread *t = eventProcessor.assign_thread(opt.etype);
NetHandler *h = get_NetHandler(t);
EThread *localt = eventProcessor.assign_thread(opt.etype);
NetHandler *h = get_NetHandler(localt);
// Assign NetHandler->mutex to NetVC
vc->mutex = h->mutex;
t->schedule_imm_signal(vc);
localt->schedule_imm_signal(vc);
} while (loop);

return 1;
Expand Down
4 changes: 2 additions & 2 deletions plugins/background_fetch/background_fetch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,9 @@ cont_handle_response(TSCont contp, TSEvent event, void *edata)
TSDebug(PLUGIN_NAME, "Testing: response status code: %d?", status);
if (TS_HTTP_STATUS_PARTIAL_CONTENT == status || (config->allow304() && TS_HTTP_STATUS_NOT_MODIFIED == status)) {
// Everything looks good so far, add a TXN hook for SEND_RESPONSE_HDR
TSCont contp = TSContCreate(cont_check_cacheable, nullptr);
TSCont localcontp = TSContCreate(cont_check_cacheable, nullptr);

TSHttpTxnHookAdd(txnp, TS_HTTP_SEND_RESPONSE_HDR_HOOK, contp);
TSHttpTxnHookAdd(txnp, TS_HTTP_SEND_RESPONSE_HDR_HOOK, localcontp);
}
// Release the response MLoc
TSHandleMLocRelease(response, TS_NULL_MLOC, resp_hdr);
Expand Down
7 changes: 5 additions & 2 deletions plugins/esi/combo_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,8 @@ prepareResponse(InterceptData &int_data, ByteBlockList &body_blocks, string &res
resp_header_fields.append("Expires: 0\r\n");
} else {
char line_buf[128];
int line_size = strftime(line_buf, 128, "Expires: %a, %d %b %Y %T GMT\r\n", gmtime(&expires_time));
struct tm gm_expires_time;
int line_size = strftime(line_buf, 128, "Expires: %a, %d %b %Y %T GMT\r\n", gmtime_r(&expires_time, &gm_expires_time));
resp_header_fields.append(line_buf, line_size);
}
}
Expand Down Expand Up @@ -1086,7 +1087,9 @@ writeStandardHeaderFields(InterceptData &int_data, int &n_bytes_written)
if (find(HEADER_WHITELIST.begin(), HEADER_WHITELIST.end(), TS_MIME_FIELD_LAST_MODIFIED) == HEADER_WHITELIST.end()) {
time_t time_now = static_cast<time_t>(TShrtime() / 1000000000); // it returns nanoseconds!
char last_modified_line[128];
int last_modified_line_size = strftime(last_modified_line, 128, "Last-Modified: %a, %d %b %Y %T GMT\r\n", gmtime(&time_now));
struct tm gmnow;
int last_modified_line_size =
strftime(last_modified_line, 128, "Last-Modified: %a, %d %b %Y %T GMT\r\n", gmtime_r(&time_now, &gmnow));
if (TSIOBufferWrite(int_data.output.buffer, last_modified_line, last_modified_line_size) == TS_ERROR) {
LOG_ERROR("Error while writing last-modified fields");
return false;
Expand Down
10 changes: 5 additions & 5 deletions plugins/experimental/memcache/tsmemcache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -962,13 +962,13 @@ MC::ascii_incr_decr_event(int event, void *data)
}
header.cas = ink_atomic_increment(&next_cas, 1);
{
char *data = nullptr;
int len = 0;
char *localdata = nullptr;
int len = 0;
// must be huge, why convert to a counter ??
if (cwvc->get_single_data((void **)&data, &len) < 0) {
if (cwvc->get_single_data((void **)&localdata, &len) < 0) {
goto Lfail;
}
uint64_t new_value = xatoull(data, data + len);
uint64_t new_value = xatoull(localdata, localdata + len);
if (f.set_incr) {
new_value += delta;
} else {
Expand Down Expand Up @@ -1628,7 +1628,7 @@ TSPluginInit(int argc, const char *argv[])
if (argc < 2) {
TSError("[tsmemcache] Usage: tsmemcache.so [accept_port]\n");
goto error;
} else if (argc > 1) {
} else {
int port = atoi(argv[1]);
if (!port) {
TSError("[tsmemcache] bad accept_port '%s'\n", argv[1]);
Expand Down
9 changes: 3 additions & 6 deletions plugins/experimental/uri_signing/uri_signing.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,7 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
TSHandleMLocRelease(mbuf, TS_NULL_MLOC, ul);

PluginDebug("Processing request for %.*s.", url_ct, url);
if (cpi < max_cpi) {
checkpoints[cpi++] = mark_timer(&t);
}
checkpoints[cpi++] = mark_timer(&t);

int strip_size = url_ct + 1;
strip_uri = (char *)TSmalloc(strip_size);
Expand All @@ -199,9 +197,8 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
size_t strip_ct;
cjose_jws_t *jws = get_jws_from_uri(url, url_ct, package, strip_uri, strip_size, &strip_ct);

if (cpi < max_cpi) {
checkpoints[cpi++] = mark_timer(&t);
}
checkpoints[cpi++] = mark_timer(&t);

int checked_cookies = 0;
if (!jws) {
check_cookies:
Expand Down
16 changes: 8 additions & 8 deletions plugins/header_rewrite/conditions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1113,17 +1113,17 @@ ConditionCidr::append_value(std::string &s, const Resources &res)
if (addr) {
switch (addr->sa_family) {
case AF_INET: {
char res[INET_ADDRSTRLEN];
char resource[INET_ADDRSTRLEN];
struct in_addr ipv4 = reinterpret_cast<const struct sockaddr_in *>(addr)->sin_addr;

ipv4.s_addr &= _v4_mask.s_addr;
inet_ntop(AF_INET, &ipv4, res, INET_ADDRSTRLEN);
if (res[0]) {
s += res;
inet_ntop(AF_INET, &ipv4, resource, INET_ADDRSTRLEN);
if (resource[0]) {
s += resource;
}
} break;
case AF_INET6: {
char res[INET6_ADDRSTRLEN];
char resource[INET6_ADDRSTRLEN];
struct in6_addr ipv6 = reinterpret_cast<const struct sockaddr_in6 *>(addr)->sin6_addr;

if (_v6_zero_bytes > 0) {
Expand All @@ -1132,9 +1132,9 @@ ConditionCidr::append_value(std::string &s, const Resources &res)
if (_v6_mask != 0xff) {
ipv6.s6_addr[16 - _v6_zero_bytes] &= _v6_mask;
}
inet_ntop(AF_INET6, &ipv6, res, INET6_ADDRSTRLEN);
if (res[0]) {
s += res;
inet_ntop(AF_INET6, &ipv6, resource, INET6_ADDRSTRLEN);
if (resource[0]) {
s += resource;
}
} break;
}
Expand Down
12 changes: 6 additions & 6 deletions plugins/lua/ts_lua_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ typedef struct {
char script[TS_LUA_MAX_SCRIPT_FNAME_LENGTH];
void *conf_vars[TS_LUA_MAX_CONFIG_VARS_COUNT];

int _first : 1; // create current instance for 1st ts_lua_main_ctx
int _last : 1; // create current instance for the last ts_lua_main_ctx
unsigned int _first : 1; // create current instance for 1st ts_lua_main_ctx
unsigned int _last : 1; // create current instance for the last ts_lua_main_ctx

int remap;
int states;
Expand Down Expand Up @@ -160,10 +160,10 @@ typedef struct {
ts_lua_http_ctx *hctx;

int64_t to_flush;
int reuse : 1;
int recv_complete : 1;
int send_complete : 1;
int all_ready : 1;
unsigned int reuse : 1;
unsigned int recv_complete : 1;
unsigned int send_complete : 1;
unsigned int all_ready : 1;
} ts_lua_http_intercept_ctx;

#define TS_LUA_RELEASE_IO_HANDLE(ih) \
Expand Down
2 changes: 1 addition & 1 deletion plugins/lua/ts_lua_coroutine.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ typedef struct async_item {
void *data; // private data

async_clean cleanup; // cleanup function
int deleted : 1;
unsigned int deleted : 1;
} ts_lua_async_item;

ts_lua_async_item *ts_lua_async_create_item(TSCont cont, async_clean func, void *d, ts_lua_cont_info *ci);
Expand Down
4 changes: 2 additions & 2 deletions plugins/lua/ts_lua_fetch.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ typedef struct {
TSIOBufferReader reader;
TSFetchSM fch;

int over : 1;
int failed : 1;
unsigned int over : 1;
unsigned int failed : 1;
} ts_lua_fetch_info;

typedef struct fetch_multi_info {
Expand Down
6 changes: 3 additions & 3 deletions plugins/multiplexer/dispatch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ class Handler
if (TSIsDebugTagSet(PLUGIN_TAG) > 0) {
const TSIOBuffer buffer = TSIOBufferCreate();
TSHttpHdrPrint(b, l, buffer);
std::string b;
read(buffer, b);
TSDebug(PLUGIN_TAG, "Response header for \"%s\" was:\n%s", url.c_str(), b.c_str());
std::string buf;
read(buffer, buf);
TSDebug(PLUGIN_TAG, "Response header for \"%s\" was:\n%s", url.c_str(), buf.c_str());
TSIOBufferDestroy(buffer);
}
}
Expand Down
12 changes: 4 additions & 8 deletions proxy/hdrs/HdrTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,6 @@ HdrTest::test_http_aux(const char *request, const char *response)
const char *start;
const char *end;

int status = 1;

printf(" <<< MUST BE HAND-VERIFIED FOR FULL BENEFIT >>>\n\n");

/*** (1) parse the request string into req_hdr ***/
Expand All @@ -624,7 +622,7 @@ HdrTest::test_http_aux(const char *request, const char *response)
if (err == PARSE_RESULT_ERROR) {
req_hdr.destroy();
rsp_hdr.destroy();
return (failures_to_status("test_http_aux", (status == 0)));
return (failures_to_status("test_http_aux", false));
}

/*** useless copy to exercise copy function ***/
Expand Down Expand Up @@ -665,7 +663,7 @@ HdrTest::test_http_aux(const char *request, const char *response)
if (err == PARSE_RESULT_ERROR) {
req_hdr.destroy();
rsp_hdr.destroy();
return (failures_to_status("test_http_aux", (status == 0)));
return (failures_to_status("test_http_aux", false));
}

http_parser_clear(&parser);
Expand Down Expand Up @@ -714,7 +712,7 @@ HdrTest::test_http_aux(const char *request, const char *response)
req_hdr.destroy();
rsp_hdr.destroy();

return (failures_to_status("test_http_aux", (status == 0)));
return (failures_to_status("test_http_aux", false));
}

int
Expand Down Expand Up @@ -1579,8 +1577,6 @@ HdrTest::test_http()
int
HdrTest::test_http_mutation()
{
int status = 1;

bri_box("test_http_mutation");

printf(" <<< MUST BE HAND-VERIFIED FOR FULL BENEFIT>>>\n\n");
Expand Down Expand Up @@ -1658,7 +1654,7 @@ HdrTest::test_http_mutation()

resp_hdr.destroy();

return (failures_to_status("test_http_mutation", (status == 0)));
return (failures_to_status("test_http_mutation", false));
}

/*-------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions proxy/http/HttpSM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4263,7 +4263,7 @@ HttpSM::parse_range_and_compare(MIMEField *field, int64_t content_length)
;
}

if (s < e || start < 0) {
if (s < e) {
t_state.range_setup = HttpTransact::RANGE_NONE;
goto Lfaild;
}
Expand Down Expand Up @@ -4303,7 +4303,7 @@ HttpSM::parse_range_and_compare(MIMEField *field, int64_t content_length)
;
}

if (s < e || end < 0) {
if (s < e) {
t_state.range_setup = HttpTransact::RANGE_NONE;
goto Lfaild;
}
Expand Down
5 changes: 0 additions & 5 deletions proxy/http/remap/RemapConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,6 @@ process_regex_mapping_config(const char *from_host_lower, url_mapping *new_mappi
const char *to_host;
int to_host_len;
int substitution_id;
int substitution_count = 0;
int captures;

reg_map->to_url_host_template = nullptr;
Expand Down Expand Up @@ -875,10 +874,6 @@ process_regex_mapping_config(const char *from_host_lower, url_mapping *new_mappi
to_host = new_mapping->toURL.host_get(&to_host_len);
for (int i = 0; i < (to_host_len - 1); ++i) {
if (to_host[i] == '$') {
if (substitution_count > UrlRewrite::MAX_REGEX_SUBS) {
Warning("Cannot have more than %d substitutions in mapping with host [%s]", UrlRewrite::MAX_REGEX_SUBS, from_host_lower);
goto lFail;
}
substitution_id = to_host[i + 1] - '0';
if ((substitution_id < 0) || (substitution_id > captures)) {
Warning("Substitution id [%c] has no corresponding capture pattern in regex [%s]", to_host[i + 1], from_host_lower);
Expand Down
10 changes: 5 additions & 5 deletions src/traffic_cache_tool/CacheTool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,8 @@ Cache::loadSpanConfig(ts::file::path const &path)
if (line.empty() || '#' == *line) {
continue;
}
ts::TextView path = line.take_prefix_if(&isspace);
if (path) {
ts::TextView localpath = line.take_prefix_if(&isspace);
if (localpath) {
// After this the line is [size] [id=string] [volume=#]
while (line) {
ts::TextView value(line.take_prefix_if(&isspace));
Expand All @@ -539,7 +539,7 @@ Cache::loadSpanConfig(ts::file::path const &path)
}
}
}
zret = this->loadSpan(ts::file::path(path));
zret = this->loadSpan(ts::file::path(localpath));
}
}
} else {
Expand All @@ -552,7 +552,7 @@ Errata
Cache::loadURLs(ts::file::path const &path)
{
static const ts::TextView TAG_VOL("url");
ts::URLparser parser;
ts::URLparser loadURLparser;
Errata zret;

std::error_code ec;
Expand All @@ -568,7 +568,7 @@ Cache::loadURLs(ts::file::path const &path)
std::string url;
url.assign(blob.data(), blob.size());
int port_ptr = -1, port_len = -1;
int port = parser.getPort(url, port_ptr, port_len);
int port = loadURLparser.getPort(url, port_ptr, port_len);
if (port_ptr >= 0 && port_len > 0) {
url.erase(port_ptr, port_len + 1); // get rid of :PORT
}
Expand Down
Loading