I've been in discussions outside the list about this, these are my thoughts
on a possible solution - any comments welcome.

Thanks,

Mark

-----Original Message-----
From: Mark Weaver [mailto:[EMAIL PROTECTED]]
Sent: 06 September 2001 14:00
To: [EMAIL PROTECTED]
Subject: RE: Problem initializing and terminating XMLPlatformUtils


Hi,

I've made a partial fix that suited my needs that notifies classes that
lazy data has been cleaned up, it's a little inelegant though (you need to
manually maintain a list of classes to call).  My preferred method would
be to have something like this (sorry about the code, it's just a quick
sketch):

class XMLRegisterCleanup;
extern XMLRegisterCleanup* gXMLCleanupList;

class XMLRegisterCleanup
{
public:
        typedef void (*XMLCleanupFn)();

        XMLRegisterCleanup* next() { return m_nextCleanup; }
        void doCleanup() {
                if (m_cleanupFn) m_cleanupFn();
        }

private:
        XMLRegisterCleanup(XMLCleanupFn cleanupFn) :
                m_cleanupFn(cleanupFn)
        {
                m_nextCleanup = gXMLCleanupList;
                gXMLCleanupList = this;
        }

        XMLCleanupFn m_cleanupFn;
        XMLRegisterCleanup* m_nextCleanup;
};

then, in each module you do:

void myCleanupFunction()
{
        /* free/reset data */
}

/* register my cleanup */
static XMLRegisterCleanup gCleaner(myCleanupFunction);

and finally, in PlatformUtils::Terminate you have:

XMLRegisterCleanup* currCleanup = gXMLCleanupList;
while (currCleanup) {
        currCleanup->clean();
        currCleanup = currCleanup->next();
}

This should simplify the process of implementing new cleanups.

I am happy to implement this, if this is deemed to be the right method, or
to use some other method if pointed in the right direction.  If I read you
correctly, I should also remove the use of XMLDeleterFor<> on these kinds
of objects (e.g. the lazily created mutexes) - I guess this would be
neater than having the object deleted in a location which wasn't the
cleanup function!

Now I have a few questions:

1) How do you subscribe to the mailing list? I've tried sending mail to
the help address & subscribe but I don't seem to be getting any response
2) Who do I submit the patches too, when completed?

Thanks,

Mark

> -----Original Message-----
> From: Erik Schroeder [mailto:[EMAIL PROTECTED]]
> Sent: 06 September 2001 13:20
> To: '[EMAIL PROTECTED]'
> Subject: FW: Problem initializing and terminating XMLPlatformUtils
>
>
> LOL!
> It's a small world... Mark, you may wish to check this message out...
>
> -----Original Message-----
> From: Jesse Pelton [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 06, 2001 7:14 AM
> To: '[EMAIL PROTECTED]'
> Subject: RE: Problem initializing and terminating XMLPlatformUtils
>
>
> It doesn't fix all cases. Take a look at gScannerMutex() in
> src/internal/XMLScanner.cpp: it allocates some memory, for which it
> registers and XMLDeleterFor, but it also sets a flag indicating that the
> memory was registered. There's no mechanism for resetting the flag, so
the
> flag is set wrong once the memory gets released.
>
> Rather than registering XMLDeleterFor objects, I think we need to
register
> static cleanup functions. It's a more general mechanism; such
> functions can
> undo *any* changes to global data, whether it's releasing memory (and
> setting corresponding pointers to null), setting or clearing flags, or
> something else. I got a favorable response when I proposed the idea, but
I
> haven't found the time in the last year (!) to implement it. See the
> http://marc.theaimsgroup.com/?l=xerces-c-dev&m=86952115511528&w=2 for
> details. I think the problem is worth solving, if only to avoid
> the constant
> stream of messages on the topic.
>
> Here's what I'd propose:
>
> 1) Find out if anyone wants to give this approach a shot.
> 2) If so, call for a vote on the idea.
> 3) Implementer gives it a go. I'd be happy to consult, though I'm way
> down-level, so I may not be much use on specifics.
> 4) If it works out, commit it.
>
> This all assumes that nobody has a better idea. So far, I don't think
I've
> seen one.
>
> -jesse-
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 06, 2001 12:20 AM
> To: [EMAIL PROTECTED]
> Subject: Problem initializing and terminating XMLPlatformUtils
>
>
> I have a need to initialize and terminate the utilities multiple
> time for a
> single process.
>
> For each lazily initialized data (or Singleton) we register an object
that
> will perfom its cleanup (XMLDeleterFor<type>).  It seems to me that if
we
> modified the XMLDeleterFor<type> to not only delete the pointer
> but also set
> it to NULL this problem goes away.
>
> Is there a problem with doing this?
>
> Thanks,
>
> -Chris.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to