[Mapserver-dev] MS concurrency problem with vector symbols (partially solved)

Chris G. Nicholas cgn at globexplorer.com
Thu Jun 5 12:51:25 EDT 2003

We are playing with the Java/SWIG interface, and after an adventure in linkage (who designed libwww, anyway?) things seem to work reasonably well. Given a JNI interface, one can configure in multiple Tomcat JK workers as per: http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk/release/v1.2.0/doc/jk/workershowto.html

Chris Nicholas

-----Original Message-----
From:	Mark Cave-Ayland [mailto:m.cave-ayland at webbased.co.uk]
Sent:	Thu 6/5/2003 5:42 AM
To:	woodbri at swoodbridge.com; mapserver-dev at lists.gis.umn.edu
Subject:	RE: [Mapserver-dev] MS concurrency problem with vector symbols (partially solved)
Hi Steve,

> -----Original Message-----
> From: mapserver-dev-admin at lists.gis.umn.edu 
> [mailto:mapserver-dev-admin at lists.gis.umn.edu] On Behalf Of 
> woodbri at swoodbridge.com
> Sent: 04 June 2003 23:28
> To: mapserver-dev at lists.gis.umn.edu; Mark Cave-Ayland
> Subject: Re: [Mapserver-dev] MS concurrency problem with 
> vector symbols
> Mark,
> Mapserver, and therefore Mapscript, are not yet thread-safe. The 
> developers have been making a lot of changes to the source to remedy 
> this, and I don't think it is totally fixed in ms-3.7/4.0, let along 
> 3.6.5.
> You can search the archives for "thread safe" to get more info. By 
> the way, this is also the same reason that PHP must be built as a CGI 
> in Apache and not as a module if you want to use PHP/mapscript.

I don't know whether I am imagining things but I seem to recall that a
number of fixes went into the 3.6 branch a while back to deal with most
of these issues? I've just had a look back over the archives for the
past 6 months as you suggested, and the only outstanding issue I can
find relates to the FreeType library (paths aren't too much of a problem
as we use absolute paths for everything).

Anyway, I've spent several hours chipping away at this one and I've
managed to find where things were going wrong. The problem was that I
was calling setSymbolSet() which is not thread safe because it uses the
parser without locking. To fix the problem I implemented a lock around
msLoadSymbolSet() in mapsymbol.c and also had to change the lexer reset
code a little - please find the patch attached.

I've load tested this with 4000 requests over 10mins and it hasn't
failed once since the patch was applied. However.... This is not a great
fix because it defines a new lock type TLOCK_SUBPARSER to allow the call
to setSymbolSet() to work. Unfortunately this means that there is still
a conflict with TLOCK_PARSER since an entire mapfile could possibly be
lexed at the same time as the setSymbolSet() call is being executed
since the locks are different and I don't think it is possible to set
the same mutex twice without causing all sorts of problems :(.

I think what mapthread.c is missing is a routine msCheckLock(int) which
returns true if a lock has been taken. It would then be easy to modify
the patch so that if TLOCK_PARSER was not already set then it would be
set just for the duration of msLoadSymbolSet(). I've had a look at the
pthread documentation but there was no obvious way to implement this. It
would be great if the guy who wrote the code (Frank Warmerdam) could
suggest a way around this one.....

Many thanks,



Mark Cave-Ayland
Webbased Ltd.
Tamar Science Park

Tel: +44 (0)1752 764445
Fax: +44 (0)1752 764446

This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender. You
should not copy it or use it for any purpose nor disclose or distribute
its contents to any other person.

More information about the mapserver-dev mailing list