summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2006-08-01 13:28:03 +0000
committerAntony Dovgal <tony2001@php.net>2006-08-01 13:28:03 +0000
commitad3ad9bb7971a376e953dabbdeb0ed928fb47633 (patch)
treeff53186a25b0875a352420458825a45474dc30f0 /ext
parent1bf915ca2dca23923753c29156ca5531638f003b (diff)
downloadphp-git-ad3ad9bb7971a376e953dabbdeb0ed928fb47633.tar.gz
MFH: fix #38269 (fopen wrapper doesn't fail on invalid hostname with curlwrappers enabled)
Diffstat (limited to 'ext')
-rw-r--r--ext/curl/streams.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/ext/curl/streams.c b/ext/curl/streams.c
index 2941edf855..f4600c00a7 100644
--- a/ext/curl/streams.c
+++ b/ext/curl/streams.c
@@ -396,15 +396,33 @@ php_stream *php_curl_stream_opener(php_stream_wrapper *wrapper, char *filename,
/* fire up the connection; we need to detect a connection error here,
* otherwise the curlstream we return ends up doing nothing useful. */
CURLMcode m;
+ CURLMsg *msg;
+ int msgs_left, msg_found = 0;
while (CURLM_CALL_MULTI_PERFORM == (m = curl_multi_perform(curlstream->multi, &curlstream->pending))) {
; /* spin */
}
if (m != CURLM_OK) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "There was an error mcode=%d", m);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", curl_multi_strerror(m));
+ php_stream_close(stream);
+ return NULL;
+ }
+
+ /* we have only one curl handle here, even though we use multi syntax,
+ * so it's ok to fail on any error */
+ while ((msg = curl_multi_info_read(curlstream->multi, &msgs_left))) {
+ if (msg->data.result == CURLE_OK) {
+ continue;
+ } else {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", curl_easy_strerror(msg->data.result));
+ msg_found++;
+ }
+ }
+ if (msg_found) {
+ php_stream_close(stream);
+ return NULL;
}
-
}
return stream;