title: cURL error 26 couldn't open file
body: <p>So, need help.</p>
  
  <p>prePS - code works but not works fine when load test.</p>
  
  <p>So, at all, php code get from user a file and save it on cluster(4 nodes) as tree parts.</p>
  
  <p>so, simple code like.</p>
  
  <pre><code>$user_file = get_full_filename_of_userfile_from_post_array('user_file');
  
  $fin = fopen($user_file,'rb');
  
  $fout1 = fopen(get_uniq_name('p1'),'wb');
  $fout2 = fopen(get_uniq_name('p2'),'wb');
  $fout3 = fopen(get_uniq_name('p3'),'wb');
  
  while ($part = fread($fin))
  {
  fwrite($fout1,get_1_part($part));
  fwrite($fout2,get_2_part($part));
  fwrite($fout3,get_3_part($part));
  }
  fclose($fin);
  fclose($fout1);
  fclose($fout2);
  fclose($fout3);
  
  $location = get_random_nodes(3,$array_of_existing_nodes);
  
  foreach($location as $key =&gt; $node)//key 1..3
  {
  if(is_local_node($node)
  {
  save_local_file(get_part_file_name($key));
  }
  else
  {
  save_remote_file(get_part_file_name($key),$node);
  }
  }
  
  //delete tmp files, logs,...etc
  </code></pre>
  
  <p>save_remote_file() - using cURL sends a file POST method like in docs</p>
  
  <pre><code>$post_data = array(
  'md5sum' =&gt; $md5sum,
  'ctime'  =&gt; $ctime,
  .....
  'file'   =&gt; @.$upload_file_full_name,
  );
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, Config::get('connect_curl_timeout'));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
  curl_setopt($ch, CURLOPT_URL, $URL.'/index.php');
  curl_setopt($ch, CURLOPT_PORT, Config::get('NODES_PORT'));
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_FAILONERROR, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  </code></pre>
  
  <p>So, during test, I upload 14000 files, a file per request, 10 request per node (parallel).
  php code, check file and get answer, and then in background saving file on cluster.
  (yes ,I know that it would be nice to create daemon for saving - it is a task for future)</p>
  
  <p>SO, sometime, there may be about 100, or even 200 php processes on node, in background
  (use php-fpm function )</p>
  
  <pre><code>ignore_user_abort(true);
  set_time_limit(0);
  session_commit();
  
  if(function_exists('fastcgi_finish_request'))
      fastcgi_finish_request();
  </code></pre>
  
  <p>A few calculation.
  14000 files = 14000*3=42000parts, saveing on random 3 from 4, so 25% parts save locally, 75% -remote
  = 0.75*42000 = 31500 remote saveings</p>
  
  <p>during test I gets about 100 errors on all nodes from curl
  errno = 26
  errer = couldn't open file "##ІИP_zOж
  лЅHж"//it is stranger, because origin file name - it is about 124 chars in name. example</p>
  
  <p>/var/vhosts/my.domains.com/www/process/r_5357bc33f3686_h1398258739.9968.758df087f8db9b340653ceb1abf160ae8512db03.chunk0.part2</p>
  
  <p>before code with cURL , I added checks file_exists($upload_file_full_name)
  and is_readable($upload_file_full_name); if not - log it.</p>
  
  <p>checks passed good, but curl returns error(100 times from 31500 ones)</p>
  
  <p>also, add code, if error, wait 10secs, try againg, wait 10secs, try, wait 10 try.</p>
  
  <p>always all if first try with error, all next tries with error too, but according logs, at the same time another php processes what are saving other files, good send a part via curl.</p>
  
  <p>So I don't understand, how can I find a reason and fixing it.</p>