mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-24 13:24:56 +08:00
Don't assume the replog is sorted, sort the queue before processing.
This commit is contained in:
parent
d31230f859
commit
45d24d16eb
@ -217,6 +217,7 @@ populate_queue(
|
||||
{
|
||||
FILE *fp, *lfp;
|
||||
char *p;
|
||||
int wake = 0;
|
||||
|
||||
if ( acquire_lock( f, &fp, &lfp ) < 0 ) {
|
||||
#ifdef NEW_LOGGING
|
||||
@ -262,10 +263,16 @@ populate_queue(
|
||||
"error: malformed replog entry (begins with \"%s\")\n",
|
||||
p, 0, 0 );
|
||||
#endif
|
||||
} else {
|
||||
wake = 1;
|
||||
}
|
||||
free( p );
|
||||
ldap_pvt_thread_yield();
|
||||
}
|
||||
/* wake up any threads waiting for more work */
|
||||
if ( wake ) {
|
||||
ldap_pvt_thread_cond_broadcast( &sglob->rq->rq_more );
|
||||
}
|
||||
sglob->srpos = ftell( fp );
|
||||
}
|
||||
(void) relinquish_lock( f, fp, lfp );
|
||||
|
@ -197,10 +197,27 @@ Rq_add(
|
||||
rq->rq_head = re;
|
||||
rq->rq_tail = re;
|
||||
wasempty = 1;
|
||||
} else {
|
||||
} else if ( re->re_timestamp > rq->rq_tail->re_timestamp ||
|
||||
( re->re_timestamp == rq->rq_tail->re_timestamp &&
|
||||
re->re_seq > rq->rq_tail->re_seq )) {
|
||||
rq->rq_tail->re_next = re;
|
||||
rq->rq_tail = re;
|
||||
} else {
|
||||
Re *p, *r;
|
||||
|
||||
for (r = rq->rq_head, p = NULL; r->re_timestamp < re->re_timestamp ||
|
||||
(r->re_timestamp == re->re_timestamp && r->re_seq < re->re_seq);
|
||||
p = r, r = r->re_next );
|
||||
if ( !p ) {
|
||||
re->re_next = rq->rq_head;
|
||||
rq->rq_head = re;
|
||||
} else {
|
||||
re->re_next = p->re_next;
|
||||
p->re_next = re;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* set the sequence number */
|
||||
re->re_seq = 0;
|
||||
if ( !wasempty && ( rq->rq_tail->re_timestamp == re->re_timestamp )) {
|
||||
@ -211,11 +228,14 @@ Rq_add(
|
||||
re->re_seq = rq->rq_tail->re_seq + 1;
|
||||
}
|
||||
rq->rq_tail = re;
|
||||
#endif
|
||||
|
||||
/* Increment count of items in queue */
|
||||
rq->rq_nre++;
|
||||
#if 0
|
||||
/* wake up any threads waiting for more work */
|
||||
ldap_pvt_thread_cond_broadcast( &rq->rq_more );
|
||||
#endif
|
||||
|
||||
/* ... and unlock the queue */
|
||||
rq->rq_unlock( rq );
|
||||
|
Loading…
Reference in New Issue
Block a user