Fix last warnings, SocketContextOptions, BloomFilter

This commit is contained in:
Alex Hultman
2020-12-01 05:45:53 +01:00
parent a8b33acf7b
commit fe553742f2
5 changed files with 25 additions and 8 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
EXAMPLE_FILES := HelloWorld ServerName EchoServer BroadcastingEchoServer UpgradeSync UpgradeAsync
THREADED_EXAMPLE_FILES := HelloWorldThreaded EchoServerThreaded
override CXXFLAGS += -lpthread -Wpedantic -Wall -Wextra -std=c++2a -Isrc -IuSockets/src
override CXXFLAGS += -lpthread -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++2a -Isrc -IuSockets/src
override LDFLAGS += uSockets/*.o -lz
DESTDIR ?=
+19 -2
View File
@@ -29,6 +29,23 @@
namespace uWS {
/* This one matches us_socket_context_options_t but has default values */
struct SocketContextOptions {
const char *key_file_name = nullptr;
const char *cert_file_name = nullptr;
const char *passphrase = nullptr;
const char *dh_params_file_name = nullptr;
const char *ca_file_name = nullptr;
int ssl_prefer_low_memory_usage = 0;
/* Conversion operator used internally */
operator struct us_socket_context_options_t() const {
struct us_socket_context_options_t socket_context_options;
memcpy(&socket_context_options, this, sizeof(SocketContextOptions));
return socket_context_options;
}
};
template <bool SSL>
struct TemplatedApp {
private:
@@ -39,7 +56,7 @@ private:
public:
/* Server name */
TemplatedApp &&addServerName(std::string hostname_pattern, us_socket_context_options_t options = {}) {
TemplatedApp &&addServerName(std::string hostname_pattern, SocketContextOptions options = {}) {
us_socket_context_add_server_name(SSL, (struct us_socket_context_t *) httpContext, hostname_pattern.c_str(), options);
return std::move(*this);
@@ -107,7 +124,7 @@ public:
webSocketContexts = std::move(other.webSocketContexts);
}
TemplatedApp(us_socket_context_options_t options = {}) {
TemplatedApp(SocketContextOptions options = {}) {
httpContext = uWS::HttpContext<SSL>::create(uWS::Loop::get(), options);
}
+2 -2
View File
@@ -31,11 +31,11 @@ private:
std::bitset<512> filter;
unsigned int hash1(std::string_view key) {
return ((unsigned int)key[key.length() - 1] - (key.length() << 3)) & 511;
return ((size_t)key[key.length() - 1] - (key.length() << 3)) & 511;
}
unsigned int hash2(std::string_view key) {
return (((unsigned int)key[0] + (key.length() << 4)) & 511);
return (((size_t)key[0] + (key.length() << 4)) & 511);
}
unsigned int hash3(std::string_view key) {
+1 -1
View File
@@ -152,7 +152,7 @@ private:
static unsigned int toUnsignedInteger(std::string_view str) {
unsigned int unsignedIntegerValue = 0;
for (char c : str) {
unsignedIntegerValue = unsignedIntegerValue * 10 + ((unsigned char) c - '0');
unsignedIntegerValue = unsignedIntegerValue * 10u + ((unsigned int) c - (unsigned int) '0');
}
return unsignedIntegerValue;
}
+2 -2
View File
@@ -362,9 +362,9 @@ protected:
static inline bool consumeContinuation(char *&src, unsigned int &length, WebSocketState<isServer> *wState, void *user) {
if (wState->remainingBytes <= length) {
if (isServer) {
int n = wState->remainingBytes >> 2;
unsigned int n = wState->remainingBytes >> 2;
unmaskInplace(src, src + n * 4, wState->mask);
for (int i = 0, s = wState->remainingBytes % 4; i < s; i++) {
for (unsigned int i = 0, s = wState->remainingBytes % 4; i < s; i++) {
src[n * 4 + i] ^= wState->mask[i];
}
}