thread: Don't acquire lock for thread_cleanup_push/pop
authorMartin Willi <martin@revosec.ch>
Wed, 15 Apr 2015 08:53:27 +0000 (10:53 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 15 Apr 2015 12:38:42 +0000 (14:38 +0200)
This is called only by the thread for its own thread_t, and does not need
synchronization.

src/libstrongswan/threading/thread.c

index 2bf86c1..91a2d34 100644 (file)
@@ -374,9 +374,7 @@ void thread_cleanup_push(thread_cleanup_t cleanup, void *arg)
                .arg = arg,
        );
 
-       this->mutex->lock(this->mutex);
        this->cleanup_handlers->insert_last(this->cleanup_handlers, handler);
-       this->mutex->unlock(this->mutex);
 }
 
 /**
@@ -387,15 +385,12 @@ void thread_cleanup_pop(bool execute)
        private_thread_t *this = (private_thread_t*)thread_current();
        cleanup_handler_t *handler;
 
-       this->mutex->lock(this->mutex);
        if (this->cleanup_handlers->remove_last(this->cleanup_handlers,
                                                                                        (void**)&handler) != SUCCESS)
        {
-               this->mutex->unlock(this->mutex);
                DBG1(DBG_LIB, "!!! THREAD CLEANUP ERROR !!!");
                return;
        }
-       this->mutex->unlock(this->mutex);
 
        if (execute)
        {