php - why does apache/server die when i make a typo and cause a never ending loop? -


this more of fundamental question @ how apache/threading works. in hypothetical (read: suck , write terrible code), write code enters infinite-recursion phases of it's life. then, what's expected, happens. serve stalls.

even if close tab, open new one, , hit site again (locally, of course), nothing. if hit different domain i'm hosting through vhost declaration, nothing. have wait number of seconds before apache can begin handling traffic again. of time tired , restart server manually.

can explain process me? have php runtime setting 'ignore_user_abort' set true allow ajax calls initiated keep running if close browser, being set false affect it?

any appreciated. didn't know search for. thanks.

ignore_user_abort() allows script (and apache) ignore user disconnecting (closing browser/tab, moving away page, hitting esc, esc..) , continue processing. useful in cases - instance in shopping cart once user hits "yes, place order". don't want order die halfway through process, e.g. order's in database, charge hasn't been sent payment facility yet. or vice-versa.

however, while script busilly running away in "the background", lock resources on server, session file - php locks session file make sure multiple parallel requests won't stomp on file, while infinite loop running in background, won't able use session-enabled other part of site. , if loop intensive enough, tie cpu enough apache unable handle other requests on other hosted sites, session lock might not apply.

if infinite loop, you'll have wait until php's own maximum allowed run time (set_time_limit() , max_execution_time()) kicks in , kills script. there's server-side limiters, apache's rlimitcpu , timeout can handle situations this.

note except on windows, php doesn't count "external" time in set_time_limit. if runaway process doing database stuff, calling external programs via system() , like, time spent running external calls not accounted in parent's time limit.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -