[OpenLayers-Dev] Race condition in WMSGetFeatureInfo

Gael Lafond G.Lafond at aims.gov.au
Thu Dec 9 18:24:11 EST 2010


Hello,

I use the WMSGetFeatureInfo object with multiple layers from 2 distinct
servers, with the DrillDown option.

The class has to send 2 requests. Since both servers are internals, the
answers come back very fast and the method handleResponse is call at the
exact same time for both servers (lets say with very few CPU cycles
difference). The problem is actually in the concat call of the
handleResponse method:
[...]
this._features = (this._features || []).concat(features);
[...]
I suspect this line to takes multiple CPU cycles, enough to actually
having it call at the same time for both requests. This result in having
both getting the content of this._features when it is actually empty,
and, at the end, the second request override what the first one has set
into it.

I can (kind of) prouve this by adding an alert just before the suspected
line. When I do so, I get 2 alerts at the same time (I though it was
impossible to have 2 alert windows at the same time), pausing both
process. Everything goes fine after I close those windows.

In java, I would propose to add the Synchronize keyword to the
handleResponse method, but this keyword do not seems to exists in
javascript. Implementing a mutex (or even a semaphore) is almost
impossible without been able to use the CPU call that check and set a
boolean in one operation. (the only solution I know is to use an array
of boolean, one for each process... I will not describe this here)

In my case, I have to place each response in a different Div so I have
to override this method anyway. That will solve my problem, but they
will still have a race condition in that method.

-- 
Gael Lafond
Programmer
Australian Institute of Marine Science (AIMS)
PMB 3
Townsville MC
QLD 4810
Ph: +61 7 4753 4207
E-Mail: g.lafond at aims.gov.au


--  
------------------------------------------------------------------------
The information contained within this transmission is for the
use of the intended recipient only and may contain confidential
and/or legally privileged material and/or material the subject
of copyright and/or personal information and/or sensitive
information that is subject to the Privacy Act 1988. Any review,
re-transmission, disclosure, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited. If you have received this email in error please
notify the AIMS Privacy Officer on (07) 4753 4444 and delete
all copies of this transmission together with any attachments.
------------------------------------------------------------------------


More information about the Dev mailing list