Commit e570324d authored by Alex Hultman's avatar Alex Hultman
Browse files

Properly handle connection errors

parent a8d9f1d3
...@@ -55,8 +55,7 @@ void Hub::onClientConnection(uS::Socket *s, bool error) { ...@@ -55,8 +55,7 @@ void Hub::onClientConnection(uS::Socket *s, bool error) {
HttpSocket<CLIENT> *httpSocket = (HttpSocket<CLIENT> *) s; HttpSocket<CLIENT> *httpSocket = (HttpSocket<CLIENT> *) s;
if (error) { if (error) {
((Group<CLIENT> *) httpSocket->nodeData)->errorHandler(httpSocket->httpUser); httpSocket->onEnd(httpSocket);
delete httpSocket;
} else { } else {
httpSocket->setState<HttpSocket<CLIENT>>(); httpSocket->setState<HttpSocket<CLIENT>>();
httpSocket->change(httpSocket->nodeData->loop, httpSocket, httpSocket->setPoll(UV_READABLE)); httpSocket->change(httpSocket->nodeData->loop, httpSocket, httpSocket->setPoll(UV_READABLE));
......
...@@ -238,6 +238,9 @@ void testConnections() { ...@@ -238,6 +238,9 @@ void testConnections() {
case 7: case 7:
std::cout << "Client emitted error on HTTP response without upgrade (SSL)" << std::endl; std::cout << "Client emitted error on HTTP response without upgrade (SSL)" << std::endl;
break; break;
case 10:
std::cout << "Client emitted error on poll error" << std::endl;
break;
default: default:
std::cout << "FAILURE: " << user << " should not emit error!" << std::endl; std::cout << "FAILURE: " << user << " should not emit error!" << std::endl;
exit(-1); exit(-1);
...@@ -272,6 +275,7 @@ void testConnections() { ...@@ -272,6 +275,7 @@ void testConnections() {
h.connect("wss://echo.websocket.org", (void *) 9); h.connect("wss://echo.websocket.org", (void *) 9);
h.connect("ws://google.com", (void *) 6); h.connect("ws://google.com", (void *) 6);
h.connect("wss://google.com", (void *) 7); h.connect("wss://google.com", (void *) 7);
h.connect("ws://127.0.0.1:6000", (void *) 10, {}, 60000);
h.run(); h.run();
std::cout << "Falling through testConnections" << std::endl; std::cout << "Falling through testConnections" << std::endl;
......
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