Commit 3291e706 authored by jan.koester's avatar jan.koester
Browse files

fixes

parent 02b0e116
Loading
Loading
Loading
Loading
+18 −4
Changes for src/event/epoll.cpp: 18 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -424,10 +424,12 @@ namespace netplus {
                                break;
                        }

                        // Step 4: Flush and send
                        // Always attempt to send if there is data queued
                        // (browsers require the server's HTTP/2 SETTINGS before
                        //  sending their request, so we must not wait for EPOLLOUT)
                        // Step 4: Flush, send, and handle keep-alive pipelining.
                        // Wrapped in a loop so that after ResponseEvent resets
                        // the request state, any already-buffered next request
                        // in RecvData gets dispatched and sent immediately
                        // instead of stalling until the next EPOLLIN event.
                        for (;;) {
                        if ((c->SendData.pos < c->SendData.size() || c->csock->hasPendingWrite()) && !needClose) {
                            if (c->csock->hasPendingWrite()) {
                                try {
@@ -494,6 +496,18 @@ namespace netplus {
                                evconnection->ResponseEvent(*c, tid, args);
                            }
                        }

                        // Keep-alive pipelining: if ResponseEvent cleared the
                        // request state and RecvData still has bytes from the
                        // next request, dispatch it now and loop back to send.
                        if (!needClose && !c->RecvData.empty() &&
                            c->SendData.pos >= c->SendData.size()) {
                            evconnection->RequestEvent(*c, tid, args);
                            if (c->SendData.pos < c->SendData.size())
                                continue;   // new response queued → send it
                        }
                        break;  // nothing more to pipeline
                        } // end keep-alive loop
                    }

                } catch (NetException& e) {