Is there a limit to no. of file handlers a script can use?
Moderator: General Moderators
Is there a limit to no. of file handlers a script can use?
I sometimes have to do large mailouts (to subscribed addresses). I have a system where I build a mailout list from the wesbite administration tool, then send have the web-script call a background script to do the mailout. The background script reports back by writing an XML file which an ajax script from the browser accesses regularly.
The system works well, and has successfully sent throusands of emails for newsletters etc.
the most recent one I ran, something strange happenned. It was a very large list, and while the script did completely send all the emails (as confirmed by grepping the mail log) it stopped rewriting the XML file.
I have a custom error handler that should report any major PHP errors, but received nothing.
It had successfully rewritten the XML file about 2600 times when it stopped working.
After the last email is sent it should also sleep 15 seconds than delete the XML file (giving enough time for the Ajax script to get the last report), however it did not do this either.
I am wondering if there is an upper limit on how many times a PHP script can open a file handler? As I am closing the handler after each write.
Does anyone know about file handlers, and if they have a script limit? If so, I bet the guy who programmed the PHP file handler never thought anyone would ever use that limit!
PS - I do not endorse SPAM! this is for legitimate subscribed mailing lists only.
The system works well, and has successfully sent throusands of emails for newsletters etc.
the most recent one I ran, something strange happenned. It was a very large list, and while the script did completely send all the emails (as confirmed by grepping the mail log) it stopped rewriting the XML file.
I have a custom error handler that should report any major PHP errors, but received nothing.
It had successfully rewritten the XML file about 2600 times when it stopped working.
After the last email is sent it should also sleep 15 seconds than delete the XML file (giving enough time for the Ajax script to get the last report), however it did not do this either.
I am wondering if there is an upper limit on how many times a PHP script can open a file handler? As I am closing the handler after each write.
Does anyone know about file handlers, and if they have a script limit? If so, I bet the guy who programmed the PHP file handler never thought anyone would ever use that limit!
PS - I do not endorse SPAM! this is for legitimate subscribed mailing lists only.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Don't think so
The script completed, all the emails were sent. If there was a memory limit reached the script would have terminated (I think)
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Weirdran - I suspect that could be it!
Operating system limit sounds likely - Either I look into this limit, or change the way the script works. I could leave the one handler open I suppose, however not sure if this is a good idea considering the script runs for hours. Wondering also if apache can access a file that a file handler has open - guess I will just have to find out!
PS - Weirdran - are you a mineralogist or do you just like that image? brings back memories of 2nd year geology.
Thanks for your help
PS - Weirdran - are you a mineralogist or do you just like that image? brings back memories of 2nd year geology.
Thanks for your help
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Are you sure that there is nothing that could cause this line:
to not equal 0?
Edit | I am wondering too if there is a chance that the fopen() call failed? I notice there is not error handling on that. Have you had a look at your server error log?
Code: Select all
if ( ($int_total_sent - (floor( $int_total_sent/REPORT_INTERVAL ) * REPORT_INTERVAL)) == 0 )Edit | I am wondering too if there is a chance that the fopen() call failed? I notice there is not error handling on that. Have you had a look at your server error log?
Other lines also failed.
I should have use the remainder function! so many functions in PHP!
Anyway, even if there is a logic error in that line, that would cause me to never again get that equation to equal zero, I should still have got a report written when the loop was complete, then the unlink lines should also have executed.
PS - Squashed Hedghog? looks more like a Badger to me!
Anyway, even if there is a logic error in that line, that would cause me to never again get that equation to equal zero, I should still have got a report written when the loop was complete, then the unlink lines should also have executed.
PS - Squashed Hedghog? looks more like a Badger to me!
-
nickvd
- DevNet Resident
- Posts: 1027
- Joined: Thu Mar 10, 2005 5:27 pm
- Location: Southern Ontario
- Contact:
While certainly not the cause of your problem, it may be the cause of a server break-in...
SQL INJECTION:
SQL INJECTION:
Code: Select all
$sql .= "INNER JOIN search_results ON search_results.contact_id = ".$config['contact']['table'].".".$config["contact"]["key"]." AND search_id = ".$_GET['search_id'];Script cannot be browser accessed!
I assure you, this script cannot be accessed directly by a browser/HTTP request, it is a background script.
NB - globals are always off and magic quotes turned on
NB - globals are always off and magic quotes turned on