X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-ldap%2Fdistproc.c;h=7fb41d4b7b5858ff508e61b46e5449a9d9700890;hb=c8c34cdd43d3603f3b64a56841b4425379c98f45;hp=6124a97514b2174078e9f7ac60a0af38130eb956;hpb=acbb5cf689a4336af05c9f259d909d8141055bac;p=openldap
diff --git a/servers/slapd/back-ldap/distproc.c b/servers/slapd/back-ldap/distproc.c
index 6124a97514..7fb41d4b7b 100644
--- a/servers/slapd/back-ldap/distproc.c
+++ b/servers/slapd/back-ldap/distproc.c
@@ -2,7 +2,7 @@
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
- * Copyright 2005-2006 The OpenLDAP Foundation.
+ * Copyright 2005-2011 The OpenLDAP Foundation.
* Portions Copyright 2003 Howard Chu.
* All rights reserved.
*
@@ -22,14 +22,15 @@
#include "portable.h"
-#ifdef LDAP_DEVEL
-
#include
#include
#include
#include "slap.h"
+
+#ifdef SLAP_DISTPROC
+
#include "back-ldap.h"
#include "config.h"
@@ -106,6 +107,7 @@ typedef struct ContinuationReference_t {
} ContinuationReference_t;
#define CR_INIT { NULL, BER_BVNULL, LDAP_DP_RT_UNKNOWN, BER_BVNULL, LDAP_DP_SS_UNKNOWN, NULL, BER_BVNULL }
+#ifdef unused
static struct berval bv2rt[] = {
BER_BVC( "superior" ),
BER_BVC( "subordinate" ),
@@ -195,6 +197,7 @@ ldap_distproc_str2ss( const char *s )
ber_str2bv( s, 0, 0, &bv );
return ldap_distproc_bv2ss( &bv );
}
+#endif /* unused */
/*
* NOTE: this overlay assumes that the chainingBehavior control
@@ -236,13 +239,7 @@ static int ldap_distproc_db_init_common( BackendDB *be );
static int ldap_distproc_db_init_one( BackendDB *be );
#define ldap_distproc_db_open_one(be) (lback)->bi_db_open( (be) )
#define ldap_distproc_db_close_one(be) (0)
-#define ldap_distproc_db_destroy_one(be) (lback)->bi_db_destroy( (be) )
-
-static int
-ldap_distproc_parse_ctrl(
- Operation *op,
- SlapReply *rs,
- LDAPControl *ctrl );
+#define ldap_distproc_db_destroy_one(be, ca) (lback)->bi_db_destroy( (be), (ca) )
static int
ldap_distproc_uri_cmp( const void *c1, const void *c2 )
@@ -297,7 +294,7 @@ ldap_distproc_operational( Operation *op, SlapReply *rs )
* database. This fix is likely to intercept also entries
* generated by back-perl and so. */
if ( rs->sr_entry->e_private == NULL ) {
- return 0;
+ return LDAP_SUCCESS;
}
return SLAP_CB_CONTINUE;
@@ -336,9 +333,10 @@ static ConfigTable distproc_cfg[] = {
"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
{ "distproc-cache-uri", "TRUE/FALSE",
2, 2, 0, ARG_MAGIC|ARG_ON_OFF|DP_CACHE_URI, distproc_cfgen,
- "( OLcfgOvAt:3.2 NAME 'olcCacheURI' "
+ "( OLcfgOvAt:3.2 NAME 'olcChainCacheURI' "
"DESC 'Enables caching of URIs not present in configuration' "
- "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
+ "SYNTAX OMsBoolean "
+ "SINGLE-VALUE )", NULL, NULL },
{ NULL, NULL, 0, 0, 0, ARG_IGNORED }
};
@@ -349,7 +347,7 @@ static ConfigOCs distproc_ocs[] = {
"SUP olcOverlayConfig "
"MAY ( "
"olcChainingBehavior $ "
- "olcCacheURI "
+ "olcChainCacheURI "
") )",
Cft_Overlay, distproc_cfg, NULL, distproc_cfadd },
{ "( OLcfgOvOc:7.2 "
@@ -445,7 +443,7 @@ distproc_ldadd( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
done:;
if ( rc != LDAP_SUCCESS ) {
- (void)ldap_distproc_db_destroy_one( ca->be );
+ (void)ldap_distproc_db_destroy_one( ca->be, NULL );
ch_free( ca->be );
ca->be = NULL;
}
@@ -470,9 +468,9 @@ ldap_distproc_cfadd_apply( void *datum, void *arg )
struct berval bv;
/* FIXME: should not hardcode "olcDatabase" here */
- bv.bv_len = snprintf( lca->ca->msg, sizeof( lca->ca->msg ),
+ bv.bv_len = snprintf( lca->ca->cr_msg, sizeof( lca->ca->cr_msg ),
"olcDatabase={%d}%s", lca->count, lback->bi_type );
- bv.bv_val = lca->ca->msg;
+ bv.bv_val = lca->ca->cr_msg;
lca->ca->be->be_private = (void *)li;
config_build_entry( lca->op, lca->rs, lca->p->e_private, lca->ca,
@@ -565,7 +563,8 @@ distproc_cfgen( ConfigArgs *c )
static int
ldap_distproc_db_init(
- BackendDB *be )
+ BackendDB *be,
+ ConfigReply *cr )
{
slap_overinst *on = (slap_overinst *)be->bd_info;
ldap_distproc_t *lc = NULL;
@@ -583,6 +582,7 @@ ldap_distproc_db_init(
return 1;
}
memset( lc, 0, sizeof( ldap_distproc_t ) );
+ ldap_pvt_thread_mutex_init( &lc->lc_lai.lai_mutex );
on->on_bi.bi_private = (void *)lc;
@@ -656,7 +656,7 @@ private_destroy:;
db.bd_info = lback;
db.be_private = (void *)lc->lc_cfg_li;
- ldap_distproc_db_destroy_one( &db );
+ ldap_distproc_db_destroy_one( &db, NULL );
lc->lc_cfg_li = NULL;
} else {
@@ -709,7 +709,7 @@ ldap_distproc_db_apply( void *datum, void *arg )
lca->be->be_private = (void *)li;
- return lca->func( lca->be );
+ return lca->func( lca->be, NULL );
}
static int
@@ -732,7 +732,7 @@ ldap_distproc_db_func(
db.bd_info = lback;
db.be_private = lc->lc_common_li;
- rc = func( &db );
+ rc = func( &db, NULL );
if ( rc != 0 ) {
return rc;
@@ -756,21 +756,24 @@ ldap_distproc_db_func(
static int
ldap_distproc_db_open(
- BackendDB *be )
+ BackendDB *be,
+ ConfigReply *cr )
{
return ldap_distproc_db_func( be, db_open );
}
static int
ldap_distproc_db_close(
- BackendDB *be )
+ BackendDB *be,
+ ConfigReply *cr )
{
return ldap_distproc_db_func( be, db_close );
}
static int
ldap_distproc_db_destroy(
- BackendDB *be )
+ BackendDB *be,
+ ConfigReply *cr )
{
slap_overinst *on = (slap_overinst *) be->bd_info;
ldap_distproc_t *lc = (ldap_distproc_t *)on->on_bi.bi_private;
@@ -781,6 +784,7 @@ ldap_distproc_db_destroy(
if ( lc ) {
avl_free( lc->lc_lai.lai_tree, NULL );
+ ldap_pvt_thread_mutex_destroy( &lc->lc_lai.lai_mutex );
ch_free( lc );
}
@@ -800,7 +804,7 @@ ldap_distproc_db_init_common(
be->bd_info = lback;
be->be_private = NULL;
- t = lback->bi_db_init( be );
+ t = lback->bi_db_init( be, NULL );
if ( t != 0 ) {
return t;
}
@@ -827,11 +831,11 @@ ldap_distproc_db_init_one(
BackendInfo *bi = be->bd_info;
ldapinfo_t *li;
- int t;
+ slap_op_t t;
be->bd_info = lback;
be->be_private = NULL;
- t = lback->bi_db_init( be );
+ t = lback->bi_db_init( be, NULL );
if ( t != 0 ) {
return t;
}
@@ -841,7 +845,7 @@ ldap_distproc_db_init_one(
li->li_nretries = lc->lc_common_li->li_nretries;
li->li_flags = lc->lc_common_li->li_flags;
li->li_version = lc->lc_common_li->li_version;
- for ( t = 0; t < LDAP_BACK_OP_LAST; t++ ) {
+ for ( t = 0; t < SLAP_OP_LAST; t++ ) {
li->li_timeout[ t ] = lc->lc_common_li->li_timeout[ t ];
}
be->bd_info = bi;
@@ -954,6 +958,7 @@ distproc_initialize( void )
return rc;
}
+#ifdef LDAP_DEVEL
rc = supported_feature_load( &slap_FEATURE_CANCHAINOPS );
if ( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_ANY, "slapd-distproc: "
@@ -961,6 +966,7 @@ distproc_initialize( void )
rc, 0, 0 );
return rc;
}
+#endif
rc = register_supported_control( LDAP_CONTROL_X_RETURNCONTREF,
SLAP_CTRL_GLOBAL|SLAP_CTRL_ACCESS|SLAP_CTRL_HIDE, NULL,
@@ -1004,4 +1010,4 @@ distproc_initialize( void )
return overlay_register( &distproc );
}
-#endif /* LDAP_DEVEL */
+#endif /* SLAP_DISTPROC */