DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=880>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=880
XMLPlatformUtils::Terminate cannot be called more than once.
------- Additional Comments From [EMAIL PROTECTED] 2001-09-26 14:03 -------
The problem with Initializing, Terminating, and re-Initializing actually goes
further than the simple scanner mutex, although it was the first one I found as
well.
Just as stated before, the problem is that these pointers are statically
declared to be 0, and upon request, if still equal to 0, the objects are
created. The objects then get deleted when you call Terminate, but the
pointers do not get set back to 0. So if you re-Initialize and try to use
them, since they are not 0, the code thinks they are already created and tries
to use the destroyed objects.
The solution I found was to add Terminate methods to each of the affected
files, which are called from within the main Terminate method. These Terminate
methods simply point the static pointers back to 0, so that the objects do get
created upon use after re-Initialization. Some of the static variables which
were declared inside their function needed to be moved outside of the function
in order to be accessed by the Terminate method. Other such variables were
already accessible. Most of the affected static pointers are to DOMStrings,
XMLMutexes, and XMLMsgLoaders. There are also some static integers which may
want to be zeroed as well, such as the TotalStringData... counters, which
should reset for a new run of Xerces. Or not, that's just a matter of
preference I suppose.
Here's a list of the files and objects I found which need to be reset to 0 upon
termination:
dom/CDATASectionImpl: DOMString *gcdata_section;
dom/CommentImpl: DOMString *gComment;
dom/DeepNodeListImpl: DOMString *kAstr;
dom/DocumentFragmentImpl: DOMString *nam;
dom/DocumentImpl: DOMString *nam; int kidOK[0-13];
dom/DOM_DOMImplementation: DOM_DOMImplementation *gDomimp; DOMString *gXML,
*gxml, *g1_0, *g2_0, *gTrav;
dom/DOMString: int gLiveStringDataCount, gTotalStringDataCount,
gTotalStringHandleCount (not gLiveStringHandleCount or else
that messes up DOMStringTerminate() getting called)
dom/ElementImpl: DOMString *emptyString;
dom/NamedNodeMapImpl: int gLiveNamedNodeMaps, gTotalNamedNodeMaps
dom/NodeImpl: DOMString *s_xml, *s_xmlURI, *s_xmlns, *s_xmlnsURI;
int gLiveNodeImpls, gTotalNodeImpls
dom/TextImpl: DOMString *gText;
dom/XMLDeclImpl: DOMString *nam;
framework/XMLValidator: XMLMutex* validatorMutex; XMLMsgLoader* gMsgLoader;
internal/XMLScanner: XMLUInt32 gScannerId; XMLMsgLoader* gMsgLoader;
XMLMutex* scannerMutex; bool registered
util/XMLException: XMLMutex* msgMutex; XMLMsgLoader* gLoader
So the point is, beware of the static variables. Const static variables and
those assigned a value at initialization (which presumably don't change) aren't
a problem. But any static variable which is initialized to 0, or initialized
lazily, NEEDS to be reset to 0 when Xerces terminates, if you want to be able
to re-initialize it and use it again later.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]