From: Jong Hyuk Choi Date: Wed, 26 Nov 2003 20:40:16 +0000 (+0000) Subject: Another patch for the multi syncrepl thread support X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~372 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5d411fd9637fd2f291a09a5802497ec0895af87a;p=openldap Another patch for the multi syncrepl thread support --- diff --git a/libraries/libldap_r/rq.c b/libraries/libldap_r/rq.c index 75bf99563b..6cbddd6143 100644 --- a/libraries/libldap_r/rq.c +++ b/libraries/libldap_r/rq.c @@ -47,7 +47,7 @@ ldap_pvt_runqueue_insert( entry->next_sched.tv_usec = 0; entry->routine = routine; entry->arg = arg; - LDAP_STAILQ_INSERT_HEAD( &rq->task_list, entry, tnext ); + LDAP_STAILQ_INSERT_TAIL( &rq->task_list, entry, tnext ); } void @@ -98,7 +98,7 @@ ldap_pvt_runqueue_runtask( struct re_s* entry ) { - LDAP_STAILQ_INSERT_HEAD( &rq->run_list, entry, rnext ); + LDAP_STAILQ_INSERT_TAIL( &rq->run_list, entry, rnext ); } void @@ -164,17 +164,18 @@ ldap_pvt_runqueue_resched( } else { LDAP_STAILQ_INSERT_AFTER( &rq->task_list, prev, entry, tnext ); } - break; + return; } else if ( e->next_sched.tv_sec > entry->next_sched.tv_sec ) { if ( prev == NULL ) { LDAP_STAILQ_INSERT_HEAD( &rq->task_list, entry, tnext ); } else { LDAP_STAILQ_INSERT_AFTER( &rq->task_list, prev, entry, tnext ); } - break; + return; } prev = e; } + LDAP_STAILQ_INSERT_TAIL( &rq->task_list, entry, tnext ); } } diff --git a/servers/slapd/operation.c b/servers/slapd/operation.c index ff6fbf3cc6..9ac982bb87 100644 --- a/servers/slapd/operation.c +++ b/servers/slapd/operation.c @@ -94,6 +94,7 @@ slap_op_free( Operation *op ) op->o_sync_state.sid = -1; op->o_sync_slog_size = -1; + op->o_sync_state.rid = -1; ldap_pvt_thread_mutex_lock( &slap_op_mutex ); LDAP_STAILQ_INSERT_HEAD( &slap_free_ops, op, o_next ); ldap_pvt_thread_mutex_unlock( &slap_op_mutex ); @@ -130,6 +131,7 @@ slap_op_alloc( op->o_sync_state.sid = -1; op->o_sync_slog_size = -1; + op->o_sync_state.rid = -1; LDAP_STAILQ_FIRST( &op->o_sync_slog_list ) = NULL; op->o_sync_slog_list.stqh_last = &LDAP_STAILQ_FIRST( &op->o_sync_slog_list ); diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 12cb666b32..90e58e5adb 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -193,6 +193,9 @@ do_syncrep1( struct berval syncrepl_cn_bv; struct sync_cookie *sc = NULL; struct sync_cookie syncCookie = { NULL, -1, NULL }; + struct berval *psub; + + psub = &si->si_be->be_nsuffix[0]; /* Init connection to master */ @@ -311,8 +314,7 @@ do_syncrep1( syncrepl_cn_bv.bv_val = syncrepl_cbuf; syncrepl_cn_bv.bv_len = snprintf(syncrepl_cbuf, sizeof(syncrepl_cbuf), CN_STR "syncrepl%d", si->si_id ); - build_new_dn( &op->o_req_ndn, &si->si_base, &syncrepl_cn_bv, - op->o_tmpmemctx ); + build_new_dn( &op->o_req_ndn, psub, &syncrepl_cn_bv, op->o_tmpmemctx ); op->o_req_dn = op->o_req_ndn; LDAP_STAILQ_FOREACH( sc, &slap_sync_cookie, sc_next ) { @@ -347,9 +349,12 @@ do_syncrep1( sc = NULL; } else { /* stored cookie */ + struct berval newcookie = { 0, NULL }; ber_dupbv( &cookie_bv, &cookie[0] ); ber_bvarray_add( &si->si_syncCookie.octet_str, &cookie_bv ); slap_parse_sync_cookie( &si->si_syncCookie ); + ber_bvarray_free( si->si_syncCookie.octet_str ); + si->si_syncCookie.octet_str = NULL; ber_bvarray_free_x( cookie, op->o_tmpmemctx ); if ( sc->sid != -1 ) { /* command line cookie wins */ @@ -370,6 +375,10 @@ do_syncrep1( } slap_sync_cookie_free( sc, 1 ); sc = NULL; + slap_compose_sync_cookie( NULL, &newcookie, + &si->si_syncCookie.ctxcsn[0], + si->si_syncCookie.sid, si->si_syncCookie.rid ); + ber_bvarray_add( &si->si_syncCookie.octet_str, &newcookie ); } } else { /* no command line cookie is specified */