Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP infinite loop prevents access to other scripts?

While running an infinite loop in PHP on Apache, others pages/scripts would hang (take forever to load) until I break execution of the script. However, other pages would still execute on a different user session or browser. Can this be resolved?

like image 258
B00T3D Avatar asked Dec 24 '12 13:12

B00T3D


1 Answers

This is a race condition problem.

Once you session_start() a session, a file attached to the session id is opened with restrictive permissions (locked for reading and writing). If another session_start() is called, it will wait for the session file to be unlocked, to avoid the second script to modify asynchronously the session.

Have a look to this article which explain better than me what's happen.

like image 99
Alain Tiemblo Avatar answered Sep 28 '22 17:09

Alain Tiemblo