Opened 19 years ago

Closed 19 years ago

Last modified 19 years ago

#1299 closed defect (fixed)

Random images produced by PHP Mapscript's processTemplate()

Reported by: dmorissette Owned by: mapserverbugs
Priority: high Milestone:
Component: MapScript-PHP Version: 4.5
Severity: normal Keywords:
Cc: mbasa@…

Description

Mario Basa reported the following in bug 67. However I am creating a new bug
since his problem is with PHP MapScript's processTemplate() method ib CGI mode
and bug 67 is about the use of the saveWebImage() method in PHP DSO mode... two
different problems.

------- Additional Comment #11 From Mario Basa  2005-03-24 02:37 -------

Daniel, we are continously experiencing the same thing with a 4.4.1 CGI
php-mapscript application. This happens when requests are submitted
simoultaneously to process a map with huge datasets. It seems that php have to
finish completely a process before  starting a new one.

I thought at first that mapscript is not creating unique filenames, so I added a
4 digit random numbember in maptemplate.c (i.e. sprintf(msObj->Id,
"%ld-%04d",(long)time(NULL),j);) but that didn't work since we are still
experiencing the problem.


------- Additional Comment #12 From Daniel Morissette 2005-03-26 18:54 -------

Mario, does this happen on Windows or Linux? If Windows, then which version is
it? With Apache or IIS?
Are you 100% sure that your PHP is really configured as a CGI? I can't see how
two CGI processes could end up overwriting each other's files or reusing the
same filename... unless all processes end up with the same PID which would be
really odd. 
If you generate simultaneous requests, are you able to capture the image URLs
and compare them to see if they are identical or not?
Finally, is this map drawn out of shapefiles? If not then where does the data
come from. 
I also assume that the output is a GIF or PNG image? If not then what's your
output format?


------- Additional Comment #13 From Mario Basa 2005-03-27 09:08 -------

Daniel, I think the problem is in the processtemplate() function. I re-wrote our
php application so as not to use this function, and the problem stopped so far.
This might be a memory allocation problem, wherein one process is getting
variables allocated by another process which was started simoultaneously. I can
send an apache log file wherein you can see a temporay image file is requested
as much as 5 times (which should never happen).

Our environment is all linux (fc1,fc3,rhel3), and the php-mapscript is compiled
as a CGI. It was compiled both with and afterwards without threads, but it did
not make any difference. The data sets we are using are both shapfiles and
postgis layers. The data is a bit heavy, very simillar to Assefa's goSVG sample
data. Also, the output format is always PNG. In our case, just a few minutes of
simoultaneous panning by 2 to 3 clients, and a map will be dumped where it
shouldn't be. I also tested with 4.5, but the errors were still there. Please,
just ask if you need any more info.

Change History (5)

comment:1 by dmorissette, 19 years ago

Cc: mbasa@… added
Status: newassigned
Looking at the code, I see that msProcessTemplate() only uses the timestamp and
doesn't use the PID to generate a unique filename: 

       sprintf(msObj->Id, "%ld",(long)time(NULL)); 

This is very likely the source of Mario's problem. I'll fix msProcessTemplate()
now to use the PID as well. Actually, I see 4 places in the code that set this
msObj->Id... I'll move the initialization of this member in msAllocMapServObj().

comment:2 by dmorissette, 19 years ago

Mario, I have committed a fix for this in 4.5 (dev) in CVS. Can you please test
it and let me know if that fixes your issue. If that works then I'll backport to
MapServer 4.4.

comment:3 by mbasa@…, 19 years ago

Daniel, this fixed it. We were banging on our server for over an hour with 3
clients and the error didn't appear.

comment:4 by dmorissette, 19 years ago

Cool. Backporting the fix to 4.4 now.

comment:5 by dmorissette, 19 years ago

Resolution: fixed
Status: assignedclosed
Done. The fix has been backported to the 4.4 CVS, will be in 4.4.2
Note: See TracTickets for help on using tickets.