Commit 1b565856 authored by Alex Hultman's avatar Alex Hultman

Pass testListening, testReusePort & partially testHTTP

parent fac23e65
...@@ -132,6 +132,8 @@ Group<isServer>::Group(int extensionOptions, uS::Loop *loop) : extensionOptions( ...@@ -132,6 +132,8 @@ Group<isServer>::Group(int extensionOptions, uS::Loop *loop) : extensionOptions(
template <bool isServer> template <bool isServer>
void Group<isServer>::stopListening() { void Group<isServer>::stopListening() {
uS::Context::stopListening();
// stop context // stop context
// if (async) { // if (async) {
......
...@@ -64,6 +64,8 @@ uS::Socket *HttpSocket<isServer>::onData(uS::Socket *s, char *data, size_t lengt ...@@ -64,6 +64,8 @@ uS::Socket *HttpSocket<isServer>::onData(uS::Socket *s, char *data, size_t lengt
httpSocket->missedDeadline = false; httpSocket->missedDeadline = false;
if (httpSocket->contentLength >= length) { if (httpSocket->contentLength >= length) {
Group<isServer>::from(httpSocket)->httpDataHandler(httpSocket->outstandingResponsesTail, data, length, httpSocket->contentLength -= length); Group<isServer>::from(httpSocket)->httpDataHandler(httpSocket->outstandingResponsesTail, data, length, httpSocket->contentLength -= length);
// not worth corking?
httpSocket->cork(false);
return httpSocket; return httpSocket;
} else { } else {
Group<isServer>::from(httpSocket)->httpDataHandler(httpSocket->outstandingResponsesTail, data, httpSocket->contentLength, 0); Group<isServer>::from(httpSocket)->httpDataHandler(httpSocket->outstandingResponsesTail, data, httpSocket->contentLength, 0);
...@@ -149,11 +151,14 @@ uS::Socket *HttpSocket<isServer>::onData(uS::Socket *s, char *data, size_t lengt ...@@ -149,11 +151,14 @@ uS::Socket *HttpSocket<isServer>::onData(uS::Socket *s, char *data, size_t lengt
Group<SERVER>::from(httpSocket)->httpRequestHandler(res, req, nullptr, 0, 0); Group<SERVER>::from(httpSocket)->httpRequestHandler(res, req, nullptr, 0, 0);
} }
// fix this! corking should happen even if is shutting down!
if (httpSocket->isClosed() || httpSocket->isShuttingDown()) { if (httpSocket->isClosed() || httpSocket->isShuttingDown()) {
// should uncokr here to release any shutdown sends
return httpSocket; return httpSocket;
} }
} else { } else {
httpSocket->onEnd(httpSocket); httpSocket->onEnd(httpSocket);
httpSocket->cork(false); // added recently
return httpSocket; return httpSocket;
} }
} }
...@@ -181,6 +186,7 @@ uS::Socket *HttpSocket<isServer>::onData(uS::Socket *s, char *data, size_t lengt ...@@ -181,6 +186,7 @@ uS::Socket *HttpSocket<isServer>::onData(uS::Socket *s, char *data, size_t lengt
} else { } else {
httpSocket->onEnd(httpSocket); httpSocket->onEnd(httpSocket);
} }
httpSocket->cork(false); // added recently
return httpSocket; return httpSocket;
} }
} else { } else {
...@@ -191,6 +197,7 @@ uS::Socket *HttpSocket<isServer>::onData(uS::Socket *s, char *data, size_t lengt ...@@ -191,6 +197,7 @@ uS::Socket *HttpSocket<isServer>::onData(uS::Socket *s, char *data, size_t lengt
httpSocket->httpBuffer.append(lastCursor, end - lastCursor); httpSocket->httpBuffer.append(lastCursor, end - lastCursor);
} }
} }
httpSocket->cork(false); // added recently
return httpSocket; return httpSocket;
} }
} while(cursor != end); } while(cursor != end);
......
...@@ -234,6 +234,17 @@ struct HttpResponse { ...@@ -234,6 +234,17 @@ struct HttpResponse {
while (messagePtr) { while (messagePtr) {
HttpSocket<true>::Queue::Message *nextMessage = messagePtr->nextMessage; HttpSocket<true>::Queue::Message *nextMessage = messagePtr->nextMessage;
std::cout << "OUT OF ORDER RESPONSE IS COMMENTED OUT!" << std::endl;
// delete this message
HttpSocket<true>::freeMessage(messagePtr);
// messagePtr->callback = callback;
// messagePtr->callbackData = callbackData;
// if (httpSocket->sendMessage(messagePtr, true)) {
// HttpSocket<true>::freeMessage(messagePtr);
// }
// bool wasTransferred; // bool wasTransferred;
// if (httpSocket->write(messagePtr, wasTransferred)) { // if (httpSocket->write(messagePtr, wasTransferred)) {
// if (!wasTransferred) { // if (!wasTransferred) {
...@@ -252,7 +263,7 @@ struct HttpResponse { ...@@ -252,7 +263,7 @@ struct HttpResponse {
// } // }
// goto updateHead; // goto updateHead;
// } // }
// messagePtr = nextMessage; messagePtr = nextMessage;
} }
// cannot go beyond unfinished responses // cannot go beyond unfinished responses
if (!head->hasEnded) { if (!head->hasEnded) {
......
This diff is collapsed.
Subproject commit b28c3c6317b4b9ffb2bf1c36268e4f20de74e9cf Subproject commit f4fe1118eaa52ba8f97120c85441bb33fb90e3b6
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment