Skip to content

Commit 628d87e

Browse files
committed
Upgrade websocketpp to 0.8.1, disable TCP_NO_DELAY for now.
1 parent a04801a commit 628d87e

37 files changed

+673
-487
lines changed

client_server/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ add_definitions(
122122
# Make targets.
123123
#---------------------------------------------------------------------------
124124

125+
# add_executable(tst tst.cc)
126+
# target_link_libraries(tst
127+
# ${Boost_LIBRARIES}
128+
# Threads::Threads
129+
# )
130+
125131
# Server executable
126132
if(MSVC AND CADABRA_DEBUG_BUILD)
127133
add_executable(cadabra-server ${CADABRA_SERVER_SRC})

client_server/Server.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "CdbPython.hh"
2222
#include "SympyCdb.hh"
2323

24-
// #define DEBUG 1
24+
//#define DEBUG 1
2525

2626
using websocketpp::lib::placeholders::_1;
2727
using websocketpp::lib::placeholders::_2;
@@ -204,7 +204,8 @@ std::string Server::run_string(const std::string& blk, bool handle_output)
204204
void Server::on_socket_init(websocketpp::connection_hdl, boost::asio::ip::tcp::socket & s)
205205
{
206206
boost::asio::ip::tcp::no_delay option(true);
207-
s.set_option(option);
207+
// FIXME: this used to work in older websocketpp
208+
// s.lowest_layer().set_option(option);
208209
}
209210

210211
Server::Connection::Connection()
@@ -501,14 +502,21 @@ void Server::run()
501502
wserver.clear_access_channels(websocketpp::log::alevel::all);
502503
wserver.clear_error_channels(websocketpp::log::elevel::all);
503504

505+
wserver.init_asio();
506+
wserver.set_reuse_addr(true);
507+
504508
wserver.set_socket_init_handler(bind(&Server::on_socket_init, this, ::_1,::_2));
505509
wserver.set_message_handler(bind(&Server::on_message, this, ::_1, ::_2));
506510
wserver.set_open_handler(bind(&Server::on_open,this,::_1));
507511
wserver.set_close_handler(bind(&Server::on_close,this,::_1));
508512

509-
wserver.init_asio();
510-
wserver.set_reuse_addr(true);
513+
#ifdef DEBUG
514+
std::cerr << "going to listen" << std::endl;
515+
#endif
511516
wserver.listen(websocketpp::lib::asio::ip::tcp::v4(), 0);
517+
#ifdef DEBUG
518+
std::cerr << "going to accept" << std::endl;
519+
#endif
512520
wserver.start_accept();
513521
websocketpp::lib::asio::error_code ec;
514522
auto p = wserver.get_local_endpoint(ec);

config/buildbot.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ function runbuild {
77
# Start the VM and wait for it to come up.
88
echo "Starting build bot for $1, ssh port $3"
99
ssh buildbothost "nohup VBoxHeadless -s '$1' > /tmp/buildbot.out 2> /tmp/buildbot.err < /dev/null &"
10-
echo "Waiting 10 seconds for VM to start up..."
11-
sleep 10
10+
echo "Waiting 20 seconds for VM to start up..."
11+
sleep 20
1212

1313
# Setup the tunnel to the VM; a local port $3 gets mapped
1414
# to a port $3 on the build host, which is forwarded by
@@ -57,16 +57,16 @@ function runbuild {
5757

5858
# Parameters: VM name, package type, local ssh port, folder name on web server.
5959

60-
runbuild "Ubuntu_18.04" ".deb" 7017 ubuntu1804
61-
runbuild "Fedora_28" ".rpm" 7020 fedora28
62-
runbuild "Fedora_29" ".rpm" 7025 fedora29
63-
runbuild "Mint_19" ".deb" 7022 mint19
64-
runbuild "OpenSUSE_15" ".rpm" 7024 opensuse150
65-
runbuild "OpenSUSE_Tumbleweed" ".rpm" 7023 opensusetw
66-
runbuild "CentOS_7" ".rpm" 7004 centos7
67-
runbuild "Scientific_Linux_74" ".rpm" 7013 scientific7x
68-
runbuild "Debian_921" ".deb" 7014 debian9
69-
runbuild "Debian_Buster" ".deb" 7021 debian10
60+
#runbuild "Ubuntu_18.04" ".deb" 7017 ubuntu1804
61+
#runbuild "Fedora_28" ".rpm" 7020 fedora28
62+
#runbuild "Fedora_29" ".rpm" 7025 fedora29
63+
#runbuild "Mint_19" ".deb" 7022 mint19
64+
runbuild "OpenSUSE_15" ".rpm" 7024 opensuse150 ssh error
65+
#runbuild "OpenSUSE_Tumbleweed" ".rpm" 7023 opensusetw ssh error
66+
#runbuild "CentOS_7" ".rpm" 7004 centos7 cmake/packaging clash
67+
#runbuild "Scientific_Linux_74" ".rpm" 7013 scientific7x
68+
#runbuild "Debian_921" ".deb" 7014 debian9
69+
#runbuild "Debian_Buster" ".deb" 7021 debian10
7070

7171
# Outdated versions:
7272
# runbuild "Mint_18" ".deb" 7002 mint18 ERROR

libs/websocketpp/CMakeLists.txt

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,42 @@
11

22
############ Setup project and cmake
3-
4-
# Project name
5-
project (websocketpp)
6-
73
# Minimum cmake requirement. We should require a quite recent
84
# cmake for the dependency find macros etc. to be up to date.
9-
cmake_minimum_required (VERSION 2.6)
5+
cmake_minimum_required (VERSION 2.8.8)
106

7+
############ Paths
8+
9+
set (WEBSOCKETPP_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
10+
set (WEBSOCKETPP_INCLUDE ${WEBSOCKETPP_ROOT}/websocketpp)
11+
set (WEBSOCKETPP_BUILD_ROOT ${CMAKE_CURRENT_BINARY_DIR})
12+
set (WEBSOCKETPP_BIN ${WEBSOCKETPP_BUILD_ROOT}/bin)
13+
set (WEBSOCKETPP_LIB ${WEBSOCKETPP_BUILD_ROOT}/lib)
14+
15+
# CMake install step prefix. I assume linux users want the prefix to
16+
# be the default /usr or /usr/local so this is only adjusted on Windows.
17+
# This must be set prior to any call to project or it will not be read correctly.
18+
# - Windows: Build the INSTALL project in your solution file.
19+
# - Linux/OSX: make install.
20+
if (WIN32)
21+
set (CMAKE_INSTALL_PREFIX "${WEBSOCKETPP_ROOT}/install" CACHE PATH "")
22+
endif ()
23+
24+
############ Project name and version
1125
set (WEBSOCKETPP_MAJOR_VERSION 0)
12-
set (WEBSOCKETPP_MINOR_VERSION 7)
13-
set (WEBSOCKETPP_PATCH_VERSION 0)
26+
set (WEBSOCKETPP_MINOR_VERSION 8)
27+
set (WEBSOCKETPP_PATCH_VERSION 1)
1428
set (WEBSOCKETPP_VERSION ${WEBSOCKETPP_MAJOR_VERSION}.${WEBSOCKETPP_MINOR_VERSION}.${WEBSOCKETPP_PATCH_VERSION})
1529

30+
if(POLICY CMP0048)
31+
cmake_policy(GET CMP0048 _version_policy)
32+
endif()
33+
34+
if(_version_allowed STREQUAL NEW)
35+
project (websocketpp VERSION ${WEBSOCKETPP_VERSION})
36+
else()
37+
project (websocketpp)
38+
endif()
39+
1640
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1741

1842
set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
@@ -44,21 +68,6 @@ set (CMAKE_CONFIGURATION_TYPES "Release;RelWithDebInfo;Debug" CACHE STRING "Conf
4468
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
4569
include (CMakeHelpers)
4670

47-
############ Paths
48-
49-
set (WEBSOCKETPP_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
50-
set (WEBSOCKETPP_INCLUDE ${WEBSOCKETPP_ROOT}/websocketpp)
51-
set (WEBSOCKETPP_BUILD_ROOT ${CMAKE_CURRENT_BINARY_DIR})
52-
set (WEBSOCKETPP_BIN ${WEBSOCKETPP_BUILD_ROOT}/bin)
53-
set (WEBSOCKETPP_LIB ${WEBSOCKETPP_BUILD_ROOT}/lib)
54-
55-
# CMake install step prefix. I assume linux users want the prefix to
56-
# be the default /usr or /usr/local so this is only adjusted on Windows.
57-
# - Windows: Build the INSTALL project in your solution file.
58-
# - Linux/OSX: make install.
59-
if (MSVC)
60-
set (CMAKE_INSTALL_PREFIX "${WEBSOCKETPP_ROOT}/install")
61-
endif ()
6271

6372
############ Build customization
6473

@@ -193,7 +202,7 @@ if (BUILD_TESTS OR BUILD_EXAMPLES)
193202
endif ()
194203

195204
if (NOT Boost_USE_STATIC_LIBS)
196-
add_definitions (/DBOOST_TEST_DYN_LINK)
205+
add_definitions (-DBOOST_TEST_DYN_LINK)
197206
endif ()
198207

199208
set (Boost_FIND_REQUIRED TRUE)
@@ -250,8 +259,16 @@ print_used_build_config()
250259

251260
export (PACKAGE websocketpp)
252261

253-
configure_file (websocketpp-config.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/websocketpp-config.cmake" @ONLY)
254-
configure_file (websocketpp-configVersion.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/websocketpp-configVersion.cmake" @ONLY)
262+
include(CMakePackageConfigHelpers)
263+
configure_package_config_file(websocketpp-config.cmake.in
264+
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/websocketpp-config.cmake"
265+
PATH_VARS INSTALL_INCLUDE_DIR
266+
INSTALL_DESTINATION "${INSTALL_CMAKE_DIR}"
267+
NO_CHECK_REQUIRED_COMPONENTS_MACRO
268+
)
269+
write_basic_package_version_file("${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/websocketpp-configVersion.cmake"
270+
VERSION ${WEBSOCKETPP_VERSION}
271+
COMPATIBILITY ExactVersion)
255272

256273
# Install the websocketpp-config.cmake and websocketpp-configVersion.cmake
257274
install (FILES

libs/websocketpp/websocketpp-config.cmake.in

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,12 @@
33
# WEBSOCKETPP_FOUND - indicates that the module was found
44
# WEBSOCKETPP_INCLUDE_DIR - include directories
55

6+
@PACKAGE_INIT@
7+
set_and_check(WEBSOCKETPP_INCLUDE_DIR "@PACKAGE_INSTALL_INCLUDE_DIR@")
68
set(WEBSOCKETPP_FOUND TRUE)
7-
set(WEBSOCKETPP_INCLUDE_DIR "@INSTALL_INCLUDE_DIR@")
9+
10+
#This is a bit of a hack, but it works well. It also allows continued support of CMake 2.8
11+
if(${CMAKE_VERSION} VERSION_GREATER 3.0.0 OR ${CMAKE_VERSION} VERSION_EQUAL 3.0.0)
12+
add_library(websocketpp::websocketpp INTERFACE IMPORTED)
13+
set_target_properties(websocketpp::websocketpp PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${WEBSOCKETPP_INCLUDE_DIR}")
14+
endif()

libs/websocketpp/websocketpp-configVersion.cmake.in

Lines changed: 0 additions & 11 deletions
This file was deleted.

libs/websocketpp/websocketpp/close.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ namespace status {
142142
/// or reconnect to the same IP upon user action.
143143
static value const try_again_later = 1013;
144144

145+
/// Indicates that the server was acting as a gateway or proxy and received
146+
/// an invalid response from the upstream server. This is similar to 502
147+
/// HTTP Status Code.
148+
static value const bad_gateway = 1014;
149+
145150
/// An endpoint failed to perform a TLS handshake
146151
/**
147152
* Designated for use in applications expecting a status code to indicate
@@ -178,7 +183,7 @@ namespace status {
178183
*/
179184
inline bool reserved(value code) {
180185
return ((code >= rsv_start && code <= rsv_end) ||
181-
code == 1004 || code == 1014);
186+
code == 1004);
182187
}
183188

184189
/// First value in range that is always invalid on the wire
@@ -248,6 +253,12 @@ namespace status {
248253
return "Extension required";
249254
case internal_endpoint_error:
250255
return "Internal endpoint error";
256+
case service_restart:
257+
return "Service restart";
258+
case try_again_later:
259+
return "Try again later";
260+
case bad_gateway:
261+
return "Bad gateway";
251262
case tls_handshake:
252263
return "TLS handshake failure";
253264
case subprotocol_error:

libs/websocketpp/websocketpp/common/asio.hpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,19 @@ namespace lib {
101101
bool is_neg(T duration) {
102102
return duration.count() < 0;
103103
}
104-
inline lib::chrono::milliseconds milliseconds(long duration) {
105-
return lib::chrono::milliseconds(duration);
106-
}
104+
105+
// If boost believes it has std::chrono available it will use it
106+
// so we should also use it for things that relate to boost, even
107+
// if the library would otherwise use boost::chrono.
108+
#if defined(BOOST_ASIO_HAS_STD_CHRONO)
109+
inline std::chrono::milliseconds milliseconds(long duration) {
110+
return std::chrono::milliseconds(duration);
111+
}
112+
#else
113+
inline lib::chrono::milliseconds milliseconds(long duration) {
114+
return lib::chrono::milliseconds(duration);
115+
}
116+
#endif
107117
#else
108118
// Using boost::asio <1.49 we pretend a deadline timer is a steady
109119
// timer and wrap the negative detection and duration conversion

libs/websocketpp/websocketpp/common/memory.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ namespace lib {
6565
#ifdef _WEBSOCKETPP_CPP11_MEMORY_
6666
using std::shared_ptr;
6767
using std::weak_ptr;
68-
using std::auto_ptr;
6968
using std::enable_shared_from_this;
7069
using std::static_pointer_cast;
7170
using std::make_shared;

libs/websocketpp/websocketpp/common/thread.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@
5151
#endif
5252
#endif
5353

54-
#ifdef _WEBSOCKETPP_CPP11_THREAD_
54+
#if defined(_WEBSOCKETPP_MINGW_THREAD_)
55+
#include <mingw-threads/mingw.thread.h>
56+
#include <mingw-threads/mingw.mutex.h>
57+
#include <mingw-threads/mingw.condition_variable.h>
58+
#elif defined(_WEBSOCKETPP_CPP11_THREAD_)
5559
#include <thread>
5660
#include <mutex>
5761
#include <condition_variable>
@@ -64,7 +68,7 @@
6468
namespace websocketpp {
6569
namespace lib {
6670

67-
#ifdef _WEBSOCKETPP_CPP11_THREAD_
71+
#if defined(_WEBSOCKETPP_CPP11_THREAD_) || defined(_WEBSOCKETPP_MINGW_THREAD_)
6872
using std::mutex;
6973
using std::lock_guard;
7074
using std::thread;

0 commit comments

Comments
 (0)