]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/backover.c
slight improvements; doesn't work yet
[openldap] / servers / slapd / backover.c
index 46bd7a439e808a93634a997631aa1e9efe308e09..d97225ac47c833d1b979a2c8acca75140242a4c7 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003 The OpenLDAP Foundation.
+ * Copyright 2003-2004 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -267,15 +267,27 @@ overlay_register(
        return 0;
 }
 
+slap_overinst *
+overlay_next(
+       slap_overinst *on
+)
+{
+       if ( on == NULL ) {
+               return overlays;
+       }
+
+       return on->on_next;
+}
+
 static const char overtype[] = "over";
 
 /* add an overlay to a particular backend. */
 int
 overlay_config( BackendDB *be, const char *ov )
 {
-       slap_overinst *on, *on2, *prev;
-       slap_overinfo *oi;
-       BackendInfo *bi;
+       slap_overinst *on = NULL, *on2 = NULL, *prev = NULL;
+       slap_overinfo *oi = NULL;
+       BackendInfo *bi = NULL;
 
        for ( on = overlays; on; on=on->on_next ) {
                if (!strcmp( ov, on->on_bi.bi_type ) )
@@ -316,12 +328,15 @@ overlay_config( BackendDB *be, const char *ov )
                bi->bi_extended = over_op_extended;
 
                be->bd_info = bi;
+
+       } else {
+               oi = (slap_overinfo *) be->bd_info;
        }
 
+#if 0
        /* Walk to the end of the list of overlays, add the new
         * one onto the end
         */
-       oi = (slap_overinfo *) be->bd_info;
        for ( prev=NULL, on2 = oi->oi_list; on2; prev=on2, on2=on2->on_next );
        on2 = ch_calloc( 1, sizeof(slap_overinst) );
        if ( !prev ) {
@@ -332,6 +347,16 @@ overlay_config( BackendDB *be, const char *ov )
        *on2 = *on;
        on2->on_next = NULL;
        on2->on_info = oi;
+#else
+       /* Insert new overlay on head of list. Overlays are executed
+        * in reverse of config order...
+        */
+       on2 = ch_calloc( 1, sizeof(slap_overinst) );
+       *on2 = *on;
+       on2->on_info = oi;
+       on2->on_next = oi->oi_list;
+       oi->oi_list = on2;
+#endif
 
        /* Any initialization needed? */
        if ( on->on_bi.bi_db_init ) {