]> git.sur5r.net Git - openldap/commitdiff
new ldap_pvt_thread_pool_setkey API
authorPierangelo Masarati <ando@openldap.org>
Sat, 29 Dec 2007 18:14:54 +0000 (18:14 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 29 Dec 2007 18:14:54 +0000 (18:14 +0000)
include/ldap_pvt_thread.h
libraries/libldap_r/tpool.c
servers/slapd/overlays/memberof.c

index 21b2dc69cdf3affcca2b2db47d5ed4404b06c3bc..e8a8b08dbfd777a4f1d029b417816bb9a592c85d 100644 (file)
@@ -268,11 +268,16 @@ ldap_pvt_thread_pool_getkey LDAP_P((
        ldap_pvt_thread_pool_keyfree_t **kfree ));
 
 LDAP_F( int )
-ldap_pvt_thread_pool_setkey LDAP_P((
+ldap_pvt_thread_pool_setkey_x LDAP_P((
        void *ctx,
        void *key,
        void *data,
-       ldap_pvt_thread_pool_keyfree_t *kfree ));
+       ldap_pvt_thread_pool_keyfree_t *kfree,
+       void **olddatap,
+       ldap_pvt_thread_pool_keyfree_t **oldkfreep ));
+
+#define ldap_pvt_thread_pool_setkey( ctx, key, data, kfree ) \
+       ldap_pvt_thread_pool_setkey_x( (ctx), (key), (data), (kfree), NULL, NULL )
 
 LDAP_F( void )
 ldap_pvt_thread_pool_purgekey LDAP_P(( void *key ));
index 81ebd92ed63b5d59a0a393a429298d1ce980cd7f..3b7abee8a7cb9e81cfe46f363dd143582b0d74a3 100644 (file)
@@ -756,11 +756,13 @@ clear_key_idx( ldap_int_thread_userctx_t *ctx, int i )
  *   responsibility to free any existing data with the same key.
  *   kfree() must not call functions taking a tpool argument.
  */
-int ldap_pvt_thread_pool_setkey(
+int ldap_pvt_thread_pool_setkey_x(
        void *xctx,
        void *key,
        void *data,
-       ldap_pvt_thread_pool_keyfree_t *kfree )
+       ldap_pvt_thread_pool_keyfree_t *kfree,
+       void **olddatap,
+       ldap_pvt_thread_pool_keyfree_t **oldkfreep )
 {
        ldap_int_thread_userctx_t *ctx = xctx;
        int i, found;
@@ -776,6 +778,22 @@ int ldap_pvt_thread_pool_setkey(
                }
        }
 
+       if ( olddatap ) {
+               if ( found ) {
+                       *olddatap = ctx->ltu_key[i].ltk_data;
+               } else {
+                       *olddatap = NULL;
+               }
+       }
+
+       if ( oldkfreep ) {
+               if ( found ) {
+                       *oldkfreep = ctx->ltu_key[i].ltk_free;
+               } else {
+                       *oldkfreep = NULL;
+               }
+       }
+
        if ( data || kfree ) {
                if ( i>=MAXKEYS )
                        return ENOMEM;
index 50d018d0dd2cb9197fbad3e115a3f1608c6f284e..0dec9c86ed2396fe3cd2ad37133b4fd0272032cf 100644 (file)
@@ -234,14 +234,11 @@ memberof_saved_member_set( Operation *op, void *keyp, BerVarray vals )
        } else {
                BerVarray       old_vals = NULL;
 
-               ldap_pvt_thread_pool_getkey( op->o_threadctx,
-                               key, (void **)&old_vals, NULL );
+               ldap_pvt_thread_pool_setkey_x( op->o_threadctx, key,
+                               saved_vals, memberof_saved_member_free, &old_vals, NULL );
                if ( old_vals != NULL ) {
                        ber_bvarray_free( old_vals );
                }
-
-               ldap_pvt_thread_pool_setkey( op->o_threadctx, key,
-                               saved_vals, memberof_saved_member_free );
        }
 }