|
Boost : |
From: Christof Meerwald (cmeerw_at_[hidden])
Date: 2002-06-10 10:31:42
Hi,
currently, detail::tss::set doesn't remove the previously registered
cleanup handler if the new value is a NULL pointer. So if you reset
a thread_specific_pointer with a NULL pointer (or release it) and don't
set any other value before the thread terminates, the initial pointer
will be deleted twice (once by thread_specific_pointer::reset and again
by the cleanup handler).
Shouldn't the implementation of tss::set (for Win32) be changed to
something like (completely untested):
bool tss::set(void* value)
{
if (m_cleanup)
{
cleanup_handlers* handlers = get_handlers();
assert(handlers);
if (!handlers)
return false;
if (value)
{
cleanup_info info(m_cleanup, value);
(*handlers)[m_key] = info;
}
else if (TlsGetValue(m_key))
{
handlers->erase(m_key);
}
}
return !!TlsSetValue(m_key, value);
}
bye, Christof
-- http://cmeerw.org JID: cmeerw_at_[hidden] mailto cmeerw at web.de
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk