Hi all. I'm looking at some inherited (and old) code for a client after they
have found that a particular image manipulation script that is run on a cron,
is routinely crashing the server. The machine still functions, and responds to
PING. But no http, ssh, ftp or IO seems to respond.
We have narrowed the issue to this one cleanup page that takes a bunch of
images, resizes them, renames them and moves them around. (god knows why the
dev didn't do this on the fly).
But can anyone spot a problem in either of these two functions should they be
run several hundred to 1000 times. (images are usually no more than 500k). The
second function is most likely to be the culprit from what I see in the custom
logs (saveimage is called first, and the blank spot in the last log when it
crashed, this function had finished fine, but failed before fotoflag could do
it's job.
function saveimage($inpath, $newfn)
{
$outpath = "/var/www/vhosts/mydomain/htdocs/photo_large/".$newfn;
$job = "(convert $inpath -resize 800x600 $outpath &) > /dev/null";
$jrslt = system($job, $retval);
$outpath = "/var/www/vhosts/mydomain/htdocs/photo_thumb/".$newfn;
$job = "(convert $inpath -thumbnail 80x60 $outpath &) > /dev/null";
$jrslt = system($job, $retval);
}
function fotoflag($filename)
{
global $conn;
$di = explode('_', $filename);
$vi = explode('-', $di[1]);
$sql = "update vehicle set photo=1 where dealer_id='$di[0]' and
stock='$vi[0]'";
$rslt = mysql_query($sql, $conn) or die(mysql_error());
}
We've been discussing using a local db connection and closing it on that
function, and using mysql_free_resource on the result. But can anyone spot
anything claring in these two examples?
Cheers
Aaron
--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---