1--TEST-- 2Segfault due to libcurl connection caching 3--CREDITS-- 4--SKIPIF-- 5<?php 6if (!extension_loaded("curl")) exit("skip curl extension not loaded"); 7if (false === getenv('PHP_CURL_FTP_REMOTE_SERVER')) exit("skip PHP_CURL_FTP_REMOTE_SERVER env variable is not defined"); 8if (false === getenv('PHP_CURL_FTP_REMOTE_USER')) exit("skip PHP_CURL_FTP_REMOTE_USER env variable is not defined"); 9if (false === getenv('PHP_CURL_FTP_REMOTE_PASSWD')) exit("skip PHP_CURL_FTP_REMOTE_PASSWD env variable is not defined"); 10?> 11--FILE-- 12<?php 13 $host = getenv('PHP_CURL_FTP_REMOTE_SERVER'); 14 $username = getenv('PHP_CURL_FTP_REMOTE_USER'); 15 $password = getenv('PHP_CURL_FTP_REMOTE_PASSWD'); 16 17 // FTP this script to a server 18 $fp = fopen ( __FILE__ , "r" ); 19 $url = "ftp://$username:$password@$host/" ; 20 21 $ch = curl_init (); 22 23 curl_setopt ( $ch , CURLOPT_URL, $url ); 24 curl_setopt ( $ch , CURLOPT_RETURNTRANSFER, 1 ); 25 26 //force passive connection 27 curl_setopt ( $ch , CURLOPT_FTP_USE_EPSV, 0 ); 28 curl_setopt ( $ch , CURLOPT_FTP_SKIP_PASV_IP, 1 ); 29 30 $cmh = curl_multi_init(); 31 curl_multi_add_handle($cmh, $ch); 32 33 $active = null; 34 35 do { 36 $mrc = curl_multi_exec($cmh, $active); 37 } while ($mrc == CURLM_CALL_MULTI_PERFORM); 38 39 40 while ($active && $mrc == CURLM_OK) { 41 if (curl_multi_select($cmh) != -1) { 42 do { 43 $mrc = curl_multi_exec($cmh, $active); 44 } while ($mrc == CURLM_CALL_MULTI_PERFORM); 45 } 46 } 47 48 var_dump(is_string(curl_multi_getcontent($ch))); 49 curl_multi_remove_handle($cmh, $ch); 50 curl_close($ch); 51 curl_multi_close($cmh); 52?> 53===DONE=== 54--EXPECTF-- 55bool(true) 56===DONE=== 57