From: helge Date: Wed, 14 Sep 2005 10:28:39 +0000 (+0000) Subject: fixed some edge condition X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a9ce471f6536df23a78daa0b444a24aaf45c0f4;p=sope fixed some edge condition git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1104 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-xml/libxmlSAXDriver/ChangeLog b/sope-xml/libxmlSAXDriver/ChangeLog index 05ee7eed..eb830b38 100644 --- a/sope-xml/libxmlSAXDriver/ChangeLog +++ b/sope-xml/libxmlSAXDriver/ChangeLog @@ -1,3 +1,8 @@ +2005-09-14 Helge Hess + + * libxmlSAXDriver.m: improved 'activeDriver' handling in some edge + condition (v4.5.22) + 2005-08-16 Helge Hess * install into SaxObjC framework Resources when being used with OSX diff --git a/sope-xml/libxmlSAXDriver/Version b/sope-xml/libxmlSAXDriver/Version index 8f54e04e..b0de02fb 100644 --- a/sope-xml/libxmlSAXDriver/Version +++ b/sope-xml/libxmlSAXDriver/Version @@ -1,3 +1,3 @@ # version -SUBMINOR_VERSION:=21 +SUBMINOR_VERSION:=22 diff --git a/sope-xml/libxmlSAXDriver/libxmlSAXDriver.m b/sope-xml/libxmlSAXDriver/libxmlSAXDriver.m index 900f299d..17b1dfca 100644 --- a/sope-xml/libxmlSAXDriver/libxmlSAXDriver.m +++ b/sope-xml/libxmlSAXDriver/libxmlSAXDriver.m @@ -82,7 +82,22 @@ extern xmlParserCtxtPtr xmlCreateMemoryParserCtxt(char *buffer, int size); @implementation libxmlSAXDriver -static libxmlSAXDriver *activeDriver = nil; +static libxmlSAXDriver *activeDriver = nil; // THREAD + +#define SETUP_ACTDRIVER \ + { if (activeDriver != nil) { \ + NSLog(@"ERROR(%s): %@ there is an active driver set (0x%08X), " \ + @"override!", \ + __PRETTY_FUNCTION__, self, activeDriver);\ + }\ + activeDriver = self;} + +#define TEARDOWN_ACTDRIVER \ + { if (activeDriver == self) activeDriver = nil; \ + else if (activeDriver != nil) { \ + NSLog(@"ERROR(%s): %@ activeDriver global var mixed up 0x%08X, " \ + @"probably a THREAD issue.", \ + __PRETTY_FUNCTION__, self, activeDriver); } } static void _startElement(libxmlSAXDriver *self, const xmlChar *name, const xmlChar **atts); @@ -444,11 +459,7 @@ static xmlSAXHandler saxHandler = { } } - if (activeDriver != nil) { - NSLog(@"ERROR(%s): %@ there is an active driver set (%@), override !", - __PRETTY_FUNCTION__, self, activeDriver); - } - activeDriver = self; + SETUP_ACTDRIVER; self->ctxt = xmlCreateMemoryParserCtxt((void *)start, len); @@ -458,14 +469,14 @@ static xmlSAXHandler saxHandler = { NSLog(@"%s: couldn't create memory parser ctx (src=0x%08X, len=%d) !", __PRETTY_FUNCTION__, src, len); - - if (activeDriver == self) - activeDriver = nil; + + TEARDOWN_ACTDRIVER; ui = nil; - e = (id)[SaxParseException exceptionWithName:@"SaxIOException" - reason:@"couldn't create memory parser context" - userInfo:ui]; + e = (id)[SaxParseException + exceptionWithName:@"SaxIOException" + reason:@"couldn't create memory parser context" + userInfo:ui]; [self->errorHandler fatalError:e]; return; @@ -493,11 +504,10 @@ static xmlSAXHandler saxHandler = { ((xmlParserCtxtPtr)self->ctxt)->sax = oldsax; ((xmlParserCtxtPtr)self->ctxt)->userData = NULL; xmlFreeParserCtxt(ctxt); - - if (activeDriver == self) - activeDriver = nil; - - if (src) { + + TEARDOWN_ACTDRIVER; + + if (src != NULL) { free(src); src = NULL; } @@ -593,16 +603,11 @@ static int mfclose(void *f) { [_sysId cString]; } - if (activeDriver != nil) { - NSLog(@"WARNING(%s): %@ there is an active driver set (%@), override !", - __PRETTY_FUNCTION__, self, activeDriver); - } - activeDriver = self; + SETUP_ACTDRIVER; xmlParseDocument(self->ctxt); - if (activeDriver == self) - activeDriver = nil; + TEARDOWN_ACTDRIVER; if (((xmlParserCtxtPtr)self->ctxt)->input != NULL && [_sysId length] > 0) { ((xmlParserInputPtr)((xmlParserCtxtPtr)self->ctxt)->input)->filename =