summaryrefslogtreecommitdiff
path: root/src/libstrongswan/threading/thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/threading/thread.c')
-rw-r--r--src/libstrongswan/threading/thread.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/libstrongswan/threading/thread.c b/src/libstrongswan/threading/thread.c
index d6d98d1ef..eb167d6a4 100644
--- a/src/libstrongswan/threading/thread.c
+++ b/src/libstrongswan/threading/thread.c
@@ -341,7 +341,20 @@ thread_t *thread_create(thread_main_t main, void *arg)
*/
thread_t *thread_current()
{
- return current_thread->get(current_thread);
+ private_thread_t *this;
+
+ this = (private_thread_t*)current_thread->get(current_thread);
+ if (!this)
+ {
+ this = thread_create_internal();
+
+ id_mutex->lock(id_mutex);
+ this->id = next_id++;
+ id_mutex->unlock(id_mutex);
+
+ current_thread->set(current_thread, (void*)this);
+ }
+ return &this->public;
}
/**