Some LCUP clean up

This commit is contained in:
Kurt Zeilenga 2002-09-06 00:29:20 +00:00
parent bbc22d5318
commit 37d9880495
4 changed files with 82 additions and 76 deletions

View file

@ -201,6 +201,7 @@ typedef struct ldapcontrol {
#define LDAP_CONTROL_PAGEDRESULTS "1.2.840.113556.1.4.319"
#endif
#define LDAP_CLIENT_UPDATE 1
#ifdef LDAP_CLIENT_UPDATE
#define LDAP_CONTROL_CLIENT_UPDATE "1.3.6.1.4.1.4203.666.5.3"
#define LDAP_CONTROL_ENTRY_UPDATE "1.3.6.1.4.1.4203.666.5.4"
@ -460,22 +461,20 @@ typedef struct ldapcontrol {
#ifdef LDAP_CLIENT_UPDATE
/* resultCode for LCUP */
#define LCUP_RESOURCES_EXHAUSTED 0x62
#define LCUP_SECURITY_VIOLATION 0x63
#define LCUP_INVALID_COOKIE 0x64
#define LCUP_UNSUPPORTED_SCHEME 0x65
#define LCUP_CLIENT_DISCONNECT 0x66
#define LCUP_RELOAD_REQUIRED 0x67
#endif /* LDAP_CLIENT_UPDATE */
#define LDAP_CUP_RESOURCES_EXHAUSTED 0x62
#define LDAP_CUP_SECURITY_VIOLATION 0x63
#define LDAP_CUP_INVALID_COOKIE 0x64
#define LDAP_CUP_UNSUPPORTED_SCHEME 0x65
#define LDAP_CUP_CLIENT_DISCONNECT 0x66
#define LDAP_CUP_RELOAD_REQUIRED 0x67
#ifdef LDAP_CLIENT_UPDATE
#define SYNCHRONIZE_ONLY 0x00
#define SYNCHRONIZE_AND_PERSIST 0x01
#define PERSIST_ONLY 0x02
#endif /* LDAP_CLIENT_UPDATE */
/* LCUP update type */
#define LDAP_CUP_SYNC_ONLY 0x00
#define LDAP_CUP_SYNC_AND_PERSIST 0x01
#define LDAP_CUP_PERSIST_ONLY 0x02
#ifdef LDAP_CLIENT_UPDATE
#define LDAP_LCUP_DEFAULT_SEND_COOKIE_INTERVAL 0x01
/* LCUP default cookie interval */
#define LDAP_CUP_DEFAULT_SEND_COOKIE_INTERVAL 0x01
#endif /* LDAP_CLIENT_UPDATE */
/*

View file

@ -57,9 +57,9 @@ bdb_search(
int manageDSAit;
#ifdef LDAP_CLIENT_UPDATE
Filter lcupf, csnfnot, csnfeq, csnfand, csnfge;
Filter lcupf, csnfnot, csnfeq, csnfand, csnfge;
AttributeAssertion aa_ge, aa_eq;
LDAPControl ctrl;
LDAPControl ctrl;
int entry_count = 0;
#endif /* LDAP_CLIENT_UPDATE */
@ -342,31 +342,30 @@ dn2entry_retry:
#endif /* SLAP_X_FILTER_HASSUBORDINATES */
#ifdef LDAP_CLIENT_UPDATE
if ( op->o_clientupdatetype == SYNCHRONIZE_ONLY ||
op->o_clientupdatetype == SYNCHRONIZE_AND_PERSIST ) {
lcupf.f_choice = LDAP_FILTER_AND;
lcupf.f_and = &csnfnot;
lcupf.f_next = NULL;
if ( op->o_clientupdate_type & SLAP_LCUP_SYNC ) {
lcupf.f_choice = LDAP_FILTER_AND;
lcupf.f_and = &csnfnot;
lcupf.f_next = NULL;
csnfnot.f_choice = LDAP_FILTER_NOT;
csnfnot.f_not = &csnfeq;
csnfnot.f_next = &csnfand;
csnfnot.f_choice = LDAP_FILTER_NOT;
csnfnot.f_not = &csnfeq;
csnfnot.f_next = &csnfand;
csnfeq.f_choice = LDAP_FILTER_EQUALITY;
csnfeq.f_ava = &aa_eq;
csnfeq.f_av_desc = slap_schema.si_ad_entryCSN;
ber_dupbv(&csnfeq.f_av_value, op->o_clientupdatestate);
csnfeq.f_choice = LDAP_FILTER_EQUALITY;
csnfeq.f_ava = &aa_eq;
csnfeq.f_av_desc = slap_schema.si_ad_entryCSN;
ber_dupbv(&csnfeq.f_av_value, op->o_clientupdate_state);
csnfand.f_choice = LDAP_FILTER_AND;
csnfand.f_and = &csnfge;
csnfand.f_next = NULL;
csnfand.f_choice = LDAP_FILTER_AND;
csnfand.f_and = &csnfge;
csnfand.f_next = NULL;
csnfge.f_choice = LDAP_FILTER_GE;
csnfge.f_ava = &aa_ge;
csnfge.f_av_desc = slap_schema.si_ad_entryCSN;
ber_dupbv(&csnfge.f_av_value, op->o_clientupdatestate);
csnfge.f_next = filter;
}
csnfge.f_choice = LDAP_FILTER_GE;
csnfge.f_ava = &aa_ge;
csnfge.f_av_desc = slap_schema.si_ad_entryCSN;
ber_dupbv(&csnfge.f_av_value, op->o_clientupdate_state);
csnfge.f_next = filter;
}
#endif /* LDAP_CLIENT_UPDATE */
for ( id = bdb_idl_first( candidates, &cursor );
@ -553,7 +552,9 @@ id2entry_retry:
goto loop_continue;
}
hasSubordinates = slap_operational_hasSubordinate( hs == LDAP_COMPARE_TRUE );
hasSubordinates = slap_operational_hasSubordinate(
hs == LDAP_COMPARE_TRUE );
if ( hasSubordinates == NULL ) {
goto loop_continue;
}
@ -565,16 +566,13 @@ id2entry_retry:
/* if it matches the filter and scope, send it */
#ifdef LDAP_CLIENT_UPDATE
if ( op->o_clientupdatetype == SYNCHRONIZE_ONLY ||
op->o_clientupdatetype == SYNCHRONIZE_AND_PERSIST ) {
rc = test_filter( be, conn, op, e, &lcupf );
}
else {
rc = test_filter( be, conn, op, e, filter );
}
#else /* LDAP_CLIENT_UPDATE */
rc = test_filter( be, conn, op, e, filter );
if ( op->o_clientupdate_type & SLAP_LCUP_SYNC ) {
rc = test_filter( be, conn, op, e, &lcupf );
} else
#endif /* LDAP_CLIENT_UPDATE */
{
rc = test_filter( be, conn, op, e, filter );
}
#ifdef SLAP_X_FILTER_HASSUBORDINATES
if ( hasSubordinates ) {
@ -673,8 +671,9 @@ id2entry_retry:
loop_continue:
if( e != NULL ) {
/* free reader lock */
bdb_cache_return_entry_r ( bdb->bi_dbenv, &bdb->bi_cache, e , &lock);
e = NULL;
bdb_cache_return_entry_r( bdb->bi_dbenv,
&bdb->bi_cache, e , &lock);
e = NULL;
}
ldap_pvt_thread_yield();

View file

@ -126,10 +126,6 @@ int get_ctrls(
int rc = LDAP_SUCCESS;
const char *errmsg = NULL;
#ifdef LDAP_CLIENT_UPDATE
op->o_clientupdatetype = -1;
#endif
len = ber_pvt_ber_remaining(ber);
if( len == 0) {
@ -624,7 +620,7 @@ static int parseClientUpdate (
struct berval scheme = { 0, NULL };
struct berval cookie = { 0, NULL };
if ( op->o_noop != SLAP_NO_CONTROL ) {
if ( op->o_clientupdate != SLAP_NO_CONTROL ) {
*text = "LCUP client update control specified multiple times";
return LDAP_PROTOCOL_ERROR;
}
@ -656,9 +652,17 @@ static int parseClientUpdate (
return LDAP_PROTOCOL_ERROR;
}
if ( type != SYNCHRONIZE_ONLY &&
type != SYNCHRONIZE_AND_PERSIST &&
type != PERSIST_ONLY ) {
switch( type ) {
case LDAP_CUP_SYNC_ONLY:
type = SLAP_LCUP_SYNC;
break;
case LDAP_CUP_SYNC_AND_PERSIST:
type = SLAP_LCUP_SYNC_AND_PERSIST;
break;
case LDAP_CUP_PERSIST_ONLY:
type = SLAP_LCUP_PERSIST;
break;
default:
*text = "LCUP client update control : unknown update type";
return LDAP_PROTOCOL_ERROR;
}
@ -676,12 +680,12 @@ static int parseClientUpdate (
if ( interval <= 0 ) {
/* server chooses interval */
interval = LDAP_LCUP_DEFAULT_SEND_COOKIE_INTERVAL;
interval = LDAP_CUP_DEFAULT_SEND_COOKIE_INTERVAL;
}
}
else {
} else {
/* server chooses interval */
interval = LDAP_LCUP_DEFAULT_SEND_COOKIE_INTERVAL;
interval = LDAP_CUP_DEFAULT_SEND_COOKIE_INTERVAL;
}
if ( (tag = ber_peek_tag( ber, &len )) == LBER_DEFAULT ) {
@ -710,12 +714,12 @@ static int parseClientUpdate (
}
#endif
op->o_clientupdatestate = ber_dupbv(NULL, &cookie);
op->o_clientupdate_state = ber_dupbv(NULL, &cookie);
(void) ber_free( ber, 1 );
op->o_clientupdatetype = type;
op->o_clientupdateinterval = interval;
op->o_clientupdate_type = (char) type;
op->o_clientupdate_interval = interval;
op->o_clientupdate = ctrl->ldctl_iscritical
? SLAP_CRITICAL_CONTROL

View file

@ -443,7 +443,7 @@ typedef struct slap_matching_rule {
/*
* null terminated list of syntaxes compatible with this syntax
* note: when MS_EXT is set, this MUST NOT contain the assertion
* syntax of the rule. When MS_EXT is not set, it MAY.
* syntax of the rule. When MS_EXT is not set, it MAY.
*/
Syntax **smr_compat_syntaxes;
@ -1237,7 +1237,7 @@ struct slap_backend_db {
#define SLAP_RESTRICT_OP_SEARCH 0x0080U
#define SLAP_RESTRICT_OP_READS \
( SLAP_RESTRICT_OP_COMPARE \
( SLAP_RESTRICT_OP_COMPARE \
| SLAP_RESTRICT_OP_SEARCH )
#define SLAP_RESTRICT_OP_WRITES \
( SLAP_RESTRICT_OP_ADD \
@ -1279,7 +1279,7 @@ struct slap_backend_db {
struct berval be_rootdn; /* the magic "root" name (DN) for this db */
struct berval be_rootndn; /* the magic "root" normalized name (DN) for this db */
struct berval be_rootpw; /* the magic "root" password for this db */
unsigned int be_max_deref_depth; /* limit for depth of an alias deref */
unsigned int be_max_deref_depth; /* limit for depth of an alias deref */
#define be_sizelimit be_def_limit.lms_s_soft
#define be_timelimit be_def_limit.lms_t_soft
struct slap_limits_set be_def_limit; /* default limits */
@ -1352,13 +1352,13 @@ typedef int (BI_op_abandon) LDAP_P((BackendDB *bd,
ber_int_t msgid));
typedef int (BI_op_extended) LDAP_P((
BackendDB *be,
struct slap_conn *conn,
struct slap_op *op,
BackendDB *be,
struct slap_conn *conn,
struct slap_op *op,
const char *reqoid,
struct berval * reqdata,
struct berval * reqdata,
char **rspoid,
struct berval ** rspdata,
struct berval ** rspdata,
LDAPControl *** rspctrls,
const char ** text,
BerVarray *refs ));
@ -1587,9 +1587,13 @@ typedef struct slap_op {
#ifdef LDAP_CLIENT_UPDATE
char o_clientupdate;
ber_int_t o_clientupdatetype;
ber_int_t o_clientupdateinterval;
struct berval* o_clientupdatestate;
char o_clientupdate_type;
#define SLAP_LCUP_NONE (0x0)
#define SLAP_LCUP_SYNC (0x1)
#define SLAP_LCUP_PERSIST (0x2)
#define SLAP_LCUP_SYNC_AND_PERSIST (0x3)
ber_int_t o_clientupdate_interval;
struct berval* o_clientupdate_state;
#endif
#ifdef LDAP_CONNECTIONLESS
@ -1698,7 +1702,7 @@ typedef struct slap_conn {
fprintf( stderr, (fmt), (connid), (opid), (arg1), (arg2), (arg3) );\
if ( ldap_syslog & (level) ) \
syslog( ldap_syslog_level, (fmt), (connid), (opid), (arg1), \
(arg2), (arg3) ); \
(arg2), (arg3) ); \
} while (0)
#else
#define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 )