summaryrefslogtreecommitdiffstats
path: root/src/shrpx_worker.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/shrpx_worker.cc')
-rw-r--r--src/shrpx_worker.cc43
1 files changed, 20 insertions, 23 deletions
diff --git a/src/shrpx_worker.cc b/src/shrpx_worker.cc
index 9f5911f..3a585f6 100644
--- a/src/shrpx_worker.cc
+++ b/src/shrpx_worker.cc
@@ -555,9 +555,9 @@ void Worker::process_events() {
faddr = &quic_upstream_addrs_[wev.quic_pkt->upstream_addr_index];
}
- quic_conn_handler_.handle_packet(
- faddr, wev.quic_pkt->remote_addr, wev.quic_pkt->local_addr,
- wev.quic_pkt->pi, wev.quic_pkt->data.data(), wev.quic_pkt->data.size());
+ quic_conn_handler_.handle_packet(faddr, wev.quic_pkt->remote_addr,
+ wev.quic_pkt->local_addr, wev.quic_pkt->pi,
+ wev.quic_pkt->data);
break;
}
@@ -579,7 +579,7 @@ tls::CertLookupTree *Worker::get_quic_cert_lookup_tree() const {
std::shared_ptr<TicketKeys> Worker::get_ticket_keys() {
#ifdef HAVE_ATOMIC_STD_SHARED_PTR
- return std::atomic_load_explicit(&ticket_keys_, std::memory_order_acquire);
+ return ticket_keys_.load(std::memory_order_acquire);
#else // !HAVE_ATOMIC_STD_SHARED_PTR
std::lock_guard<std::mutex> g(ticket_keys_m_);
return ticket_keys_;
@@ -589,8 +589,7 @@ std::shared_ptr<TicketKeys> Worker::get_ticket_keys() {
void Worker::set_ticket_keys(std::shared_ptr<TicketKeys> ticket_keys) {
#ifdef HAVE_ATOMIC_STD_SHARED_PTR
// This is single writer
- std::atomic_store_explicit(&ticket_keys_, std::move(ticket_keys),
- std::memory_order_release);
+ ticket_keys_.store(std::move(ticket_keys), std::memory_order_release);
#else // !HAVE_ATOMIC_STD_SHARED_PTR
std::lock_guard<std::mutex> g(ticket_keys_m_);
ticket_keys_ = std::move(ticket_keys);
@@ -855,8 +854,7 @@ int Worker::create_quic_server_socket(UpstreamAddr &faddr) {
hints.ai_flags |= AI_ADDRCONFIG;
# endif // AI_ADDRCONFIG
- auto node =
- faddr.host == StringRef::from_lit("*") ? nullptr : faddr.host.c_str();
+ auto node = faddr.host == "*"_sr ? nullptr : faddr.host.data();
addrinfo *res, *rp;
rv = getaddrinfo(node, service.c_str(), &hints, &res);
@@ -1027,7 +1025,7 @@ int Worker::create_quic_server_socket(UpstreamAddr &faddr) {
if (should_attach_bpf()) {
auto &bpfconf = config->quic.bpf;
- auto obj = bpf_object__open_file(bpfconf.prog_file.c_str(), nullptr);
+ auto obj = bpf_object__open_file(bpfconf.prog_file.data(), nullptr);
if (!obj) {
auto error = errno;
LOG(FATAL) << "Failed to open bpf object file: "
@@ -1231,13 +1229,13 @@ const UpstreamAddr *Worker::find_quic_upstream_addr(const Address &local_addr) {
if (faddr.port == 443 || faddr.port == 80) {
switch (faddr.family) {
case AF_INET:
- if (util::streq(faddr.hostport, StringRef::from_lit("0.0.0.0"))) {
+ if (faddr.hostport == "0.0.0.0"_sr) {
fallback_faddr = &faddr;
}
break;
case AF_INET6:
- if (util::streq(faddr.hostport, StringRef::from_lit("[::]"))) {
+ if (faddr.hostport == "[::]"_sr) {
fallback_faddr = &faddr;
}
@@ -1248,14 +1246,13 @@ const UpstreamAddr *Worker::find_quic_upstream_addr(const Address &local_addr) {
} else {
switch (faddr.family) {
case AF_INET:
- if (util::starts_with(faddr.hostport,
- StringRef::from_lit("0.0.0.0:"))) {
+ if (util::starts_with(faddr.hostport, "0.0.0.0:"_sr)) {
fallback_faddr = &faddr;
}
break;
case AF_INET6:
- if (util::starts_with(faddr.hostport, StringRef::from_lit("[::]:"))) {
+ if (util::starts_with(faddr.hostport, "[::]:"_sr)) {
fallback_faddr = &faddr;
}
@@ -1297,10 +1294,10 @@ size_t match_downstream_addr_group_host(
if (!wildcard_patterns.empty() && !host.empty()) {
auto rev_host_src = make_byte_ref(balloc, host.size() - 1);
- auto ep =
- std::copy(std::begin(host) + 1, std::end(host), rev_host_src.base);
- std::reverse(rev_host_src.base, ep);
- auto rev_host = StringRef{rev_host_src.base, ep};
+ auto ep = std::copy(std::begin(host) + 1, std::end(host),
+ std::begin(rev_host_src));
+ std::reverse(std::begin(rev_host_src), ep);
+ auto rev_host = StringRef{std::span{std::begin(rev_host_src), ep}};
ssize_t best_group = -1;
const RNode *last_node = nullptr;
@@ -1334,7 +1331,7 @@ size_t match_downstream_addr_group_host(
}
}
- group = router.match(StringRef::from_lit(""), path);
+ group = router.match(""_sr, path);
if (group != -1) {
if (LOG_ENABLED(INFO)) {
LOG(INFO) << "Found pattern with query " << path
@@ -1367,7 +1364,7 @@ size_t match_downstream_addr_group(
auto path = StringRef{std::begin(raw_path), query};
if (path.empty() || path[0] != '/') {
- path = StringRef::from_lit("/");
+ path = "/"_sr;
}
if (hostport.empty()) {
@@ -1398,10 +1395,10 @@ size_t match_downstream_addr_group(
return 'A' <= c || c <= 'Z';
}) != std::end(host)) {
auto low_host = make_byte_ref(balloc, host.size() + 1);
- auto ep = std::copy(std::begin(host), std::end(host), low_host.base);
+ auto ep = std::copy(std::begin(host), std::end(host), std::begin(low_host));
*ep = '\0';
- util::inp_strlower(low_host.base, ep);
- host = StringRef{low_host.base, ep};
+ util::inp_strlower(std::begin(low_host), ep);
+ host = StringRef{std::span{std::begin(low_host), ep}};
}
return match_downstream_addr_group_host(routerconf, host, path, groups,
catch_all, balloc);