]> git.sur5r.net Git - openldap/commitdiff
use be_ctrls[cid] for counting the number of overlay instances that have
authorRalf Haferkamp <ralf@openldap.org>
Fri, 2 Jul 2010 11:31:34 +0000 (11:31 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Mon, 7 Nov 2011 20:00:59 +0000 (12:00 -0800)
registered the control for a specific BackendDB to make sure that
the control is unregistered only after the last instance calls
overlay_unregister_control().

servers/slapd/backover.c

index f332b335f206088f85ca6b024284e65fe08012a3..f3e5f80ff6bdc0677f625d8d0c36edf5cfeac7d5 100644 (file)
@@ -1076,14 +1076,22 @@ overlay_register_control( BackendDB *be, const char *oid )
                                gotit = 1;
                        }
 
-                       bd->be_ctrls[ cid ] = 1;
+                       /* overlays can be instanciated multiple times, use
+                        * be_ctrls[ cid ] as an instance counter, so that the
+                        * overlay's controls are only really disabled after the
+                        * last instance called overlay_register_control() */
+                       bd->be_ctrls[ cid ]++;
                        bd->be_ctrls[ SLAP_MAX_CIDS ] = 1;
                }
 
        }
        
        if ( !gotit ) {
-               be->bd_self->be_ctrls[ cid ] = 1;
+               /* overlays can be instanciated multiple times, use
+                * be_ctrls[ cid ] as an instance counter, so that the
+                * overlay's controls are only really unregistered after the
+                * last instance called overlay_register_control() */
+               be->bd_self->be_ctrls[ cid ]++;
                be->bd_self->be_ctrls[ SLAP_MAX_CIDS ] = 1;
        }
 
@@ -1110,12 +1118,12 @@ overlay_unregister_control( BackendDB *be, const char *oid )
                                gotit = 1;
                        }
 
-                       bd->be_ctrls[ cid ] = 0;
+                       bd->be_ctrls[ cid ]--;
                }
        }
 
        if ( !gotit ) {
-               be->bd_self->be_ctrls[ cid ] = 0;
+               be->bd_self->be_ctrls[ cid ]--;
        }
 }
 #endif /* SLAP_CONFIG_DELETE */