From 8766e7009ed1f962228f7d301aa5da0ddbc32ade Mon Sep 17 00:00:00 2001
From: Adrien Beraud <adrien.beraud@savoirfairelinux.com>
Date: Fri, 2 Jun 2017 11:49:27 +0200
Subject: [PATCH] contrib/restbed: handle DNS resolution error
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Add patch to fix restbed DNS resolution error,
that was ignored, causing indefinite hangup.

Change-Id: I40fff6a8662e8d204e0d4b813c4a94adadb99b65
Reviewed-by: Anthony Léonard <anthony.leonard@savoirfairelinux.com>
---
 .../src/restbed/dns-resolution-error.patch    | 31 +++++++++++++++++++
 contrib/src/restbed/rules.mak                 |  1 +
 2 files changed, 32 insertions(+)
 create mode 100644 contrib/src/restbed/dns-resolution-error.patch

diff --git a/contrib/src/restbed/dns-resolution-error.patch b/contrib/src/restbed/dns-resolution-error.patch
new file mode 100644
index 0000000000..e645e57242
--- /dev/null
+++ b/contrib/src/restbed/dns-resolution-error.patch
@@ -0,0 +1,31 @@
+From: Adrien Beraud <adrien.beraud@savoirfairelinux.com>
+Date: Fri, 2 Jun 2017 11:24:12 +0200
+Subject: [PATCH] Handle DNS resolution error
+
+DNS resolution error currently causes
+indefinite hangup as the callback is
+not called and higher-level layers
+are not informed.
+
+This commit bubbles up the error,
+allowing the request to fail.
+---
+ source/corvusoft/restbed/detail/socket_impl.cpp | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/source/corvusoft/restbed/detail/socket_impl.cpp b/source/corvusoft/restbed/detail/socket_impl.cpp
+index 313a421..665cfe7 100644
+--- a/source/corvusoft/restbed/detail/socket_impl.cpp
++++ b/source/corvusoft/restbed/detail/socket_impl.cpp
+@@ -145,6 +145,8 @@ namespace restbed
+                         m_is_open = true;
+                         callback( error );
+                     } );
++                } else {
++                    callback( error );
+                 }
+             } );
+         }
+-- 
+2.11.0
+
diff --git a/contrib/src/restbed/rules.mak b/contrib/src/restbed/rules.mak
index 38b655c5a2..89c6b0d0a6 100644
--- a/contrib/src/restbed/rules.mak
+++ b/contrib/src/restbed/rules.mak
@@ -44,6 +44,7 @@ restbed: restbed-$(RESTBED_VERSION).tar.gz
 	$(APPLY) $(SRC)/restbed/CMakeLists.patch
 	$(APPLY) $(SRC)/restbed/strand.patch
 	$(APPLY) $(SRC)/restbed/uri_cpp.patch
+	$(APPLY) $(SRC)/restbed/dns-resolution-error.patch
 	$(MOVE)
 
 .restbed: restbed toolchain.cmake
-- 
GitLab