Boris Kolpackov wrote:
David Bertoni <[EMAIL PROTECTED]> writes:
The use in TransService.cpp doesn't make much sense to me. The transcoding
service is created through XMLPlatformUtils::Initialize(), and we've never
claimed that's thread-safe.
Good point. This class uses things like memory manager so it probably
cannot be created before Initialize().
Unfortunately, double-checked locking is everywhere in Xerces-C
I just did a quick grep and you are right, there are many instances
of this. This sucks big time. Not sure if it even makes sense to
release 3.0.0 until we clean this up.
Well, there is a workaround, which I helped implement. You can pass true
as the last parameter for XMLPlatformUtils::Initialize(), and all static
initialization is done during Initialize(), rather than relying on
double-checking locking and lazy initialization.
Is it possible we can do static initialization of XMLTransService through
the regular static initialization process?
We can as long as the initialization process does not rely on things
that are initialized by PlatformUtils::Initialize(). We can also use
fgAtomicMutex in this case since there is only one TransService
instance created so performance is not that important.
If that's the case, then it's already broken, since it's created during
XMLPlatformUtils::Initialize():
//
// Ask the per-platform code to make the desired transcoding service for
// us to use. This call cannot throw any exceptions or do anything that
// cause any transcoding to happen. It should create the service and
// return it or zero if it cannot.
//
// This one also cannot use any utility services. It can only create a
// transcoding service object and return it.
//
// If we cannot make one, then we call panic to end the process.
//
fgTransService = makeTransService();
if (!fgTransService)
panic(PanicHandler::Panic_NoTransService);
// Initialize the transcoder service
fgTransService->initTransService();
We should try to do the same with BinHTTPURLInputSource.
Can't do that; it creates a mutex for which you need Initialize().
Actually, I meant we should figure out a way to call
BinHTTPURLInputSource::Initialize() during XMLPlatformUtils:::Initialize().
Perhaps doing it through XMLPlatformUtils::makeNetAccessor() would work,
since that's already a part of the static initialization process.
Note that the destructor for WinSockNetAccessor already does static cleanup
for BinHTTPURLInputStream:
WinSockNetAccessor::~WinSockNetAccessor()
{
// Cleanup code for the WinSock library here.
BinHTTPURLInputStream::Cleanup();
}
why not just add the corresponding Initialize() call to the constructor?
WinSockNetAccessor::WinSockNetAccessor()
{
BinHTTPURLInputStream::Initialize();
}
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]