PKG_NAME:=pianod
PKG_VERSION:=173
-PKG_RELEASE:=2
+PKG_RELEASE:=3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://deviousfish.com/Downloads/pianod/
PIANOD_CLIENT:=pianod-client-compiled-51.tar.gz
define Download/pianod-client
- URL:=$(PKG_SOURCE_URL)/Devel
+ URL:=$(PKG_SOURCE_URL)
FILE:=$(PIANOD_CLIENT)
MD5SUM:=abbdee5627bcee6a00c8304da8b4e2e7
endef
--- a/src/libwaitress/waitress.c
+++ b/src/libwaitress/waitress.c
-@@ -813,7 +813,14 @@ static WaitressReturn_t WaitressConnect
- sizeof (sockopt));
+@@ -805,34 +805,37 @@ static WaitressReturn_t WaitressConnect
+ int pollres;
- /* non-blocking connect will return immediately */
-- connect (sock, gacurr->ai_addr, gacurr->ai_addrlen);
-+ if (connect (sock, gacurr->ai_addr, gacurr->ai_addrlen) == -1) {
-+ // Error if not in-progress or immediate success
-+ if (errno != EINPROGRESS) {
-+ // Close socket and try alternatives
-+ close (sock);
-+ continue;
-+ }
-+ }
+ /* we need shorter timeouts for connect() */
+- fcntl (sock, F_SETFL, O_NONBLOCK);
++ pollres = fcntl (sock, F_SETFL, O_NONBLOCK);
++ assert (pollres != -1);
- pollres = WaitressPollLoop (sock, POLLOUT, waith->timeout);
- if (pollres == 0) {
+- /* increase socket receive buffer */
+- const int sockopt = 256*1024;
+- setsockopt (sock, SOL_SOCKET, SO_RCVBUF, &sockopt,
+- sizeof (sockopt));
+-
+- /* non-blocking connect will return immediately */
+- connect (sock, gacurr->ai_addr, gacurr->ai_addrlen);
+-
+- pollres = WaitressPollLoop (sock, POLLOUT, waith->timeout);
+- if (pollres == 0) {
+- ret = WAITRESS_RET_TIMEOUT;
+- } else if (pollres == -1) {
+- ret = WAITRESS_RET_ERR;
+- } else {
+- /* check connect () return value */
+- socklen_t pollresSize = sizeof (pollres);
+- getsockopt (sock, SOL_SOCKET, SO_ERROR, &pollres,
+- &pollresSize);
+- if (pollres != 0) {
+- ret = WAITRESS_RET_CONNECT_REFUSED;
++ if (connect (sock, gacurr->ai_addr, gacurr->ai_addrlen) != -1) {
++ /* working */
++ waith->request.sockfd = sock;
++ break;
++ } else if (errno == EINPROGRESS) {
++ /* wait for connect to succeed */
++ pollres = WaitressPollLoop (sock, POLLOUT, waith->timeout);
++ if (pollres == 0) {
++ ret = WAITRESS_RET_TIMEOUT;
++ } else if (pollres == -1) {
++ ret = WAITRESS_RET_ERR;
+ } else {
+- /* this one is working */
+- waith->request.sockfd = sock;
+- break;
++ /* check connect () return value */
++ socklen_t pollresSize = sizeof (pollres);
++ getsockopt (sock, SOL_SOCKET, SO_ERROR, &pollres,
++ &pollresSize);
++ if (pollres != 0) {
++ ret = WAITRESS_RET_CONNECT_REFUSED;
++ } else {
++ /* this one is working */
++ waith->request.sockfd = sock;
++ break;
++ }
+ }
++ } else {
++ ret = WAITRESS_RET_ERR;
+ }
++
+ close (sock);
+ }
+ }
--- a/src/libfootball/fb_service.c
+++ b/src/libfootball/fb_service.c
@@ -111,6 +111,8 @@ static bool fb_setup_socket (FB_SERVICE
--- a/src/libwaitress/waitress.c
+++ b/src/libwaitress/waitress.c
-@@ -922,14 +922,14 @@ static WaitressReturn_t WaitressSendRequ
+@@ -918,14 +918,14 @@ static WaitressReturn_t WaitressSendRequ
if (WaitressProxyEnabled (waith) && !waith->url.tls) {
snprintf (buf, WAITRESS_BUFFER_SIZE,
"%s http://%s:%s/%s HTTP/" WAITRESS_HTTP_VERSION "\r\n"
return WAITRESS_RET_OK;
}
-@@ -807,11 +878,6 @@ static WaitressReturn_t WaitressConnect
- /* we need shorter timeouts for connect() */
- fcntl (sock, F_SETFL, O_NONBLOCK);
-
-- /* increase socket receive buffer */
-- const int sockopt = 256*1024;
-- setsockopt (sock, SOL_SOCKET, SO_RCVBUF, &sockopt,
-- sizeof (sockopt));
--
- /* non-blocking connect will return immediately */
- if (connect (sock, gacurr->ai_addr, gacurr->ai_addrlen) == -1) {
- // Error if not in-progress or immediate success
-@@ -880,6 +946,11 @@ static WaitressReturn_t WaitressConnect
+@@ -876,6 +947,12 @@ static WaitressReturn_t WaitressConnect
}
}
+#if defined(USE_POLARSSL)
++ ssl_set_hostname (&waith->request.sslCtx->ssl, waith->url.host);
+ if (ssl_handshake (&waith->request.sslCtx->ssl) != 0) {
+ return WAITRESS_RET_TLS_HANDSHAKE_ERR;
+ }
/* Ignore return code as connection will likely still succeed */
gnutls_server_name_set (waith->request.tlsSession, GNUTLS_NAME_DNS,
waith->url.host, strlen (waith->url.host));
-@@ -887,14 +958,15 @@ static WaitressReturn_t WaitressConnect
+@@ -883,14 +960,15 @@ static WaitressReturn_t WaitressConnect
if (gnutls_handshake (waith->request.tlsSession) != GNUTLS_E_SUCCESS) {
return WAITRESS_RET_TLS_HANDSHAKE_ERR;
}
}
return WAITRESS_RET_OK;
-@@ -1120,6 +1192,21 @@ WaitressReturn_t WaitressFetchCall (Wait
+@@ -1116,6 +1194,21 @@ WaitressReturn_t WaitressFetchCall (Wait
waith->request.contentLengthKnown = false;
if (waith->url.tls) {
gnutls_init (&waith->request.tlsSession, GNUTLS_CLIENT);
gnutls_set_default_priority (waith->request.tlsSession);
-@@ -1137,6 +1224,7 @@ WaitressReturn_t WaitressFetchCall (Wait
+@@ -1133,6 +1226,7 @@ WaitressReturn_t WaitressFetchCall (Wait
WaitressPollRead);
gnutls_transport_set_push_function (waith->request.tlsSession,
WaitressPollWrite);
}
/* buffer is required for connect already */
-@@ -1148,15 +1236,22 @@ WaitressReturn_t WaitressFetchCall (Wait
+@@ -1144,15 +1238,22 @@ WaitressReturn_t WaitressFetchCall (Wait
if ((wRet = WaitressSendRequest (waith)) == WAITRESS_RET_OK) {
wRet = WaitressReceiveResponse (waith);
}