summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierrick Charron <pierrick@php.net>2018-09-17 20:30:18 -0400
committerPierrick Charron <pierrick@php.net>2018-09-17 20:30:18 -0400
commitbc1ecd5d7f059e66088278ea73d5e8ecdd8db5af (patch)
tree912a408e51e050b9658b3825a5b214e677d5722c
parent3691b6d245db6f69b5844ed86fa623d587d8d626 (diff)
parent3bb218a0a776f8673ea8fab1fb311b760afc0860 (diff)
downloadphp-git-bc1ecd5d7f059e66088278ea73d5e8ecdd8db5af.tar.gz
Merge branch 'PHP-7.1' into PHP-7.2
-rw-r--r--NEWS4
-rw-r--r--ext/curl/multi.c18
2 files changed, 21 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index fa5b68f596..166745444a 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ PHP NEWS
. Fixed bug #76800 (foreach inconsistent if array modified during loop).
(Dmitry)
+- CURL:
+ . Fixed bug #76480 (Use curl_multi_wait() so that timeouts are respected).
+ (Pierrick)
+
- Opcache:
. Fixed bug #76832 (ZendOPcache.MemoryBase periodically deleted by the OS).
(Anatol)
diff --git a/ext/curl/multi.c b/ext/curl/multi.c
index 55c33a8c4f..3afe8ac413 100644
--- a/ext/curl/multi.c
+++ b/ext/curl/multi.c
@@ -192,6 +192,7 @@ PHP_FUNCTION(curl_multi_remove_handle)
}
/* }}} */
+#if LIBCURL_VERSION_NUM < 0x071c00
static void _make_timeval_struct(struct timeval *to, double timeout) /* {{{ */
{
unsigned long conv;
@@ -201,6 +202,7 @@ static void _make_timeval_struct(struct timeval *to, double timeout) /* {{{ */
to->tv_usec = conv % 1000000;
}
/* }}} */
+#endif
/* {{{ proto int curl_multi_select(resource mh[, double timeout])
Get all the sockets associated with the cURL extension, which can then be "selected" */
@@ -208,12 +210,16 @@ PHP_FUNCTION(curl_multi_select)
{
zval *z_mh;
php_curlm *mh;
+ double timeout = 1.0;
+#if LIBCURL_VERSION_NUM >= 0x071c00 /* Available since 7.28.0 */
+ int numfds = 0;
+#else
fd_set readfds;
fd_set writefds;
fd_set exceptfds;
int maxfd;
- double timeout = 1.0;
struct timeval to;
+#endif
CURLMcode error = CURLM_OK;
ZEND_PARSE_PARAMETERS_START(1,2)
@@ -226,6 +232,15 @@ PHP_FUNCTION(curl_multi_select)
RETURN_FALSE;
}
+#if LIBCURL_VERSION_NUM >= 0x071c00 /* Available since 7.28.0 */
+ error = curl_multi_wait(mh->multi, NULL, 0, (unsigned long) timeout * 1000.0, &numfds);
+ if (CURLM_OK != error) {
+ SAVE_CURLM_ERROR(mh, error);
+ RETURN_LONG(-1);
+ }
+
+ RETURN_LONG(numfds);
+#else
_make_timeval_struct(&to, timeout);
FD_ZERO(&readfds);
@@ -239,6 +254,7 @@ PHP_FUNCTION(curl_multi_select)
RETURN_LONG(-1);
}
RETURN_LONG(select(maxfd + 1, &readfds, &writefds, &exceptfds, &to));
+#endif
}
/* }}} */