Skip to content
Snippets Groups Projects
Commit 619e143f authored by Adrien Béraud's avatar Adrien Béraud
Browse files

contrib: update restbed


* Update restbed to latest master 
* Removed dropped Kashmir dependency
* Removed merged/obsolete patches (locale, async read, strand)
* Use branch including necessary findopenssl changes for contrib

Change-Id: I6cdf7de1005f82abeac77eb6bfb0002df83c8017
Reviewed-by: default avatarPhilippe Gorley <philippe.gorley@savoirfairelinux.com>
parent 1e2e3c9a
Branches
Tags
No related merge requests found
e86964f4269e9f8b760b749163b92d6d3c72a94a8c5732e3c36c41fc74e2b16de35e2494c3ffe468e38a09aafe58a973fab702da0d632b5eb829480da6b32376 kashmir-dependency-2f3913f49c4ac7f9bff9224db5178f6f8f0ff3ee.tar.gz
# -*- mode: makefile; -*-
#
# Copyright (C) 2018 Savoir-faire Linux Inc.
#
# Author: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
KASHMIR_VERSION := 2f3913f49c4ac7f9bff9224db5178f6f8f0ff3ee
KASHMIR_URL := https://github.com/Corvusoft/kashmir-dependency/archive/$(KASHMIR_VERSION).tar.gz
# Pure dependency of restbed: do not add to PKGS.
$(TARBALLS)/kashmir-dependency-$(KASHMIR_VERSION).tar.gz:
$(call download,$(KASHMIR_URL))
kashmir-dependency: kashmir-dependency-$(KASHMIR_VERSION).tar.gz
$(UNPACK)
$(MOVE)
.kashmir-dependency: kashmir-dependency .sum-kashmir-dependency
mkdir -p "$(PREFIX)/include"
cd $< && cp -r kashmir "$(PREFIX)/include"
touch $@
.sum-kashmir-dependency: kashmir-dependency-$(KASHMIR_VERSION).tar.gz
26fa79c08cf9414bb26a0a6d3573e71d4df0facfe1a0d86a5935bdf5203f7d1fb633fa99802bc2c9104eed7ab67e9cef3e1679ca4a12b982bfd49d7f5a1c088c restbed-df867a858dddc4cf6ca8642da02720bd65ba239a.tar.gz b4a4c37eaadeb5f39b743c0bff74b8be526b7cda4777266a7ffde1fa5a89e0879b5523102f4b585989e8c029ebc9b5f1d18fa26876fd5eca239cf96222fea501 restbed-c3e28adaf8b15b34162da6c1ed5514606288f91b.tar.gz
\ No newline at end of file
From 09b542eea3fb3038d02ff056d41dea16bfe889bd Mon Sep 17 00:00:00 2001
From: AmarOk <contact@enconn.fr>
Date: Tue, 5 Dec 2017 10:45:53 -0600
Subject: [PATCH]socket_impl: replace read_until by async_read_until
---
source/corvusoft/restbed/detail/socket_impl.cpp | 62 +++++++++++++++++++------
1 file changed, 49 insertions(+), 13 deletions(-)
diff --git a/source/corvusoft/restbed/detail/socket_impl.cpp b/source/corvusoft/restbed/detail/socket_impl.cpp
index 90e8b04..379f1c7 100644
--- a/source/corvusoft/restbed/detail/socket_impl.cpp
+++ b/source/corvusoft/restbed/detail/socket_impl.cpp
@@ -417,28 +417,47 @@ namespace restbed
m_timer->expires_from_now( m_timeout );
m_timer->async_wait( bind( &SocketImpl::connection_timeout_handler, this, shared_from_this( ), _1 ) );
+
size_t size = 0;
+ auto finished = std::make_shared<bool>(false);
+ auto sharedError = std::make_shared<error_code>();
+ auto sharedSize = std::make_shared<size_t>(0);
+
#ifdef BUILD_SSL
-
+
if ( m_socket not_eq nullptr )
{
#endif
- size = asio::read( *m_socket, *data, asio::transfer_at_least( length ), error );
+ asio::async_read( *m_socket, *data, asio::transfer_at_least( length ),
+ [ this, finished, sharedSize, sharedError ]( const error_code & error, size_t size ) {
+ *sharedError = error;
+ *sharedSize = size;
+ *finished = true;
+ });
#ifdef BUILD_SSL
}
else
{
- size = asio::read( *m_ssl_socket, *data, asio::transfer_at_least( length ), error );
+ asio::async_read( *m_ssl_socket, *data, asio::transfer_at_least( length ),
+ [ this, finished, sharedSize, sharedError ]( const error_code & error, size_t size ) {
+ *sharedError = error;
+ *sharedSize = size;
+ *finished = true;
+ });
}
-
#endif
+ auto& io_service = m_socket->get_io_service( );
+ while (!*finished)
+ io_service.run_one();
+ error = *sharedError;
+ size = *sharedSize;
m_timer->cancel( );
-
+
if ( error )
{
m_is_open = false;
}
-
+
return size;
}
@@ -549,28 +568,45 @@ namespace restbed
m_timer->async_wait( bind( &SocketImpl::connection_timeout_handler, this, shared_from_this( ), _1 ) );
size_t length = 0;
-
+ auto finished = std::make_shared<bool>(false);
+ auto sharedError = std::make_shared<error_code>();
+ auto sharedLength = std::make_shared<size_t>(0);
+
#ifdef BUILD_SSL
-
+
if ( m_socket not_eq nullptr )
{
#endif
- length = asio::read_until( *m_socket, *data, delimiter, error );
+ asio::async_read_until( *m_socket, *data, delimiter,
+ [ this, finished, sharedLength, sharedError ]( const error_code & error, size_t length ) {
+ *sharedError = error;
+ *sharedLength = length;
+ *finished = true;
+ });
#ifdef BUILD_SSL
}
else
{
- length = asio::read_until( *m_ssl_socket, *data, delimiter, error );
+ asio::async_read_until( *m_ssl_socket, *data, delimiter,
+ [ this, finished, sharedLength, sharedError ]( const error_code & error, size_t length ) {
+ *sharedError = error;
+ *sharedLength = length;
+ *finished = true;
+ });
}
-
#endif
+ auto& io_service = m_socket->get_io_service( );
+ while (!*finished)
+ io_service.run_one();
+ error = *sharedError;
+ length = *sharedLength;
m_timer->cancel( );
-
+
if ( error )
{
m_is_open = false;
}
-
+
return length;
}
--
2.14.3
From 4df62857834ac7d2f7919e2d71f07530883a8dc2 Mon Sep 17 00:00:00 2001
From: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
Date: Thu, 5 Apr 2018 21:11:13 -0400
Subject: [PATCH] findopenssl: avoid cmake to add root_path
---
cmake/modules/Findopenssl.cmake | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/cmake/modules/Findopenssl.cmake b/cmake/modules/Findopenssl.cmake
index 4edbf5a..3455a1f 100644
--- a/cmake/modules/Findopenssl.cmake
+++ b/cmake/modules/Findopenssl.cmake
@@ -1,8 +1,19 @@
# Copyright 2013-2017, Corvusoft Ltd, All Rights Reserved.
-find_library( ssl_LIBRARY ssl ssleay32 HINTS "${PROJECT_SOURCE_DIR}/dependency/openssl/out32dll" "${PROJECT_SOURCE_DIR}/dependency/openssl" "/usr/local/opt/openssl/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib" )
-find_library( crypto_LIBRARY crypto libeay32 HINTS "${PROJECT_SOURCE_DIR}/dependency/openssl/out32dll" "${PROJECT_SOURCE_DIR}/dependency/openssl" "/usr/local/opt/openssl/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib" )
-find_path( ssl_INCLUDE openssl/ssl.h HINTS "${PROJECT_SOURCE_DIR}/dependency/openssl/inc32" "${PROJECT_SOURCE_DIR}/dependency/openssl/include" "/usr/local/opt/openssl/include" "/usr/include" "/usr/local/include" "/opt/local/include" )
+find_library( ssl_LIBRARY ssl ssleay32 HINTS "${PROJECT_SOURCE_DIR}/dependency/openssl/out32dll" "${PROJECT_SOURCE_DIR}/dependency/openssl" "/usr/local/opt/openssl/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib")
+find_library( crypto_LIBRARY crypto libeay32 HINTS "${PROJECT_SOURCE_DIR}/dependency/openssl/out32dll" "${PROJECT_SOURCE_DIR}/dependency/openssl" "/usr/local/opt/openssl/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib")
+find_path( ssl_INCLUDE openssl/ssl.h HINTS "${PROJECT_SOURCE_DIR}/dependency/openssl/inc32" "${PROJECT_SOURCE_DIR}/dependency/openssl/include" "/usr/local/opt/openssl/include" "/usr/include" "/usr/local/include" "/opt/local/include")
+
+if ( NOT ssl_LIBRARY )
+ find_library( ssl_LIBRARY ssl ssleay32 HINTS "${PROJECT_SOURCE_DIR}/dependency/openssl/out32dll" "${PROJECT_SOURCE_DIR}/dependency/openssl" "/usr/local/opt/openssl/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib" NO_CMAKE_FIND_ROOT_PATH)
+endif ( )
+if ( NOT crypto_LIBRARY )
+ find_library( crypto_LIBRARY crypto libeay32 HINTS "${PROJECT_SOURCE_DIR}/dependency/openssl/out32dll" "${PROJECT_SOURCE_DIR}/dependency/openssl" "/usr/local/opt/openssl/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib" NO_CMAKE_FIND_ROOT_PATH)
+endif ( )
+if ( NOT ssl_INCLUDE )
+ find_path( ssl_INCLUDE openssl/ssl.h HINTS "${PROJECT_SOURCE_DIR}/dependency/openssl/inc32" "${PROJECT_SOURCE_DIR}/dependency/openssl/include" "/usr/local/opt/openssl/include" "/usr/include" "/usr/local/include" "/opt/local/include" NO_CMAKE_FIND_ROOT_PATH)
+endif ( )
+
if ( ssl_INCLUDE AND ssl_LIBRARY AND crypto_LIBRARY )
set( OPENSSL_FOUND TRUE )
--
2.14.3
From 4c8762f0cd993613c29f051fde19a3f8caeac401 Mon Sep 17 00:00:00 2001
From: Adrien Beraud <adrien.beraud@savoirfairelinux.com>
Date: Mon, 31 Jul 2017 09:47:50 -0400
Subject: [PATCH] http: check for locale before duplicating string
---
source/corvusoft/restbed/detail/http_impl.cpp | 16 +++++++++++-----
source/corvusoft/restbed/http.cpp | 16 +++++++++++-----
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/source/corvusoft/restbed/detail/http_impl.cpp b/source/corvusoft/restbed/detail/http_impl.cpp
index 54b7c15..f25d6eb 100644
--- a/source/corvusoft/restbed/detail/http_impl.cpp
+++ b/source/corvusoft/restbed/detail/http_impl.cpp
@@ -96,17 +96,23 @@ namespace restbed
protocol = "HTTP";
}
- char* locale = strdup( setlocale( LC_NUMERIC, nullptr ) );
- setlocale( LC_NUMERIC, "C" );
+ char* locale = nullptr;
+ if (auto current_locale = setlocale( LC_NUMERIC, nullptr ) )
+ {
+ locale = strdup(current_locale);
+ setlocale( LC_NUMERIC, "C" );
+ }
auto data = String::format( "%s %s %s/%.1f\r\n",
request->get_method( ).data( ),
path.data( ),
protocol.data( ),
request->get_version( ) );
-
- setlocale( LC_NUMERIC, locale );
- free( locale );
+
+ if (locale) {
+ setlocale( LC_NUMERIC, locale );
+ free( locale );
+ }
auto headers = request->get_headers( );
diff --git a/source/corvusoft/restbed/http.cpp b/source/corvusoft/restbed/http.cpp
index 7648501..9722f64 100644
--- a/source/corvusoft/restbed/http.cpp
+++ b/source/corvusoft/restbed/http.cpp
@@ -62,17 +62,23 @@ namespace restbed
Bytes Http::to_bytes( const shared_ptr< Response >& value )
{
- char* locale = strdup( setlocale( LC_NUMERIC, nullptr ) );
- setlocale( LC_NUMERIC, "C" );
+ char* locale = nullptr;
+ if (auto current_locale = setlocale( LC_NUMERIC, nullptr ) )
+ {
+ locale = strdup(current_locale);
+ setlocale( LC_NUMERIC, "C" );
+ }
auto data = String::format( "%s/%.1f %i %s\r\n",
value->get_protocol( ).data( ),
value->get_version( ),
value->get_status_code( ),
value->get_status_message( ).data( ) );
-
- setlocale( LC_NUMERIC, locale );
- free( locale );
+
+ if (locale) {
+ setlocale( LC_NUMERIC, locale );
+ free( locale );
+ }
auto headers = value->get_headers( );
--
2.11.0
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
RESTBED_VERSION := df867a858dddc4cf6ca8642da02720bd65ba239a RESTBED_VERSION := c3e28adaf8b15b34162da6c1ed5514606288f91b
RESTBED_URL := https://github.com/corvusoft/restbed/archive/$(RESTBED_VERSION).tar.gz RESTBED_URL := https://github.com/aberaud/restbed/archive/$(RESTBED_VERSION).tar.gz
# Pure dependency of OpenDHT: do not add to PKGS. # Pure dependency of OpenDHT: do not add to PKGS.
...@@ -31,11 +31,11 @@ endif ...@@ -31,11 +31,11 @@ endif
$(TARBALLS)/restbed-$(RESTBED_VERSION).tar.gz: $(TARBALLS)/restbed-$(RESTBED_VERSION).tar.gz:
$(call download,$(RESTBED_URL)) $(call download,$(RESTBED_URL))
DEPS_restbed = asio kashmir-dependency libressl DEPS_restbed = asio libressl
RESTBED_CONF = -DBUILD_TESTS=NO \ RESTBED_CONF = -DBUILD_TESTS=NO \
-DBUILD_EXAMPLES=NO \
-DBUILD_SSL=YES \ -DBUILD_SSL=YES \
-DBUILD_STATIC=YES \
-DBUILD_SHARED=NO \ -DBUILD_SHARED=NO \
-DCMAKE_INCLUDE_PATH=$(PREFIX)/include \ -DCMAKE_INCLUDE_PATH=$(PREFIX)/include \
-DCMAKE_INSTALL_PREFIX=$(PREFIX) \ -DCMAKE_INSTALL_PREFIX=$(PREFIX) \
...@@ -43,9 +43,6 @@ RESTBED_CONF = -DBUILD_TESTS=NO \ ...@@ -43,9 +43,6 @@ RESTBED_CONF = -DBUILD_TESTS=NO \
restbed: restbed-$(RESTBED_VERSION).tar.gz .sum-restbed restbed: restbed-$(RESTBED_VERSION).tar.gz .sum-restbed
$(UNPACK) $(UNPACK)
$(APPLY) $(SRC)/restbed/strand.patch
$(APPLY) $(SRC)/restbed/async_read_until.patch
$(APPLY) $(SRC)/restbed/findopenssl.patch
$(MOVE) $(MOVE)
.restbed: restbed toolchain.cmake .restbed: restbed toolchain.cmake
......
From a330edb28151830aeaf08a71e42cb6618c25ef2f Mon Sep 17 00:00:00 2001
From: Sébastien Blin <sebastiem.blin@savoirfairelinux.fr>
Date: Tue, 5 Dec 2017 10:31:21 -0600
Subject: [PATCH]update strand header for asio
---
source/corvusoft/restbed/detail/socket_impl.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source/corvusoft/restbed/detail/socket_impl.hpp b/source/corvusoft/restbed/detail/socket_impl.hpp
index b10c3f7..02df572 100644
--- a/source/corvusoft/restbed/detail/socket_impl.hpp
+++ b/source/corvusoft/restbed/detail/socket_impl.hpp
@@ -23,7 +23,7 @@
#include <asio/streambuf.hpp>
#include <asio/steady_timer.hpp>
#include <asio/io_service.hpp>
-#include <asio/io_service_strand.hpp>
+#include <asio/strand.hpp>
#ifdef BUILD_SSL
#include <asio/ssl.hpp>
--
2.14.3
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment