hi Stephan,
On 23/02/12 10:48, Stephan Bergmann wrote:
> +void salhelper::Thread::launch() {
> + SAL_INFO("salhelper.thread", "launch " << name_);
> + // Assumption is that osl::Thread::create returns normally iff it causes
> + // osl::Thread::run to start executing:
looks like this assumption which you moved there is actually wrong
> + acquire();
> + try {
> + create();
> + } catch (...) {
> + release();
> + throw;
> + }
> sal_Bool SAL_CALL create()
> {
> assert(m_hThread == 0); // only one running thread per instance
> if (m_hThread)
> return sal_False;
>
> m_hThread = osl_createSuspendedThread( threadFunc, (void*)this);
> if ( m_hThread )
> osl_resumeThread(m_hThread);
>
> return m_hThread != 0;
> }
doesn't look like anything throws here, given those are C functions...
how about the attached patch?
>From cf22e569d485d050a535b3e598d7e255aed98597 Mon Sep 17 00:00:00 2001
From: Michael Stahl <[email protected]>
Date: Thu, 23 Feb 2012 14:53:56 +0100
Subject: [PATCH] salhelper::Thread::launch: check create() failure
The assumption in the comment is clearly wrong, as osl::Thread::create
returns a boolean result to indicate failure.
---
salhelper/source/thread.cxx | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/salhelper/source/thread.cxx b/salhelper/source/thread.cxx
index bf7c1f1..d1644be 100644
--- a/salhelper/source/thread.cxx
+++ b/salhelper/source/thread.cxx
@@ -32,15 +32,20 @@
#include "sal/log.hxx"
#include "salhelper/thread.hxx"
+#include <stdexcept>
+
+
salhelper::Thread::Thread(char const * name): name_(name) {}
void salhelper::Thread::launch() {
SAL_INFO("salhelper.thread", "launch " << name_);
- // Assumption is that osl::Thread::create returns normally iff it causes
- // osl::Thread::run to start executing:
acquire();
try {
- create();
+ bool const bSuccess = create();
+ if (!bSuccess) {
+ // cannot throw css::uno::RuntimeException (udkapi not available)
+ throw ::std::runtime_error("osl::Thread::create() failed");
+ }
} catch (...) {
release();
throw;
--
1.7.7.6
_______________________________________________
LibreOffice mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice