diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2008-10-01 09:04:58 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2008-10-01 09:04:58 +0000 |
commit | 3b2b8f91ff22b93050b9b1aa3da5bd4359182499 (patch) | |
tree | 3e37aa664496da562640735b168da4dcc08bb737 /sal | |
parent | 257b3205cae2665a96492b806df10faf884a4e99 (diff) |
CWS-TOOLING: integrate CWS sb93
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/thread.c | 47 | ||||
-rw-r--r-- | sal/qa/rtl/bootstrap/rtl_Bootstrap.cxx | 13 | ||||
-rw-r--r-- | sal/rtl/source/bootstrap.cxx | 24 |
3 files changed, 51 insertions, 33 deletions
diff --git a/sal/osl/unx/thread.c b/sal/osl/unx/thread.c index 40b94028a946..20272c5f4a28 100644 --- a/sal/osl/unx/thread.c +++ b/sal/osl/unx/thread.c @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: thread.c,v $ - * $Revision: 1.31 $ + * $Revision: 1.31.48.1 $ * * This file is part of OpenOffice.org. * @@ -67,6 +67,7 @@ #define THREADIMPL_FLAGS_SUSPENDED 0x00004 #define THREADIMPL_FLAGS_ACTIVE 0x00008 #define THREADIMPL_FLAGS_ATTACHED 0x00010 +#define THREADIMPL_FLAGS_DESTROYED 0x00020 typedef struct osl_thread_impl_st { @@ -197,28 +198,30 @@ static void osl_thread_destruct_Impl (Thread_Impl ** ppImpl) /*****************************************************************************/ static void osl_thread_cleanup_Impl (void* pData) { - int active; + pthread_t thread; + int attached; + int destroyed; Thread_Impl* pImpl= (Thread_Impl*)pData; pthread_mutex_lock (&(pImpl->m_Lock)); - if (pImpl->m_Flags & THREADIMPL_FLAGS_ATTACHED) - { - pImpl->m_Flags &= ~THREADIMPL_FLAGS_ATTACHED; - pthread_detach (pImpl->m_hThread); - } - - active = ((pImpl->m_Flags & THREADIMPL_FLAGS_ACTIVE) > 0); - pImpl->m_Flags &= ~THREADIMPL_FLAGS_ACTIVE; + thread = pImpl->m_hThread; + attached = (pImpl->m_Flags & THREADIMPL_FLAGS_ATTACHED) != 0; + destroyed = (pImpl->m_Flags & THREADIMPL_FLAGS_DESTROYED) != 0; + pImpl->m_Flags &= ~(THREADIMPL_FLAGS_ACTIVE | THREADIMPL_FLAGS_ATTACHED); pthread_mutex_unlock (&(pImpl->m_Lock)); - if (!active) + /* release oslThreadIdentifier @@@ see TODO @@@ */ + removeThreadId (thread); + + if (attached) { - /* release oslThreadIdentifier @@@ see TODO @@@ */ - removeThreadId (pImpl->m_hThread); + pthread_detach (thread); + } - /* free memory */ + if (destroyed) + { osl_thread_destruct_Impl (&pImpl); } } @@ -354,7 +357,15 @@ oslThread osl_createSuspendedThread ( void SAL_CALL osl_destroyThread(oslThread Thread) { if (Thread != NULL) { - osl_thread_cleanup_Impl(Thread); + Thread_Impl * impl = (Thread_Impl *) Thread; + int active; + pthread_mutex_lock(&impl->m_Lock); + active = (impl->m_Flags & THREADIMPL_FLAGS_ACTIVE) != 0; + impl->m_Flags |= THREADIMPL_FLAGS_DESTROYED; + pthread_mutex_unlock(&impl->m_Lock); + if (!active) { + osl_thread_destruct_Impl(&impl); + } } } @@ -434,6 +445,7 @@ sal_Bool SAL_CALL osl_isThreadRunning(const oslThread Thread) /*****************************************************************************/ void SAL_CALL osl_joinWithThread(oslThread Thread) { + pthread_t thread; int attached; Thread_Impl* pImpl= (Thread_Impl*)Thread; @@ -449,6 +461,7 @@ void SAL_CALL osl_joinWithThread(oslThread Thread) return; /* EDEADLK */ } + thread = pImpl->m_hThread; attached = ((pImpl->m_Flags & THREADIMPL_FLAGS_ATTACHED) > 0); pImpl->m_Flags &= ~THREADIMPL_FLAGS_ATTACHED; @@ -458,10 +471,10 @@ void SAL_CALL osl_joinWithThread(oslThread Thread) { /* install cleanup handler to ensure consistent flags and state */ pthread_cleanup_push ( - osl_thread_join_cleanup_Impl, (void*)(pImpl->m_hThread)); + osl_thread_join_cleanup_Impl, (void*)thread); /* join */ - pthread_join (pImpl->m_hThread, NULL); + pthread_join (thread, NULL); /* remove cleanup handler */ pthread_cleanup_pop (0); diff --git a/sal/qa/rtl/bootstrap/rtl_Bootstrap.cxx b/sal/qa/rtl/bootstrap/rtl_Bootstrap.cxx index 1e791ba2eaf1..85efcfa55b34 100644 --- a/sal/qa/rtl/bootstrap/rtl_Bootstrap.cxx +++ b/sal/qa/rtl/bootstrap/rtl_Bootstrap.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: rtl_Bootstrap.cxx,v $ - * $Revision: 1.11 $ + * $Revision: 1.10.20.2 $ * * This file is part of OpenOffice.org. * @@ -785,6 +785,16 @@ namespace rtl_Bootstrap t2.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("src680_test"))); } + void testNonexisting() { + rtl::OUString t( + RTL_CONSTASCII_USTRINGPARAM( + "${$ORIGIN/" SAL_CONFIGFILE("none") ":MYVAR}")); + Bootstrap::expandMacros(t); + CPPUNIT_ASSERT_MESSAGE( + "nonexisting", + t.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("src680_test"))); + } + void testSection() { rtl::OUStringBuffer b; b.appendAscii(RTL_CONSTASCII_STRINGPARAM("${")); @@ -817,6 +827,7 @@ namespace rtl_Bootstrap CPPUNIT_TEST(testRecursion); CPPUNIT_TEST(testLink); CPPUNIT_TEST(testOverride); + CPPUNIT_TEST(testNonexisting); CPPUNIT_TEST(testSection); CPPUNIT_TEST_SUITE_END(); }; // class expandMacrosFrom diff --git a/sal/rtl/source/bootstrap.cxx b/sal/rtl/source/bootstrap.cxx index 004ddb60a9ed..d73b704cca60 100644 --- a/sal/rtl/source/bootstrap.cxx +++ b/sal/rtl/source/bootstrap.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: bootstrap.cxx,v $ - * $Revision: 1.44 $ + * $Revision: 1.43.20.1 $ * * This file is part of OpenOffice.org. * @@ -891,9 +891,9 @@ rtl::OUString lookup( Bootstrap_Impl const * file, bool override, rtl::OUString const & key, ExpandRequestLink const * requestStack) { - OSL_ASSERT(file != NULL); rtl::OUString v; - file->getValue(key, &v.pData, NULL, override, requestStack); + (file == NULL ? get_static_bootstrap_handle() : file)->getValue( + key, &v.pData, NULL, override, requestStack); return v; } @@ -979,14 +979,11 @@ rtl::OUString expandMacros( } catch (rtl::MalformedUriException &) {} } } else { - rtl::Bootstrap b(seg[0]); - Bootstrap_Impl * f = static_cast< Bootstrap_Impl * >( - b.getHandle()); - // Silently ignore bootstrap files that cannot be opened - // (is that good?): - if (f != NULL) { - buf.append(lookup(f, false, seg[1], requestStack)); - } + buf.append( + lookup( + static_cast< Bootstrap_Impl * >( + rtl::Bootstrap(seg[0]).getHandle()), + false, seg[1], requestStack)); } } else if (seg[0].equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".override"))) @@ -994,10 +991,7 @@ rtl::OUString expandMacros( rtl::Bootstrap b(seg[1]); Bootstrap_Impl * f = static_cast< Bootstrap_Impl * >( b.getHandle()); - buf.append( - lookup( - f == NULL ? get_static_bootstrap_handle() : f, - f != NULL, seg[2], requestStack)); + buf.append(lookup(f, f != NULL, seg[2], requestStack)); } else { // Going through osl::Profile, this code erroneously does // not recursively expand macros in the resulting |