From 7c3585afee5b3a28fddb1102c0d24cc8555d5bc7 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Wed, 19 Dec 2018 09:22:05 +0100 Subject: [PATCH] Use us_socket_is_closed, fix non-SSL/Windows build --- src/HttpContext.h | 7 ++----- src/HttpParser.h | 1 + src/StaticDispatch.h | 20 ++++++++++++++++++++ src/WebSocketContext.h | 7 ++----- uSockets | 2 +- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/HttpContext.h b/src/HttpContext.h index 8d2f52d..7ca8ffc 100644 --- a/src/HttpContext.h +++ b/src/HttpContext.h @@ -29,9 +29,6 @@ #include #include -/* This is a hack for now on, update uSockets */ -extern "C" int us_internal_socket_is_closed(struct us_socket *s); - namespace uWS { template struct HttpResponse; @@ -153,7 +150,7 @@ private: // } /* Was the socket closed? */ - if (us_internal_socket_is_closed((struct us_socket *) s)) { + if (us_socket_is_closed((struct us_socket *) s)) { return nullptr; } @@ -173,7 +170,7 @@ private: httpResponseData->inStream(data); /* Was the socket closed? */ - if (us_internal_socket_is_closed((struct us_socket *) user)) { + if (us_socket_is_closed((struct us_socket *) user)) { return nullptr; } diff --git a/src/HttpParser.h b/src/HttpParser.h index 34aa367..670cc88 100644 --- a/src/HttpParser.h +++ b/src/HttpParser.h @@ -22,6 +22,7 @@ #include #include #include +#include namespace uWS { diff --git a/src/StaticDispatch.h b/src/StaticDispatch.h index cdff920..ca70e9b 100644 --- a/src/StaticDispatch.h +++ b/src/StaticDispatch.h @@ -22,6 +22,26 @@ #include #include +/* For now we just define all these as nonsense if using a non-SSL version of uSockets */ +#ifdef LIBUS_NO_SSL +#define us_ssl_socket_context_options int +#define us_ssl_socket_context_ext us_socket_context_ext +#define us_ssl_socket_context_on_open us_socket_context_on_open +#define us_ssl_socket_timeout us_socket_timeout +#define us_ssl_socket_ext us_socket_ext +#define us_ssl_socket_context_on_close us_socket_context_on_close +#define us_ssl_socket_context_on_data us_socket_context_on_data +#define us_ssl_socket_context_on_writable us_socket_context_on_writable +#define us_ssl_socket_context_on_end us_socket_context_on_end +#define us_ssl_socket_context_on_timeout us_socket_context_on_timeout +#define us_ssl_socket_is_shut_down us_socket_is_shut_down +#define us_ssl_socket_close us_socket_close +#define us_ssl_socket_write us_socket_write +#define us_ssl_socket_context_loop us_socket_context_loop +#define us_ssl_socket_get_context us_socket_get_context +#define us_ssl_socket_context_listen us_socket_context_listen +#endif + namespace uWS { template diff --git a/src/WebSocketContext.h b/src/WebSocketContext.h index 3bce002..72a876f 100644 --- a/src/WebSocketContext.h +++ b/src/WebSocketContext.h @@ -23,9 +23,6 @@ #include "WebSocketData.h" #include "AsyncSocket.h" -/* This is a hack for now on, update uSockets */ -extern "C" int us_internal_socket_is_closed(struct us_socket *s); - namespace uWS { template @@ -122,7 +119,7 @@ private: /* Emit message event & break if we are closed or shut down when returning */ webSocketContextData->messageHandler((WebSocket *) s, std::string_view(data, length), (uWS::OpCode) opCode); - if (us_internal_socket_is_closed((us_socket *) s) || webSocketData->isShuttingDown) { + if (us_socket_is_closed((us_socket *) s) || webSocketData->isShuttingDown) { return true; } } else { @@ -183,7 +180,7 @@ private: /* Emit message and check for shutdown or close */ webSocketContextData->messageHandler((WebSocket *) s, std::string_view(data, length), (uWS::OpCode) opCode); - if (us_internal_socket_is_closed((us_socket *) s) || webSocketData->isShuttingDown) { + if (us_socket_is_closed((us_socket *) s) || webSocketData->isShuttingDown) { return true; } diff --git a/uSockets b/uSockets index 3d1f6fb..b1f18bc 160000 --- a/uSockets +++ b/uSockets @@ -1 +1 @@ -Subproject commit 3d1f6fbb505279055a138a5d497142c95d0cb8b1 +Subproject commit b1f18bcab36f6a01032dc5664dedf5810b5910e3