Use us_socket_is_closed, fix non-SSL/Windows build

This commit is contained in:
Alex Hultman
2018-12-19 09:22:05 +01:00
parent ff4f3341ad
commit 7c3585afee
5 changed files with 26 additions and 11 deletions
+2 -5
View File
@@ -29,9 +29,6 @@
#include <string_view>
#include <functional>
/* This is a hack for now on, update uSockets */
extern "C" int us_internal_socket_is_closed(struct us_socket *s);
namespace uWS {
template<bool> 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;
}
+1
View File
@@ -22,6 +22,7 @@
#include <string>
#include <functional>
#include <cstring>
#include <algorithm>
namespace uWS {
+20
View File
@@ -22,6 +22,26 @@
#include <type_traits>
#include <libusockets.h>
/* 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 <bool SSL>
+2 -5
View File
@@ -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 <bool SSL, bool isServer>
@@ -122,7 +119,7 @@ private:
/* Emit message event & break if we are closed or shut down when returning */
webSocketContextData->messageHandler((WebSocket<SSL, isServer> *) 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<SSL, isServer> *) 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;
}