version 1.147.2.46, 2009/02/23 02:15:32
|
version 1.147.2.47, 2009/03/05 20:20:47
|
Line 1
|
Line 1
|
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.147.2.45 2009/02/17 00:06:01 quanah Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.147.2.46 2009/02/23 02:15:32 quanah 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/>. |
* |
* |
Line 876 syncprov_qplay( Operation *op, struct re
|
Line 876 syncprov_qplay( Operation *op, struct re
|
break; |
break; |
ldap_pvt_thread_mutex_unlock( &so->s_mutex ); |
ldap_pvt_thread_mutex_unlock( &so->s_mutex ); |
|
|
opc.sdn = sr->s_dn; |
if ( sr->s_mode == LDAP_SYNC_NEW_COOKIE ) { |
opc.sndn = sr->s_ndn; |
SlapReply rs = { REP_INTERMEDIATE }; |
opc.suuid = sr->s_uuid; |
|
opc.sctxcsn = sr->s_csn; |
rc = syncprov_sendinfo( op, &rs, LDAP_TAG_SYNC_NEW_COOKIE, |
opc.sreference = sr->s_isreference; |
&sr->s_csn, 0, NULL, 0 ); |
e = NULL; |
} else { |
|
opc.sdn = sr->s_dn; |
if ( sr->s_mode != LDAP_SYNC_DELETE ) { |
opc.sndn = sr->s_ndn; |
rc = overlay_entry_get_ov( op, &opc.sndn, NULL, NULL, 0, &e, on ); |
opc.suuid = sr->s_uuid; |
if ( rc ) { |
opc.sctxcsn = sr->s_csn; |
Debug( LDAP_DEBUG_SYNC, "syncprov_qplay: failed to get %s, " |
opc.sreference = sr->s_isreference; |
"error (%d), ignoring...\n", opc.sndn.bv_val, rc, 0 ); |
e = NULL; |
ch_free( sr ); |
|
rc = 0; |
if ( sr->s_mode != LDAP_SYNC_DELETE ) { |
continue; |
rc = overlay_entry_get_ov( op, &opc.sndn, NULL, NULL, 0, &e, on ); |
|
if ( rc ) { |
|
Debug( LDAP_DEBUG_SYNC, "syncprov_qplay: failed to get %s, " |
|
"error (%d), ignoring...\n", opc.sndn.bv_val, rc, 0 ); |
|
ch_free( sr ); |
|
rc = 0; |
|
continue; |
|
} |
} |
} |
} |
rc = syncprov_sendresp( op, &opc, so, &e, sr->s_mode ); |
rc = syncprov_sendresp( op, &opc, so, &e, sr->s_mode ); |
|
|
|
if ( e ) { |
if ( e ) { |
overlay_entry_release_ov( op, e, 0, on ); |
overlay_entry_release_ov( op, e, 0, on ); |
|
} |
} |
} |
|
|
ch_free( sr ); |
ch_free( sr ); |
Line 1007 static int
|
Line 1014 static int
|
syncprov_qresp( opcookie *opc, syncops *so, int mode ) |
syncprov_qresp( opcookie *opc, syncops *so, int mode ) |
{ |
{ |
syncres *sr; |
syncres *sr; |
int sid, srsize; |
int srsize; |
|
struct berval cookie = opc->sctxcsn; |
|
|
/* Don't send changes back to their originator */ |
if ( mode == LDAP_SYNC_NEW_COOKIE ) { |
sid = slap_parse_csn_sid( &opc->sctxcsn ); |
syncprov_info_t *si = opc->son->on_bi.bi_private; |
if ( sid >= 0 && sid == so->s_sid ) |
|
return LDAP_SUCCESS; |
slap_compose_sync_cookie( NULL, &cookie, si->si_ctxcsn, |
|
so->s_rid, so->s_sid); |
|
} else if ( opc->sctxcsn.bv_len ) { |
|
/* Don't send changes back to their originator */ |
|
int sid = slap_parse_csn_sid( &opc->sctxcsn ); |
|
if ( sid >= 0 && sid == so->s_sid ) |
|
return LDAP_SUCCESS; |
|
} |
|
|
srsize = sizeof(syncres) + opc->suuid.bv_len + 1 + |
srsize = sizeof(syncres) + opc->suuid.bv_len + 1 + |
opc->sdn.bv_len + 1 + opc->sndn.bv_len + 1; |
opc->sdn.bv_len + 1 + opc->sndn.bv_len + 1; |
if ( opc->sctxcsn.bv_len ) |
if ( cookie.bv_len ) |
srsize += opc->sctxcsn.bv_len + 1; |
srsize += cookie.bv_len + 1; |
sr = ch_malloc( srsize ); |
sr = ch_malloc( srsize ); |
sr->s_next = NULL; |
sr->s_next = NULL; |
sr->s_dn.bv_val = (char *)(sr + 1); |
sr->s_dn.bv_val = (char *)(sr + 1); |
Line 1031 syncprov_qresp( opcookie *opc, syncops *
|
Line 1046 syncprov_qresp( opcookie *opc, syncops *
|
opc->sndn.bv_val ) + 1; |
opc->sndn.bv_val ) + 1; |
sr->s_uuid.bv_len = opc->suuid.bv_len; |
sr->s_uuid.bv_len = opc->suuid.bv_len; |
AC_MEMCPY( sr->s_uuid.bv_val, opc->suuid.bv_val, opc->suuid.bv_len ); |
AC_MEMCPY( sr->s_uuid.bv_val, opc->suuid.bv_val, opc->suuid.bv_len ); |
if ( opc->sctxcsn.bv_len ) { |
if ( cookie.bv_len ) { |
sr->s_csn.bv_val = sr->s_uuid.bv_val + sr->s_uuid.bv_len + 1; |
sr->s_csn.bv_val = sr->s_uuid.bv_val + sr->s_uuid.bv_len + 1; |
strcpy( sr->s_csn.bv_val, opc->sctxcsn.bv_val ); |
strcpy( sr->s_csn.bv_val, cookie.bv_val ); |
} else { |
} else { |
sr->s_csn.bv_val = NULL; |
sr->s_csn.bv_val = NULL; |
} |
} |
sr->s_csn.bv_len = opc->sctxcsn.bv_len; |
sr->s_csn.bv_len = cookie.bv_len; |
|
|
|
if ( mode == LDAP_SYNC_NEW_COOKIE && cookie.bv_val ) { |
|
ch_free( cookie.bv_val ); |
|
} |
|
|
ldap_pvt_thread_mutex_lock( &so->s_mutex ); |
ldap_pvt_thread_mutex_lock( &so->s_mutex ); |
if ( !so->s_res ) { |
if ( !so->s_res ) { |
Line 1266 syncprov_matchops( Operation *op, opcook
|
Line 1285 syncprov_matchops( Operation *op, opcook
|
} else if ( !saveit && found ) { |
} else if ( !saveit && found ) { |
/* send DELETE */ |
/* send DELETE */ |
syncprov_qresp( opc, ss, LDAP_SYNC_DELETE ); |
syncprov_qresp( opc, ss, LDAP_SYNC_DELETE ); |
|
} else if ( !saveit ) { |
|
syncprov_qresp( opc, ss, LDAP_SYNC_NEW_COOKIE ); |
} |
} |
if ( !saveit && found ) { |
if ( !saveit && found ) { |
/* Decrement s_inuse, was incremented when called |
/* Decrement s_inuse, was incremented when called |