]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/cancel.c
More for 907b9d487753631371dd969b551b63c41cef30fd
[openldap] / servers / slapd / cancel.c
index 6d27d1756a5b32fe4f6ab674bbcf2687838bc738..ac0d3250825509944a0145cff797f4c4766be213 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-2013 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;