From 5e787b19b3ad8b6396eb9e95415fcbfd2b5fd590 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Sun, 9 Jun 2019 09:32:55 +0200 Subject: [PATCH] Make all examples compile with GCC on Ubuntu --- Makefile | 24 ++++++++++++------------ examples/EchoServer.cpp | 1 + examples/EchoServerThreaded.cpp | 1 + src/AsyncSocket.h | 5 +++-- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 0a8ee66..a087eed 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,25 @@ .PHONY: examples examples: # HelloWorld (non-SSL, non-Zlib compile) - clang -DLIBUS_NO_SSL -flto -O3 -c -IuSockets/src uSockets/src/*.c uSockets/src/eventing/*.c - clang++ -DLIBUS_NO_SSL -DUWS_NO_ZLIB -flto -O3 -c -std=c++17 -Isrc -IuSockets/src examples/HelloWorld.cpp - clang++ -flto -O3 -s *.o -o HelloWorld + $(CC) -DLIBUS_NO_SSL -flto -O3 -c -IuSockets/src uSockets/src/*.c uSockets/src/eventing/*.c + $(CXX) -DLIBUS_NO_SSL -DUWS_NO_ZLIB -flto -O3 -c -std=c++17 -Isrc -IuSockets/src examples/HelloWorld.cpp + $(CXX) -flto -O3 -s *.o -o HelloWorld rm *.o # HelloWorldThreaded (non-SSL, non-Zlib compile) - clang -DLIBUS_NO_SSL -flto -O3 -c -IuSockets/src uSockets/src/*.c uSockets/src/eventing/*.c - clang++ -DLIBUS_NO_SSL -DUWS_NO_ZLIB -flto -O3 -c -std=c++17 -Isrc -IuSockets/src examples/HelloWorldThreaded.cpp - clang++ -lpthread -flto -O3 -s *.o -o HelloWorldThreaded + $(CC) -DLIBUS_NO_SSL -flto -O3 -c -IuSockets/src uSockets/src/*.c uSockets/src/eventing/*.c + $(CXX) -DLIBUS_NO_SSL -DUWS_NO_ZLIB -flto -O3 -c -std=c++17 -Isrc -IuSockets/src examples/HelloWorldThreaded.cpp + $(CXX) -pthread -flto -O3 -s *.o -o HelloWorldThreaded rm *.o # EchoServer (non-SSL, non-Zlib compile) - clang -DLIBUS_NO_SSL -flto -O3 -c -IuSockets/src uSockets/src/*.c uSockets/src/eventing/*.c - clang++ -DLIBUS_NO_SSL -DUWS_NO_ZLIB -flto -O3 -c -std=c++17 -Isrc -IuSockets/src examples/EchoServer.cpp - clang++ -flto -O3 -s *.o -o EchoServer + $(CC) -DLIBUS_NO_SSL -flto -O3 -c -IuSockets/src uSockets/src/*.c uSockets/src/eventing/*.c + $(CXX) -DLIBUS_NO_SSL -DUWS_NO_ZLIB -flto -O3 -c -std=c++17 -Isrc -IuSockets/src examples/EchoServer.cpp + $(CXX) -flto -O3 -s *.o -o EchoServer rm *.o # EchoServerThreaded (non-SSL, non-Zlib compile) - clang -DLIBUS_NO_SSL -flto -O3 -c -IuSockets/src uSockets/src/*.c uSockets/src/eventing/*.c - clang++ -DLIBUS_NO_SSL -DUWS_NO_ZLIB -flto -O3 -c -std=c++17 -Isrc -IuSockets/src examples/EchoServerThreaded.cpp - clang++ -lpthread -flto -O3 -s *.o -o EchoServerThreaded + $(CC) -DLIBUS_NO_SSL -flto -O3 -c -IuSockets/src uSockets/src/*.c uSockets/src/eventing/*.c + $(CXX) -DLIBUS_NO_SSL -DUWS_NO_ZLIB -flto -O3 -c -std=c++17 -Isrc -IuSockets/src examples/EchoServerThreaded.cpp + $(CXX) -pthread -flto -O3 -s *.o -o EchoServerThreaded rm *.o diff --git a/examples/EchoServer.cpp b/examples/EchoServer.cpp index bba88f8..8eb9cf1 100644 --- a/examples/EchoServer.cpp +++ b/examples/EchoServer.cpp @@ -11,6 +11,7 @@ int main() { /* Settings */ .compression = uWS::SHARED_COMPRESSOR, .maxPayloadLength = 16 * 1024, + .idleTimeout = 10, /* Handlers */ .open = [](auto *ws, auto *req) { diff --git a/examples/EchoServerThreaded.cpp b/examples/EchoServerThreaded.cpp index 6e4fe4f..09689cb 100644 --- a/examples/EchoServerThreaded.cpp +++ b/examples/EchoServerThreaded.cpp @@ -19,6 +19,7 @@ int main() { /* Settings */ .compression = uWS::SHARED_COMPRESSOR, .maxPayloadLength = 16 * 1024, + .idleTimeout = 10, /* Handlers */ .open = [](auto *ws, auto *req) { diff --git a/src/AsyncSocket.h b/src/AsyncSocket.h index bb950ed..7204a83 100644 --- a/src/AsyncSocket.h +++ b/src/AsyncSocket.h @@ -25,14 +25,15 @@ namespace uWS { + template struct WebSocketContext; + template struct AsyncSocket { template friend struct HttpContext; template friend struct WebSocketContext; friend struct TopicTree; -/* For now, we don't even compile on GCC without this. FIX! */ -/*protected*/public: +protected: /* Get loop data for socket */ LoopData *getLoopData() { return (LoopData *) us_loop_ext(us_new_socket_context_loop(SSL, us_new_socket_context(SSL, (us_new_socket_t *) this)));