PHP file_get_contents timeout "local file" (NFS/mount) -


i know how set timeout on local file file_get_content (not http uri), sometime nfs mount partition slow , prefer give after time out (5s exemple),

file_get_contents("/mnt/photo/photo.jpg"); 

i read answers other similar questions, guess solutions work http, , not local files:

$ctx = stream_context_create(array('http'=>array('timeout' => 1200))); 

i suppose solution not me, it's web, right?

ini_set('default_socket_timeout', 900); 

i'm afraid, can not control nfs timeouts via php, nfs protocol options controlled via mount options. php has no idea whether file on nfs, or on local hard drive. believe, there ways determine fact file on nfs, won't give control on timeouts.

there 2 types of timeouts in nfs: minor , major. minor timeout occurs, when no confirmation received server within timeout specified in mount options (timeo). operation retried, , timeout doubled. major timeout occurs, when timeout interval reaches 60 seconds. happens next depends on other options.

by default, original timeout doubled, , retries continued endlessly. said volume hard-mounted (hard option on default). if volume mounted soft option, major timeout cause i/o error. should consider soft-mounting. however, note default timeout 7(0.7 seconds), small soft-mounting. should estimate possible waiting time, , adjust timeo option accordingly.

another interesting option intr, supposed allow interruption of pending nfs operations. however, option deprecated after kernel version 2.6.25. sigkill can interrupt nfs operation. may want implement watchdog process using fork() function. child process may run nfs operation, , parent may kill after period of time.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -