Commit 5d411fd9 authored by Jong Hyuk Choi's avatar Jong Hyuk Choi
Browse files

Another patch for the multi syncrepl thread support

parent 1fdda703
......@@ -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 );
}
}
......
......@@ -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 );
......
......@@ -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 */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment