X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslurpd%2Fri.c;h=6432f59f9ce70e01448a4db24f76b9484eb7482b;hb=9568a013a8793ab5eddc2acb5c8027fb5a757a0c;hp=cc478d1e6a77386007feb94078d5b432e56bfd87;hpb=42e0d83cb3a1a1c5b25183f1ab74ce7edbe25de7;p=openldap diff --git a/servers/slurpd/ri.c b/servers/slurpd/ri.c index cc478d1e6a..6432f59f9c 100644 --- a/servers/slurpd/ri.c +++ b/servers/slurpd/ri.c @@ -17,33 +17,20 @@ */ +#include "portable.h" #include -#include + +#include +#include #include "slurp.h" #include "globals.h" -/* External references */ -#ifdef NEEDPROTOS -extern void write_reject( Ri *, Re *, int, char * ); -extern void do_nothing(); -#else /* NEEDPROTOS */ -extern void write_reject(); -extern void do_nothing(); -#endif /* NEEDPROTOS */ - /* Forward references */ -#ifdef NEEDPROTOS -static int ismine( Ri *, Re * ); -static int isnew( Ri *, Re * ); -void tsleep( time_t ); -#else /* NEEDPROTOS */ -static int ismine(); -static int isnew(); -void tsleep(); -#endif /* NEEDPROTOS */ +static int ismine LDAP_P(( Ri *, Re * )); +static int isnew LDAP_P(( Ri *, Re * )); /* @@ -56,11 +43,10 @@ Ri_process( { Rq *rq = sglob->rq; Re *re, *new_re; - int i; int rc ; char *errmsg; - (void) SIGNAL( SIGUSR1, (void *) do_nothing ); + (void) SIGNAL( LDAP_SIGUSR1, do_nothing ); (void) SIGNAL( SIGPIPE, SIG_IGN ); if ( ri == NULL ) { Debug( LDAP_DEBUG_ANY, "Error: Ri_process: ri == NULL!\n", 0, 0, 0 ); @@ -75,7 +61,7 @@ Ri_process( while ( !sglob->slurpd_shutdown && (( re = rq->rq_gethead( rq )) == NULL )) { /* No work - wait on condition variable */ - pthread_cond_wait( &rq->rq_more, &rq->rq_mutex ); + ldap_pvt_thread_cond_wait( &rq->rq_more, &rq->rq_mutex ); } /* @@ -99,20 +85,22 @@ Ri_process( rc = do_ldap( ri, re, &errmsg ); switch ( rc ) { case DO_LDAP_ERR_RETRYABLE: - tsleep( RETRY_SLEEP_TIME ); + ldap_pvt_thread_sleep( RETRY_SLEEP_TIME ); Debug( LDAP_DEBUG_ANY, "Retrying operation for DN %s on replica %s:%d\n", re->re_dn, ri->ri_hostname, ri->ri_port ); continue; break; - case DO_LDAP_ERR_FATAL: + case DO_LDAP_ERR_FATAL: { /* Non-retryable error. Write rejection log. */ - write_reject( ri, re, ri->ri_ldp->ld_errno, errmsg ); + int ld_errno = 0; + ldap_get_option(ri->ri_ldp, LDAP_OPT_ERROR_NUMBER, &ld_errno); + write_reject( ri, re, ld_errno, errmsg ); /* Update status ... */ (void) sglob->st->st_update( sglob->st, ri->ri_stel, re ); /* ... and write to disk */ (void) sglob->st->st_write( sglob->st ); - break; + } break; default: /* LDAP op completed ok - update status... */ (void) sglob->st->st_update( sglob->st, ri->ri_stel, re ); @@ -129,10 +117,11 @@ Ri_process( while ( !sglob->slurpd_shutdown && ((new_re = re->re_getnext( re )) == NULL )) { if ( sglob->one_shot_mode ) { + rq->rq_unlock( rq ); return 0; } /* No work - wait on condition variable */ - pthread_cond_wait( &rq->rq_more, &rq->rq_mutex ); + ldap_pvt_thread_cond_wait( &rq->rq_more, &rq->rq_mutex ); } re->re_decrefcnt( re ); re = new_re; @@ -146,7 +135,8 @@ Ri_process( /* - * Wake a replication thread which may be sleeping. Send it a SIGUSR1. + * Wake a replication thread which may be sleeping. + * Send it a LDAP_SIGUSR1. */ static void Ri_wake( @@ -156,8 +146,8 @@ Ri_wake( if ( ri == NULL ) { return; } - pthread_kill( ri->ri_tid, SIGUSR1 ); - (void) SIGNAL( SIGUSR1, (void *) do_nothing ); + ldap_pvt_thread_kill( ri->ri_tid, LDAP_SIGUSR1 ); + (void) SIGNAL( LDAP_SIGUSR1, do_nothing ); } @@ -262,5 +252,3 @@ isnew( sglob->st->st_unlock( sglob->st ); return ret; } - -