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