bneradt commented on code in PR #14035:
URL: https://github.com/apache/trafficserver/pull/14035#discussion_r4531007356
##########
src/iocore/net/P_QUICPacketHandler.h:
##########
@@ -88,7 +101,15 @@ class QUICPacketHandlerIn : public NetAccept, public
QUICPacketHandler
void _recv_packet(int event, UDPPacket *udpPacket) override;
#if TS_HAS_OPENSSL_QUIC
- bool _start_listener();
+ /** Opens the socket unless there is one, and starts the OpenSSL listener on
it.
+ *
+ * @param net_thread Index of the net thread this listener is for when each
net thread has one, which makes the
Review Comment:
Please add `[in]` qualifier to `@param`
Please add `[in]`, `[out]`, etc to other doxygen `@param` comments as well,
if there are any.
##########
src/iocore/net/OpenSSLQUICPacketHandler.cc:
##########
@@ -464,17 +470,94 @@ QUICPacketHandlerIn::acceptEvent(int /* event ATS_UNUSED
*/, void * /* data ATS_
void
QUICPacketHandlerIn::init_accept(EThread *t)
{
- SET_HANDLER(&QUICPacketHandlerIn::acceptEvent);
-
if (t == nullptr) {
t = eventProcessor.assign_thread(ET_NET);
}
+ // A lone acceptor hands every connection to the session acceptor on this
one thread, so the session
+ // acceptor can borrow the thread's mutex.
if (!this->action_->continuation->mutex) {
this->action_->continuation->mutex = t->mutex;
this->action_->mutex = t->mutex;
}
+ this->_schedule_on(t);
+}
+
+void
+QUICPacketHandlerIn::init_accept_per_thread_listeners()
+{
+#if defined(__linux__) || defined(SO_REUSEPORT_LB)
+ auto const &net_threads = eventProcessor.thread_group[ET_NET];
+ ip_port_text_buffer addr;
+ ats_ip_nptop(&this->server.accept_addr, addr, sizeof(addr));
+
+ // Every socket is bound before any acceptor runs. The kernel picks a socket
for a datagram by hashing
+ // over however many sockets are bound at that moment, so a connection
established while the group
+ // was still growing could have its later datagrams sent to a listener that
does not know it.
+ std::vector<QUICPacketHandlerIn *> acceptors;
+ for (int i = 0; i < net_threads._count; ++i) {
+ auto *a = (i == 0) ? this : static_cast<QUICPacketHandlerIn
*>(this->clone());
+ Listen const result = a->_start_listener(i);
+ if (result == Listen::started) {
+ acceptors.push_back(a);
+ continue;
+ }
+
+ if (a != this) {
+ a->server.close();
+ delete a;
+ } else if (result == Listen::port_not_shared) {
+ Warning("HTTP/3 port %d: one OpenSSL QUIC listener serves %s, because
its socket cannot share the port", this->opt.local_port,
+ addr);
+ this->server.close();
+ this->init_accept(nullptr);
+ return;
+ }
+ break;
+ }
+
+ if (acceptors.empty()) {
+ this->_stop_unstarted_listener();
+ return;
+ }
+ if (acceptors.size() < static_cast<size_t>(net_threads._count)) {
+ Warning("HTTP/3 port %d: listening on %s on %zu of %d net threads",
this->opt.local_port, addr, acceptors.size(),
+ net_threads._count);
Review Comment:
I'm not sure it will be obvious why this is a warning. Can we reword this so
it is clearer why or how this is an unexpected condition?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]