]> git.sur5r.net Git - openldap/commitdiff
Another patch for the multi syncrepl thread support
authorJong Hyuk Choi <jongchoi@openldap.org>
Wed, 26 Nov 2003 20:40:16 +0000 (20:40 +0000)
committerJong Hyuk Choi <jongchoi@openldap.org>
Wed, 26 Nov 2003 20:40:16 +0000 (20:40 +0000)
libraries/libldap_r/rq.c
servers/slapd/operation.c
servers/slapd/syncrepl.c

index 75bf99563b21b570af0153d35b9463111c038c1b..6cbddd61437dbed0bce455d28464af0a87119cf9 100644 (file)
@@ -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 );
        }
 }
 
index ff6fbf3cc6203cdba7700cf58daa85f2219e4558..9ac982bb87cd891a2b8d8cc51023ff57a83bb067 100644 (file)
@@ -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 );
 
index 12cb666b32859ca326dea054dc79b37ca0e1c810..90e58e5adb5217ffa66bd85818040bda752ad012 100644 (file)
@@ -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 */