version 1.147.2.82, 2011/01/04 18:25:20
|
version 1.328, 2011/01/06 21:37:23
|
Line 1
|
Line 1
|
/* $OpenLDAP$ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.327 2011/01/04 23:43:32 kurt Exp $ */ |
/* syncprov.c - syncrepl provider */ |
/* syncprov.c - syncrepl provider */ |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
* |
* |
* Copyright 2004-2010 The OpenLDAP Foundation. |
* Copyright 2004-2011 The OpenLDAP Foundation. |
* All rights reserved. |
* All rights reserved. |
* |
* |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
Line 735 again:
|
Line 735 again:
|
/* If we didn't find an exact match, then try for <= */ |
/* If we didn't find an exact match, then try for <= */ |
if ( findcsn_retry ) { |
if ( findcsn_retry ) { |
findcsn_retry = 0; |
findcsn_retry = 0; |
|
rs_reinit( &frs, REP_RESULT ); |
goto again; |
goto again; |
} |
} |
rc = LDAP_NO_SUCH_OBJECT; |
rc = LDAP_NO_SUCH_OBJECT; |
Line 785 syncprov_free_syncop( syncops *so )
|
Line 786 syncprov_free_syncop( syncops *so )
|
GroupAssertion *ga, *gnext; |
GroupAssertion *ga, *gnext; |
|
|
ldap_pvt_thread_mutex_lock( &so->s_mutex ); |
ldap_pvt_thread_mutex_lock( &so->s_mutex ); |
if ( --so->s_inuse > 0 ) { |
/* already being freed, or still in use */ |
|
if ( !so->s_inuse || --so->s_inuse > 0 ) { |
ldap_pvt_thread_mutex_unlock( &so->s_mutex ); |
ldap_pvt_thread_mutex_unlock( &so->s_mutex ); |
return; |
return; |
} |
} |
Line 817 syncprov_free_syncop( syncops *so )
|
Line 819 syncprov_free_syncop( syncops *so )
|
static int |
static int |
syncprov_sendresp( Operation *op, opcookie *opc, syncops *so, int mode ) |
syncprov_sendresp( Operation *op, opcookie *opc, syncops *so, int mode ) |
{ |
{ |
slap_overinst *on = opc->son; |
|
|
|
SlapReply rs = { REP_SEARCH }; |
SlapReply rs = { REP_SEARCH }; |
LDAPControl *ctrls[2]; |
LDAPControl *ctrls[2]; |
struct berval cookie = BER_BVNULL, csns[2]; |
struct berval cookie = BER_BVNULL, csns[2]; |
Line 914 syncprov_qplay( Operation *op, syncops *
|
Line 914 syncprov_qplay( Operation *op, syncops *
|
{ |
{ |
slap_overinst *on = LDAP_SLIST_FIRST(&so->s_op->o_extra)->oe_key; |
slap_overinst *on = LDAP_SLIST_FIRST(&so->s_op->o_extra)->oe_key; |
syncres *sr; |
syncres *sr; |
Entry *e; |
|
opcookie opc; |
opcookie opc; |
int rc = 0; |
int rc = 0; |
|
|
Line 1376 syncprov_op_cleanup( Operation *op, Slap
|
Line 1375 syncprov_op_cleanup( Operation *op, Slap
|
slap_overinst *on = opc->son; |
slap_overinst *on = opc->son; |
syncprov_info_t *si = on->on_bi.bi_private; |
syncprov_info_t *si = on->on_bi.bi_private; |
syncmatches *sm, *snext; |
syncmatches *sm, *snext; |
modtarget *mt, mtdummy; |
modtarget *mt; |
|
|
ldap_pvt_thread_mutex_lock( &si->si_ops_mutex ); |
ldap_pvt_thread_mutex_lock( &si->si_ops_mutex ); |
if ( si->si_active ) |
if ( si->si_active ) |
Line 1420 syncprov_op_cleanup( Operation *op, Slap
|
Line 1419 syncprov_op_cleanup( Operation *op, Slap
|
} |
} |
|
|
static void |
static void |
syncprov_checkpoint( Operation *op, SlapReply *rs, slap_overinst *on ) |
syncprov_checkpoint( Operation *op, slap_overinst *on ) |
{ |
{ |
syncprov_info_t *si = (syncprov_info_t *)on->on_bi.bi_private; |
syncprov_info_t *si = (syncprov_info_t *)on->on_bi.bi_private; |
Modifications mod; |
Modifications mod; |
Operation opm; |
Operation opm; |
SlapReply rsm = { 0 }; |
SlapReply rsm = {REP_RESULT}; |
slap_callback cb = {0}; |
slap_callback cb = {0}; |
BackendDB be; |
BackendDB be; |
BackendInfo *bi; |
BackendInfo *bi; |
Line 1470 syncprov_checkpoint( Operation *op, Slap
|
Line 1469 syncprov_checkpoint( Operation *op, Slap
|
char txtbuf[SLAP_TEXT_BUFLEN]; |
char txtbuf[SLAP_TEXT_BUFLEN]; |
size_t textlen = sizeof txtbuf; |
size_t textlen = sizeof txtbuf; |
Entry *e = slap_create_context_csn_entry( opm.o_bd, NULL ); |
Entry *e = slap_create_context_csn_entry( opm.o_bd, NULL ); |
|
rs_reinit( &rsm, REP_RESULT ); |
slap_mods2entry( &mod, &e, 0, 1, &text, txtbuf, textlen); |
slap_mods2entry( &mod, &e, 0, 1, &text, txtbuf, textlen); |
opm.ora_e = e; |
opm.ora_e = e; |
opm.o_bd->be_add( &opm, &rsm ); |
opm.o_bd->be_add( &opm, &rsm ); |
Line 1681 syncprov_playlog( Operation *op, SlapRep
|
Line 1681 syncprov_playlog( Operation *op, SlapRep
|
|
|
if ( mmods ) { |
if ( mmods ) { |
Operation fop; |
Operation fop; |
SlapReply frs = { REP_RESULT }; |
|
int rc; |
int rc; |
Filter mf, af; |
Filter mf, af; |
AttributeAssertion eq = ATTRIBUTEASSERTION_INIT; |
AttributeAssertion eq = ATTRIBUTEASSERTION_INIT; |
Line 1711 syncprov_playlog( Operation *op, SlapRep
|
Line 1710 syncprov_playlog( Operation *op, SlapRep
|
fop.o_bd->bd_info = (BackendInfo *)on->on_info; |
fop.o_bd->bd_info = (BackendInfo *)on->on_info; |
|
|
for ( i=ndel; i<num; i++ ) { |
for ( i=ndel; i<num; i++ ) { |
if ( uuids[i].bv_len == 0 ) continue; |
if ( uuids[i].bv_len != 0 ) { |
|
SlapReply frs = { REP_RESULT }; |
|
|
mf.f_av_value = uuids[i]; |
mf.f_av_value = uuids[i]; |
cb.sc_private = NULL; |
cb.sc_private = NULL; |
fop.ors_slimit = 1; |
fop.ors_slimit = 1; |
frs.sr_nentries = 0; |
|
rc = fop.o_bd->be_search( &fop, &frs ); |
rc = fop.o_bd->be_search( &fop, &frs ); |
|
|
/* If entry was not found, add to delete list */ |
/* If entry was not found, add to delete list */ |
if ( !cb.sc_private ) { |
if ( !cb.sc_private ) { |
uuids[ndel++] = uuids[i]; |
uuids[ndel++] = uuids[i]; |
} |
} |
|
} |
} |
} |
fop.o_bd->bd_info = (BackendInfo *)on; |
fop.o_bd->bd_info = (BackendInfo *)on; |
} |
} |
Line 1895 syncprov_op_response( Operation *op, Sla
|
Line 1895 syncprov_op_response( Operation *op, Sla
|
|
|
if ( do_check ) { |
if ( do_check ) { |
ldap_pvt_thread_rdwr_rlock( &si->si_csn_rwlock ); |
ldap_pvt_thread_rdwr_rlock( &si->si_csn_rwlock ); |
syncprov_checkpoint( op, rs, on ); |
syncprov_checkpoint( op, on ); |
ldap_pvt_thread_rdwr_runlock( &si->si_csn_rwlock ); |
ldap_pvt_thread_rdwr_runlock( &si->si_csn_rwlock ); |
} |
} |
|
|
Line 1930 syncprov_op_response( Operation *op, Sla
|
Line 1930 syncprov_op_response( Operation *op, Sla
|
} |
} |
|
|
/* Add any log records */ |
/* Add any log records */ |
if ( si->si_logs && op->o_tag != LDAP_REQ_ADD ) { |
if ( si->si_logs ) { |
syncprov_add_slog( op ); |
syncprov_add_slog( op ); |
} |
} |
leave: ldap_pvt_thread_mutex_unlock( &si->si_resp_mutex ); |
leave: ldap_pvt_thread_mutex_unlock( &si->si_resp_mutex ); |
Line 2740 syncprov_operational(
|
Line 2740 syncprov_operational(
|
} |
} |
|
|
if ( !ap ) { |
if ( !ap ) { |
if ( !(rs->sr_flags & REP_ENTRY_MODIFIABLE) ) { |
if ( rs_ensure_entry_modifiable( op, rs, on )) { |
Entry *e = entry_dup( rs->sr_entry ); |
|
if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) { |
|
overlay_entry_release_ov( op, rs->sr_entry, 0, on ); |
|
rs->sr_flags ^= REP_ENTRY_MUSTRELEASE; |
|
} else if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) { |
|
entry_free( rs->sr_entry ); |
|
} |
|
rs->sr_entry = e; |
|
rs->sr_flags |= |
|
REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED; |
|
a = attr_find( rs->sr_entry->e_attrs, |
a = attr_find( rs->sr_entry->e_attrs, |
slap_schema.si_ad_contextCSN ); |
slap_schema.si_ad_contextCSN ); |
} |
} |
Line 3076 syncprov_db_close(
|
Line 3066 syncprov_db_close(
|
{ |
{ |
slap_overinst *on = (slap_overinst *) be->bd_info; |
slap_overinst *on = (slap_overinst *) be->bd_info; |
syncprov_info_t *si = (syncprov_info_t *)on->on_bi.bi_private; |
syncprov_info_t *si = (syncprov_info_t *)on->on_bi.bi_private; |
|
#ifdef SLAP_CONFIG_DELETE |
|
syncops *so, *sonext; |
|
#endif /* SLAP_CONFIG_DELETE */ |
|
|
if ( slapMode & SLAP_TOOL_MODE ) { |
if ( slapMode & SLAP_TOOL_MODE ) { |
return 0; |
return 0; |
Line 3084 syncprov_db_close(
|
Line 3077 syncprov_db_close(
|
Connection conn = {0}; |
Connection conn = {0}; |
OperationBuffer opbuf; |
OperationBuffer opbuf; |
Operation *op; |
Operation *op; |
SlapReply rs = {REP_RESULT}; |
|
void *thrctx; |
void *thrctx; |
|
|
thrctx = ldap_pvt_thread_pool_context(); |
thrctx = ldap_pvt_thread_pool_context(); |
Line 3093 syncprov_db_close(
|
Line 3085 syncprov_db_close(
|
op->o_bd = be; |
op->o_bd = be; |
op->o_dn = be->be_rootdn; |
op->o_dn = be->be_rootdn; |
op->o_ndn = be->be_rootndn; |
op->o_ndn = be->be_rootndn; |
syncprov_checkpoint( op, &rs, on ); |
syncprov_checkpoint( op, on ); |
} |
} |
|
|
|
#ifdef SLAP_CONFIG_DELETE |
|
ldap_pvt_thread_mutex_lock( &si->si_ops_mutex ); |
|
for ( so=si->si_ops, sonext=so; so; so=sonext ) { |
|
SlapReply rs = {REP_RESULT}; |
|
rs.sr_err = LDAP_UNAVAILABLE; |
|
send_ldap_result( so->s_op, &rs ); |
|
sonext=so->s_next; |
|
syncprov_drop_psearch( so, 0); |
|
} |
|
si->si_ops=NULL; |
|
ldap_pvt_thread_mutex_unlock( &si->si_ops_mutex ); |
|
overlay_unregister_control( be, LDAP_CONTROL_SYNC ); |
|
#endif /* SLAP_CONFIG_DELETE */ |
|
|
return 0; |
return 0; |
} |
} |
|
|