From: Pierangelo Masarati Date: Thu, 3 Nov 2005 13:34:43 +0000 (+0000) Subject: release entry, if required; release mapping resources as appropriate on exit X-Git-Tag: OPENLDAP_REL_ENG_2_2_MP~123 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e2b87791accc0651477fb369626d9074dd7a015e;p=openldap release entry, if required; release mapping resources as appropriate on exit --- diff --git a/servers/slapd/overlays/rwm.c b/servers/slapd/overlays/rwm.c index 6246cc68a6..42bf3f8c1e 100644 --- a/servers/slapd/overlays/rwm.c +++ b/servers/slapd/overlays/rwm.c @@ -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 ); diff --git a/servers/slapd/overlays/rwm.h b/servers/slapd/overlays/rwm.h index aca1c6d95a..0c3c73e16c 100644 --- a/servers/slapd/overlays/rwm.h +++ b/servers/slapd/overlays/rwm.h @@ -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( diff --git a/servers/slapd/overlays/rwmconf.c b/servers/slapd/overlays/rwmconf.c index 7a87ccff00..71a77924c9 100644 --- a/servers/slapd/overlays/rwmconf.c +++ b/servers/slapd/overlays/rwmconf.c @@ -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; diff --git a/servers/slapd/overlays/rwmmap.c b/servers/slapd/overlays/rwmmap.c index 4747113e77..1fa9c506d4 100644 --- a/servers/slapd/overlays/rwmmap.c +++ b/servers/slapd/overlays/rwmmap.c @@ -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 ) {