gsoap/gsoap-06-ipv6retry.diff

86 lines
2.5 KiB
Diff
Raw Normal View History

From: Jan Engelhardt <jengelh@inai.de>
Date: 2014-02-04 17:33:39.018679884 +0100
When using getaddrinfo, *all* sockets must be tried.
Remove pointless casts to void *; this implicit even in C++.
(The code is horribly indented and sprinkled with ifdefs much like
Linux 2.4. That should be factored out into separate functions.)
---
gsoap/stdsoap2.cpp | 14 +++++++++++---
gsoap/stdsoap2.h | 2 ++
2 files changed, 13 insertions(+), 3 deletions(-)
Index: gsoap-2.8.17/gsoap/stdsoap2.cpp
===================================================================
--- gsoap-2.8.17.orig/gsoap/stdsoap2.cpp
+++ gsoap-2.8.17/gsoap/stdsoap2.cpp
@@ -3847,7 +3847,7 @@ tcp_connect(struct soap *soap, const cha
}
soap->errmode = 0;
#ifdef WITH_IPV6
- memset((void*)&hints, 0, sizeof(hints));
+ memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
#ifndef WITH_LEAN
if ((soap->omode & SOAP_IO_UDP))
@@ -3868,7 +3868,7 @@ tcp_connect(struct soap *soap, const cha
again:
sk = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
soap->errmode = 0;
-#else
+#else /* WITH_IPV6 */
#ifndef WITH_LEAN
again:
#endif
@@ -3878,7 +3878,7 @@ again:
else
#endif
sk = socket(AF_INET, SOCK_STREAM, 0);
-#endif
+#endif /* WITH_IPV6 */
if (!soap_valid_socket(sk))
{
#ifdef WITH_IPV6
@@ -4081,6 +4081,7 @@ again:
SOAP_SOCKBLOCK(sk)
retries = 10;
#endif
+
for (;;)
{
#ifdef WITH_IPV6
@@ -4089,6 +4090,13 @@ again:
if (connect(sk, (struct sockaddr*)&soap->peer, sizeof(soap->peer)))
#endif
{ err = soap_socket_errno(sk);
+#ifdef WITH_IPV6
+ if (err == SOAP_ECONNREFUSED && res->ai_next != NULL) {
+ soap->fclosesocket(soap, sk);
+ res = res->ai_next;
+ goto again;
+ }
+#endif
#ifndef WITH_LEAN
if (err == SOAP_EADDRINUSE)
{ soap->fclosesocket(soap, sk);
Index: gsoap-2.8.17/gsoap/stdsoap2.h
===================================================================
--- gsoap-2.8.17.orig/gsoap/stdsoap2.h
+++ gsoap-2.8.17/gsoap/stdsoap2.h
@@ -972,11 +972,13 @@ extern "C" {
# define SOAP_EWOULDBLOCK WSAEWOULDBLOCK
# define SOAP_EINPROGRESS WSAEINPROGRESS
# define SOAP_EADDRINUSE WSAEADDRINUSE
+# define SOAP_ECONNREFUSED WSAECONNREFUSED
#else
# define SOAP_ERANGE ERANGE
# define SOAP_EINTR EINTR
# define SOAP_EAGAIN EAGAIN
# define SOAP_EADDRINUSE EADDRINUSE
+# define SOAP_ECONNREFUSED ECONNREFUSED
# ifdef SYMBIAN
# define SOAP_EWOULDBLOCK 9898
# define SOAP_EINPROGRESS 9899