summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/Thread.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2018-07-25 17:57:13 +0200
committerJose <jose@zeroc.com>2018-07-26 11:56:31 +0200
commit88f0cefa03c60c3c2f9c722aeebe3fb2905f2700 (patch)
tree10768e40d9207fe5069f76a7c1db85dde38ea02a /cpp/src/Ice/Thread.cpp
parentDo not sort generated functions alphabetical (diff)
downloadice-88f0cefa03c60c3c2f9c722aeebe3fb2905f2700.tar.bz2
ice-88f0cefa03c60c3c2f9c722aeebe3fb2905f2700.tar.xz
ice-88f0cefa03c60c3c2f9c722aeebe3fb2905f2700.zip
Missing __decRef call in Thread::start
Diffstat (limited to 'cpp/src/Ice/Thread.cpp')
-rw-r--r--cpp/src/Ice/Thread.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/cpp/src/Ice/Thread.cpp b/cpp/src/Ice/Thread.cpp
index 410b05afde8..dc10ed825e2 100644
--- a/cpp/src/Ice/Thread.cpp
+++ b/cpp/src/Ice/Thread.cpp
@@ -205,16 +205,24 @@ IceUtil::Thread::start(size_t, int)
}
//
- // It's necessary to increment the reference count since
- // pthread_create won't necessarily call the thread function until
+ // It's necessary to increment the reference count since the
+ // thread constructor won't necessarily call the thread function until
// later. If the user does (new MyThread)->start() then the thread
// object could be deleted before the thread object takes
// ownership. It's also necessary to increment the reference count
- // prior to calling pthread_create since the thread itself calls
- // __decRef().
+ // prior to calling the thread constructor since the thread start hook
+ // itself calls __decRef().
//
- __incRef();
- _thread.reset(new thread(startHook, this));
+ try
+ {
+ __incRef();
+ _thread.reset(new thread(startHook, this));
+ }
+ catch(const std::system_error&)
+ {
+ __decRef();
+ throw;
+ }
_started = true;
_running = true;
@@ -467,6 +475,7 @@ IceUtil::Thread::start(size_t stackSize, int priority)
}
if(SetThreadPriority(_handle, priority) == 0)
{
+ __decRef();
throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
if(static_cast<int>(ResumeThread(_handle)) == -1)