Loading src/httpd.cpp +10 −35 Changes for src/httpd.cpp: 10 added lines, 35 removed lines. Original line number Diff line number Diff line Loading @@ -777,17 +777,6 @@ bool libhttppp::HttpEvent::_dispatchH2Stream(HttpRequest &cureq, tempreq.setPeerAddress(peerAddr); } // Log dispatch for debugging std::string dbg_path; for (auto &hf : decoded) { if (hf.name == ":path") { dbg_path = hf.value; break; } } bool had_active = cureq.h2state().activeStreams.count(sid) > 0; std::cerr << "[H2-DISPATCH] sid=" << sid << " path=" << dbg_path << " activeAlready=" << had_active << std::endl; // Seed this stream's flow-control window now, synchronously, while we // hold the connection's event_mutex (see epoll.cpp's per-event lock // around dispatch). Offloaded requests hand the actual response off to Loading Loading @@ -979,10 +968,17 @@ void libhttppp::HttpEvent::_dispatchH1Request(HttpRequest &cureq, size_t consume bool accepted = _h1DispatchPool->submit( [this, connOwner, sockBox, consumeBodyBytes, tid, args]() mutable { HttpRequest &cureq2 = static_cast<HttpRequest&>(*connOwner); // Safe without event_mutex: nothing else can observe this connection while // it's detached from CONNECTIONS (no epoll/kqueue worker will ever dispatch // to this fd again until reattachConnection() below puts it back). // No epoll/kqueue worker will dispatch to this fd again until // reattachConnection() below puts it back -- but the worker that submitted // this task may still be unwinding out of RequestEvent, about to check // slots[0].csock and run EpollArmGuard's destructor. Restoring csock before // it got there made that worker carry on flushing/clearing the same request // concurrently with this task (double free() under load). It holds // event_mutex until after both, so taking it here waits it out. { std::lock_guard<std::recursive_mutex> lk(cureq2.event_mutex); cureq2.slots[0].csock = std::move(*sockBox); } cureq2.slots[0].csock->setBlock(); cureq2.slots[0].csock->setTimeout(kH1OffloadSocketTimeoutMs); Loading Loading @@ -1431,17 +1427,7 @@ bool libhttppp::HttpEvent::_flushSendDataNow(HttpRequest &cureq) { } } } } catch (const std::exception &e) { std::cerr << "[HTTP-WRITE] deferred: " << e.what() << " pos=" << cureq.SendData.pos << " size=" << cureq.SendData.size() << std::endl; blocked = true; } catch (...) { std::cerr << "[HTTP-WRITE] deferred: unknown exception" << " pos=" << cureq.SendData.pos << " size=" << cureq.SendData.size() << std::endl; blocked = true; } Loading Loading @@ -1550,12 +1536,6 @@ void libhttppp::HttpEvent::_resumeH2Streams(HttpRequest &cureq, streams.erase(it); break; } std::cerr << "[H2-RESUME] calling ResponseEvent sid=" << sid << " totalSent=" << ss->totalSent << " contentLen=" << ss->contentLength << " emptyCount=" << ss->emptyCount << " ext=" << ss->tempreq->extension.get() << std::endl; try { ResponseEvent(*ss->tempreq, ss->tid, ss->args); } catch (std::exception &) { Loading Loading @@ -3350,13 +3330,11 @@ libhttppp::HttpD::HttpD(const std::string& httpaddr, int port,int maxconnections try { _fileServer = false; if (!sslcertpath.empty()) { std::cerr << "[HttpD] Loading cert bundle..." << std::endl; netplus::ssl::CertificateBundle bundle; if (!bundle.loadFromFile(sslcertpath, sslkeypath, sslpassword)) { _httpexception[HTTPException::Critical] << "failed to load cert/key: " << sslcertpath; throw _httpexception; } std::cerr << "[HttpD] Cert loaded, checking validity..." << std::endl; if (!bundle.cert.checkValidity()) { time_t now = time(nullptr); _httpexception[HTTPException::Critical] << "invalid certfile: " << sslcertpath Loading @@ -3365,11 +3343,8 @@ libhttppp::HttpD::HttpD(const std::string& httpaddr, int port,int maxconnections throw _httpexception; } std::cerr << "[HttpD] Copying to certBundle map..." << std::endl; _certBundle[httpaddr] = bundle; std::cerr << "[HttpD] Creating SSL socket..." << std::endl; auto tss = std::make_unique<netplus::ssl>(_certBundle, httpaddr, port, maxconnections, -1); std::cerr << "[HttpD] Creating QUIC socket..." << std::endl; auto qss = std::make_unique<Http3QuicSocket>(_certBundle, httpaddr, port, maxconnections, -1); _ServerSockets.push_back(std::move(tss)); Loading Loading
src/httpd.cpp +10 −35 Changes for src/httpd.cpp: 10 added lines, 35 removed lines. Original line number Diff line number Diff line Loading @@ -777,17 +777,6 @@ bool libhttppp::HttpEvent::_dispatchH2Stream(HttpRequest &cureq, tempreq.setPeerAddress(peerAddr); } // Log dispatch for debugging std::string dbg_path; for (auto &hf : decoded) { if (hf.name == ":path") { dbg_path = hf.value; break; } } bool had_active = cureq.h2state().activeStreams.count(sid) > 0; std::cerr << "[H2-DISPATCH] sid=" << sid << " path=" << dbg_path << " activeAlready=" << had_active << std::endl; // Seed this stream's flow-control window now, synchronously, while we // hold the connection's event_mutex (see epoll.cpp's per-event lock // around dispatch). Offloaded requests hand the actual response off to Loading Loading @@ -979,10 +968,17 @@ void libhttppp::HttpEvent::_dispatchH1Request(HttpRequest &cureq, size_t consume bool accepted = _h1DispatchPool->submit( [this, connOwner, sockBox, consumeBodyBytes, tid, args]() mutable { HttpRequest &cureq2 = static_cast<HttpRequest&>(*connOwner); // Safe without event_mutex: nothing else can observe this connection while // it's detached from CONNECTIONS (no epoll/kqueue worker will ever dispatch // to this fd again until reattachConnection() below puts it back). // No epoll/kqueue worker will dispatch to this fd again until // reattachConnection() below puts it back -- but the worker that submitted // this task may still be unwinding out of RequestEvent, about to check // slots[0].csock and run EpollArmGuard's destructor. Restoring csock before // it got there made that worker carry on flushing/clearing the same request // concurrently with this task (double free() under load). It holds // event_mutex until after both, so taking it here waits it out. { std::lock_guard<std::recursive_mutex> lk(cureq2.event_mutex); cureq2.slots[0].csock = std::move(*sockBox); } cureq2.slots[0].csock->setBlock(); cureq2.slots[0].csock->setTimeout(kH1OffloadSocketTimeoutMs); Loading Loading @@ -1431,17 +1427,7 @@ bool libhttppp::HttpEvent::_flushSendDataNow(HttpRequest &cureq) { } } } } catch (const std::exception &e) { std::cerr << "[HTTP-WRITE] deferred: " << e.what() << " pos=" << cureq.SendData.pos << " size=" << cureq.SendData.size() << std::endl; blocked = true; } catch (...) { std::cerr << "[HTTP-WRITE] deferred: unknown exception" << " pos=" << cureq.SendData.pos << " size=" << cureq.SendData.size() << std::endl; blocked = true; } Loading Loading @@ -1550,12 +1536,6 @@ void libhttppp::HttpEvent::_resumeH2Streams(HttpRequest &cureq, streams.erase(it); break; } std::cerr << "[H2-RESUME] calling ResponseEvent sid=" << sid << " totalSent=" << ss->totalSent << " contentLen=" << ss->contentLength << " emptyCount=" << ss->emptyCount << " ext=" << ss->tempreq->extension.get() << std::endl; try { ResponseEvent(*ss->tempreq, ss->tid, ss->args); } catch (std::exception &) { Loading Loading @@ -3350,13 +3330,11 @@ libhttppp::HttpD::HttpD(const std::string& httpaddr, int port,int maxconnections try { _fileServer = false; if (!sslcertpath.empty()) { std::cerr << "[HttpD] Loading cert bundle..." << std::endl; netplus::ssl::CertificateBundle bundle; if (!bundle.loadFromFile(sslcertpath, sslkeypath, sslpassword)) { _httpexception[HTTPException::Critical] << "failed to load cert/key: " << sslcertpath; throw _httpexception; } std::cerr << "[HttpD] Cert loaded, checking validity..." << std::endl; if (!bundle.cert.checkValidity()) { time_t now = time(nullptr); _httpexception[HTTPException::Critical] << "invalid certfile: " << sslcertpath Loading @@ -3365,11 +3343,8 @@ libhttppp::HttpD::HttpD(const std::string& httpaddr, int port,int maxconnections throw _httpexception; } std::cerr << "[HttpD] Copying to certBundle map..." << std::endl; _certBundle[httpaddr] = bundle; std::cerr << "[HttpD] Creating SSL socket..." << std::endl; auto tss = std::make_unique<netplus::ssl>(_certBundle, httpaddr, port, maxconnections, -1); std::cerr << "[HttpD] Creating QUIC socket..." << std::endl; auto qss = std::make_unique<Http3QuicSocket>(_certBundle, httpaddr, port, maxconnections, -1); _ServerSockets.push_back(std::move(tss)); Loading