Multiple instances of a script running simultaneously in PHP? -


using error log in php debug code came across following situation looks if 2 instances of same script running in parallel. i'm sceptic that, i'm requesting support me figure out going on.edit: following occurs in development server serves single user.

code

following extract of code running in index.php script (which have simplified since it's longer). key i'm initiating session , redirecting. lines strarting /**/ lines added add data error log:

session_start(); if(!isset($_session['check']))      //session initialization code { /*1*/static $thread = 0; /*2*/error_log("\ninit block - run: " . $thread++); /*3*/error_log("\ninto init block - uri: " . $_server['request_uri'] . "time: " . microtime());  $_session['check'] = true; /*4*/error_log("\ninit block - run: " . $thread++);     /*execution of second script instance seems start @ point*/  $_session['var1'] = /*var1 initialization code*/; /*5*/error_log("\ninit block - run: " . $thread);  $_session['var2'] = /*var 2 initialization code*/; /*6*/error_log("\ninit block - run: " . $thread);  $_session['var3'] = /*var3 initialization code*/; /*7*/error_log("\ninit block - run: " . $thread);  $_session['var4'] = /*var4 intialization code*/ /*8*/error_log("\ninit block - run: " . $thread);  $_session['var5'] = /*var5 initialization code*/ /*9*/error_log("\ninit block - run: " . $thread++); }  if(/*condition1*/) { /*10*/static $filter = 0; /*11*/error_log("\ninto condition 1 - uri: " . $_server['request_uri'] . "time: " . microtime()); /*12*/error_log("\ncondition 1 - run: " . $filter);  header("location: " . $targeturl . $resultpage);    //post->redirect->get exit(); } else { /*...*/ } 

error log output

the output in error log follows: i'm appending code line generated output make less cumbersome read, hopefully:

[05-apr-2017 19:17:25]  init block - run: 0     /*2*/  [05-apr-2017 19:17:25]  init block - uri: / time: 0.59423800 1491430645 /*3*/  [05-apr-2017 19:17:25]  init block - run: 1     /*4*/  [05-apr-2017 19:17:25]  init block - run: 0     /*2*/  [05-apr-2017 19:17:25]  init block - uri: / time: 0.70579800 1491430645 /*3*/  [05-apr-2017 19:17:25] /*4*/ init block - run: 1  [05-apr-2017 19:17:28]  init block - run: 2     /*5*/  [05-apr-2017 19:17:28]  init block - run: 2     /*6*/  [05-apr-2017 19:17:28]  init block - run: 2     /*7*/  [05-apr-2017 19:17:28]  init block - run: 2     /*8*/  [05-apr-2017 19:17:28]  init block - run: 2     /*9*/  [05-apr-2017 19:17:28]  condition 1 - uri: / time: 0.94149400 1491430648   /*11*/  [05-apr-2017 19:17:28]  condition 1 - run: 0    /*12*/  [05-apr-2017 19:17:28]  init block - run: 2     /*5*/  [05-apr-2017 19:17:28]  init block - run: 2     /*6*/  [05-apr-2017 19:17:29]  init block - run: 2     /*7*/  [05-apr-2017 19:17:29]  init block - run: 2     /*8*/  [05-apr-2017 19:17:29]  init block - run: 2     /*9*/  [05-apr-2017 19:17:29]  condition 1 - uri: / time: 0.09837300 1491430649   /*11*/ 

as can see, code executes until line /*4*/, when seems interrupted new instance of script, , resumes after new instance ends execution. suspicious header function call, flow gets disrupted way before point. in trying find answer saw logging can duplicated depending on apache's settings, can see, not case of double logging. appreciated!


Comments