]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/cancel.c
Partial revert of f30269f5d2e4bb5ee7486fe6542078d1b59dba6d
[openldap] / servers / slapd / cancel.c
index 6d27d1756a5b32fe4f6ab674bbcf2687838bc738..97e11b95bf04c9e67250cb2c5462511a35356340 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2009 The OpenLDAP Foundation.
+ * Copyright 1998-2012 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -134,9 +134,16 @@ int cancel_extop( Operation *op, SlapReply *rs )
                        }
                }
 
-               while ( (rc = o->o_cancel) == SLAP_CANCEL_REQ ) {
-                       ldap_pvt_thread_yield();
-               }
+               do {
+                       /* Fake a cond_wait with thread_yield, then
+                        * verify the result properly mutex-protected.
+                        */
+                       while ( o->o_cancel == SLAP_CANCEL_REQ )
+                               ldap_pvt_thread_yield();
+                       ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
+                       rc = o->o_cancel;
+                       ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
+               } while ( rc == SLAP_CANCEL_REQ );
 
                if ( rc == SLAP_CANCEL_ACK ) {
                        rc = LDAP_SUCCESS;