Let me tell what I'm TRYING to do so you can see the whole picture. Hopefully something postive comes of this which I'll be glad to post in advanced tips somewhere. This post is longer than most of mine, but I think you'll find it readable.
I have a script which loops through a set of IP Class C addresses (usually 64 at a time), say 216.166.64.x, ..65.x, ..66.x, etc. - and for each of these Class C addresses loops through all 256 Class D values. More simply, you have a 256-loop in a 64-loop (so 64x256)
For each individual IP address it does a dig -x $ip call to the system, gets data back into an array, and writes domain names to a database to build a domain table.
Here's the part I thought would be pretty smart but which doesn't work. Initially before the loops start, i set:
$_SESSION['settings'][$sjid]=true;
//where $sjid is the scan job number for this batch of IPs
This tells session that the loop is running and active.
Now, at the begnning of each loop code I do the following check:
if($_SESSION['settings'][$sjid]==false){
//would have been set false by another "kill" page
?><script>
alert('Process terminated');
</script><?php
exit;
}
The thought was this: First, I have found that this loop keeps running even when the browser window is closed (which I actually want). I need some way to control the process. So, the process sets this session variable as true at first. If another page sets that variable as false, then the process would see it, stop itself and voila, you'd have an independent method to kill a process.
But when I call the "kill page" with the simple code below:
session_start();
$_SESSION['settings'][$sjid]=false;
exit;
the server doesn't open it, instead the browser hangs (while the process page is running).
The problem seems to be some type of locking. While the loop is running, I can't call the above page, because the server acts busy - very strange.
This is NOT a overly busy server, I've checked. After some trouble shooting I found:
1. I can call any and all pages on other domains on my server while the loop is going
2. I can even call the above "kill" page, on another domain on my server
3. I can call the above code if I set the session to another session id
The conflict comes when trying to call the kill page with THAT CODE, on that domain, with the same session (which of course, is what I want and all I'm asking for! :-)
I've not had very good success on complex files like this where you're looping a long process that includes database (mysql) read/writes and file read/writes. I really want some way to control these processes.
It seems like the loop page is locking access to the session file, since I just can't do any page that tries session_start() for that same session file. Any thoughts?
MANY MANY THANKS,
Samuel