]> git.sur5r.net Git - openldap/commitdiff
Update last commit: avoid LDAP_STAILQ_REMOVE in ldap_pvt_thread_pool_retract
authorHallvard Furuseth <hallvard@openldap.org>
Fri, 12 Jun 2009 19:32:53 +0000 (19:32 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Fri, 12 Jun 2009 19:32:53 +0000 (19:32 +0000)
libraries/libldap_r/tpool.c

index 17061a3744e4109f160e42e0066f68c851a1df4e..804bc0df31f87efd902baa19ec3fd33e695cd3f4 100644 (file)
@@ -373,6 +373,12 @@ ldap_pvt_thread_pool_submit (
        return(-1);
 }
 
+static void *
+no_task( void *ctx, void *arg )
+{
+       return NULL;
+}
+
 /* Cancel a pending task that was previously submitted.
  * Return 1 if the task was successfully cancelled, 0 if
  * not found, -1 for invalid parameters
@@ -397,11 +403,11 @@ ldap_pvt_thread_pool_retract (
        LDAP_STAILQ_FOREACH(task, &pool->ltp_pending_list, ltt_next.q)
                if (task->ltt_start_routine == start_routine &&
                        task->ltt_arg == arg) {
-                       pool->ltp_pending_count--;
-                       LDAP_STAILQ_REMOVE(&pool->ltp_pending_list, task,
-                               ldap_int_thread_task_s, ltt_next.q);
-                       LDAP_SLIST_INSERT_HEAD(&pool->ltp_free_list, task,
-                               ltt_next.l);
+                       /* Could LDAP_STAILQ_REMOVE the task, but that
+                        * walks ltp_pending_list again to find it.
+                        */
+                       task->ltt_start_routine = no_task;
+                       task->ltt_arg = NULL;
                        break;
                }
        ldap_pvt_thread_mutex_unlock(&pool->ltp_mutex);