]> git.sur5r.net Git - openldap/commitdiff
release entry, if required; release mapping resources as appropriate on exit
authorPierangelo Masarati <ando@openldap.org>
Thu, 3 Nov 2005 13:34:43 +0000 (13:34 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 3 Nov 2005 13:34:43 +0000 (13:34 +0000)
servers/slapd/overlays/rwm.c
servers/slapd/overlays/rwm.h
servers/slapd/overlays/rwmconf.c
servers/slapd/overlays/rwmmap.c

index 6246cc68a6919d1885e6df0506bcab5173398cd0..42bf3f8c1e2dc99d219edc1c67ddbcfd37d961af 100644 (file)
@@ -1043,6 +1043,7 @@ rwm_send_entry( Operation *op, SlapReply *rs )
                        goto fail;
                }
 
+               flags &= ~REP_ENTRY_MUSTRELEASE;
                flags |= ( REP_ENTRY_MODIFIABLE | REP_ENTRY_MUSTBEFREED );
        }
 
@@ -1075,11 +1076,9 @@ rwm_send_entry( Operation *op, SlapReply *rs )
         * to return, and remap them accordingly */
        (void)rwm_attrs( op, rs, &e->e_attrs, 1 );
 
-#if 0
-       if ( rs->sr_operational_attrs ) {
-               (void)rwm_attrs( op, rs, &rs->sr_operational_attrs, 0 );
+       if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
+               be_entry_release_rw( op, rs->sr_entry, 0 );
        }
-#endif
 
        rs->sr_entry = e;
        rs->sr_flags = flags;
@@ -1482,7 +1481,7 @@ rwm_db_destroy(
                        (struct ldaprwmap *)on->on_bi.bi_private;
 
 #ifdef ENABLE_REWRITE
-               if (rwmap->rwm_rw) {
+               if ( rwmap->rwm_rw ) {
                        rewrite_info_delete( &rwmap->rwm_rw );
                }
 #else /* !ENABLE_REWRITE */
@@ -1491,9 +1490,9 @@ rwm_db_destroy(
                }
 #endif /* !ENABLE_REWRITE */
 
-               avl_free( rwmap->rwm_oc.remap, NULL );
+               avl_free( rwmap->rwm_oc.remap, rwm_mapping_dst_free );
                avl_free( rwmap->rwm_oc.map, rwm_mapping_free );
-               avl_free( rwmap->rwm_at.remap, NULL );
+               avl_free( rwmap->rwm_at.remap, rwm_mapping_dst_free );
                avl_free( rwmap->rwm_at.map, rwm_mapping_free );
 
                ch_free( rwmap );
index aca1c6d95a674469072e2c033e138e1413f0fa01..0c3c73e16c7af9a3ce34d207368e49dfc967fa48 100644 (file)
@@ -138,6 +138,8 @@ rwm_map_attrnames(
                AttributeName **anp,
                int remap );
 
+extern void rwm_mapping_dst_free ( void *mapping );
+
 extern void rwm_mapping_free ( void *mapping );
 
 extern int rwm_map_config(
index 7a87ccff0020665c92539e076407e02955e53029..71a77924c903cbc9a41d93583bbf87173feaaefe 100644 (file)
@@ -146,7 +146,7 @@ rwm_map_config(
                        if ( mapping[0].m_dst_oc == NULL ) {
                                fprintf( stderr, "%s: line %d: unable to mimic destination objectClass '%s'\n",
                                        fname, lineno, dst );
-                               return 1;
+                               goto error_return;
                        }
 
 #if 0
@@ -186,7 +186,7 @@ rwm_map_config(
                                        fprintf( stderr,
        "%s: line %d: source attributeType '%s': %d (%s)\n",
                                                fname, lineno, src, rc, text ? text : "null" );
-                                       return 1;
+                                       goto error_return;
                                }
 
                        }
@@ -207,7 +207,7 @@ rwm_map_config(
                                fprintf( stderr,
        "%s: line %d: destination attributeType '%s': %d (%s)\n",
                                        fname, lineno, dst, rc, text ? text : "null" );
-                               return 1;
+                               goto error_return;
                        }
                }
                mapping[1].m_src_ad = mapping[0].m_dst_ad;
index 4747113e7766e57f76a3928a6718fbb33236feca..1fa9c506d4631bb23a7256911447af6166f2c06f 100644 (file)
@@ -1198,6 +1198,16 @@ rwm_dnattr_result_rewrite(
        return 0;
 }
 
+void
+rwm_mapping_dst_free( void *v_mapping )
+{
+       struct ldapmapping *mapping = v_mapping;
+
+       if ( BER_BVISEMPTY( &mapping[0].m_dst ) ) {
+               rwm_mapping_free( &mapping[ -1 ] );
+       }
+}
+
 void
 rwm_mapping_free( void *v_mapping )
 {