From e5356c8cdc9868cb65cd27439ef8d7fd7dbaacd8e3630373a49f8fbcdeef719f Mon Sep 17 00:00:00 2001
From: "P. Janouch"
Date: Mon, 9 May 2016 07:57:49 +0000
Subject: [PATCH] Accepting request 394233 from
home:alarrosa:branches:devel:libraries:c_c++
- Add 0001-Fix-invalid-Network-is-unreachable-errors.patch.
Fixes "Network is unreachable" errors in valid situations when ipv6
is not available but ipv4 is working fine. This also fixes the same
error from happening in applications using libcurl4 (like zypper).
(bsc#915846)
OBS-URL: https://build.opensuse.org/request/show/394233
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/curl?expand=0&rev=162
---
...nvalid-Network-is-unreachable-errors.patch | 34 +++++++++++++++++++
curl.changes | 9 +++++
curl.spec | 3 ++
3 files changed, 46 insertions(+)
create mode 100644 0001-Fix-invalid-Network-is-unreachable-errors.patch
diff --git a/0001-Fix-invalid-Network-is-unreachable-errors.patch b/0001-Fix-invalid-Network-is-unreachable-errors.patch
new file mode 100644
index 0000000..5b0bad1
--- /dev/null
+++ b/0001-Fix-invalid-Network-is-unreachable-errors.patch
@@ -0,0 +1,34 @@
+From 7781f212206ab3e7e26a73132c604b2dbb2498a1 Mon Sep 17 00:00:00 2001
+From: Antonio Larrosa
+Date: Thu, 5 May 2016 19:50:15 +0200
+Subject: [PATCH] Fix invalid "Network is unreachable" errors
+
+Sometimes, in systems with both ipv4 and ipv6 addresses but where the
+network doesn't support ipv6, Curl_is_connected returns an error
+(intermittently) even if the ipv4 socket connects successfully.
+
+This happens because there's a for-loop that iterates on the sockets
+but the error variable is not resetted when the ipv4 is checked and
+is ok.
+
+This patch fixes this problem by setting error to 0 when checking the
+second socket and not having a result yet.
+---
+ lib/connect.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/lib/connect.c b/lib/connect.c
+index 8dfe9e2..ac2f268 100644
+--- a/lib/connect.c
++++ b/lib/connect.c
+@@ -764,6 +764,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
+ rc = Curl_socket_ready(CURL_SOCKET_BAD, conn->tempsock[i], 0);
+
+ if(rc == 0) { /* no connection yet */
++ error = 0;
+ if(curlx_tvdiff(now, conn->connecttime) >= conn->timeoutms_per_addr) {
+ infof(data, "After %ldms connect time, move on!\n",
+ conn->timeoutms_per_addr);
+--
+2.8.1
+
diff --git a/curl.changes b/curl.changes
index 1dff955..6f49e18 100644
--- a/curl.changes
+++ b/curl.changes
@@ -1,3 +1,12 @@
+-------------------------------------------------------------------
+Thu May 5 18:53:47 UTC 2016 - alarrosa@suse.com
+
+- Add 0001-Fix-invalid-Network-is-unreachable-errors.patch.
+ Fixes "Network is unreachable" errors in valid situations when ipv6
+ is not available but ipv4 is working fine. This also fixes the same
+ error from happening in applications using libcurl4 (like zypper).
+ (bsc#915846)
+
-------------------------------------------------------------------
Thu Mar 31 17:25:29 UTC 2016 - idonmez@suse.com
diff --git a/curl.spec b/curl.spec
index 32f06ae..a77d199 100644
--- a/curl.spec
+++ b/curl.spec
@@ -33,6 +33,8 @@ Source4: %{name}.keyring
Patch0: libcurl-ocloexec.patch
Patch1: dont-mess-with-rpmoptflags.diff
Patch3: curl-secure-getenv.patch
+# PATCH-FIX-UPSTREAM 0001-Fix-invalid-Network-is-unreachable-errors.patch -- Fixes "network is unreachable" errors in valid situations when ipv6 is not working but ipv4 is
+Patch4: 0001-Fix-invalid-Network-is-unreachable-errors.patch
BuildRequires: groff
BuildRequires: krb5-mini-devel
BuildRequires: libtool
@@ -97,6 +99,7 @@ user interaction or any kind of interactivity.
%patch0
%patch1
%patch3
+%patch4 -p1
%build
# curl complains if macro definition is contained in CFLAGS