Stuart Henderson <s...@spacehopper.org> writes:

> can this just be switched to a TAILQ?

I think so, please see below,

> is anyone using this that can test?
>
>
> Index: patches/patch-authd_c
> ===================================================================
> RCS file: patches/patch-authd_c
> diff -N patches/patch-authd_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-authd_c     20 Nov 2015 11:18:12 -0000
> @@ -0,0 +1,123 @@
> +$OpenBSD$
> +--- authd.c.orig     Fri Nov 20 11:16:51 2015
> ++++ authd.c  Fri Nov 20 11:17:14 2015
> +@@ -174,7 +174,7 @@ struct auth_attempt {
> +     } result;
> + 
> +     SPLAY_ENTRY(auth_attempt) spe;
> +-    CIRCLEQ_ENTRY(auth_attempt) cqe;
> ++    TAILQ_ENTRY(auth_attempt) cqe;
> + }; /* struct auth_attempt */
> + 
> + 
> +@@ -196,7 +196,7 @@ static const struct auth_peer {
> + struct auth_attempt;
> + 
> + static SPLAY_HEAD(mod_auth_bsd_fail,auth_attempt) auth_failed_lookup;
> +-static CIRCLEQ_HEAD(,auth_attempt) auth_failed_cache;
> ++static TAILQ_HEAD(,auth_attempt) auth_failed_cache;
> + static size_t auth_failed_num;
> + 
> + static int auth_fail_cmp(struct auth_attempt *a, struct auth_attempt *b) {
> +@@ -212,7 +212,7 @@ SPLAY_GENERATE(mod_auth_bsd_fail,auth_attempt,spe,auth
> +  * Cache and lookup tree for successful authentications.
> +  */
> + static SPLAY_HEAD(mod_auth_bsd_okay,auth_attempt) auth_okayed_lookup;
> +-static CIRCLEQ_HEAD(,auth_attempt) auth_okayed_cache;
> ++static TAILQ_HEAD(,auth_attempt) auth_okayed_cache;
> + static size_t auth_okayed_num;
> + 
> + static int auth_okay_cmp(struct auth_attempt *a, struct auth_attempt *b) {
> +@@ -566,15 +566,15 @@ static struct auth_attempt *authd_userokay_cached(stru
> +              * Just setup it up for reallocation.
> +              */
> +             if (now - a->timestamp > cache_ttl) {
> +-                    CIRCLEQ_REMOVE(&auth_okayed_cache,a,cqe);
> +-                    CIRCLEQ_INSERT_HEAD(&auth_okayed_cache,a,cqe);
> ++                    TAILQ_REMOVE(&auth_okayed_cache,a,cqe);
> ++                    TAILQ_INSERT_HEAD(&auth_okayed_cache,a,cqe);
> + 
> +                     a       = NULL;
> +             } else {
> +                     a->timestamp    = now;
> + 
> +-                    CIRCLEQ_REMOVE(&auth_okayed_cache,a,cqe);
> +-                    CIRCLEQ_INSERT_TAIL(&auth_okayed_cache,a,cqe);
> ++                    TAILQ_REMOVE(&auth_okayed_cache,a,cqe);
> ++                    TAILQ_INSERT_TAIL(&auth_okayed_cache,a,cqe);
> +             }
> +     }
> + 
> +@@ -592,11 +592,11 @@ static struct auth_attempt *authd_userokay_cache(struc
> +     now     = time(NULL);
> + 
> +     if (okay) {
> +-            if ((a = CIRCLEQ_FIRST(&auth_okayed_cache)) != 
> CIRCLEQ_END(&auth_okayed_cache)
> ++            if ((a = TAILQ_FIRST(&auth_okayed_cache)) != 
> TAILQ_END(&auth_okayed_cache)

The _END macros are also deprecated.  I doubt that it would be a wise
move to delete them in base... (useless churn is useless)

Anyway, you can just replace TAILQ_END(...) with NULL here.

> +             &&  (now - a->timestamp > cache_ttl || auth_okayed_num >= 
> cache_size)) {
> +                     
> assert(SPLAY_REMOVE(mod_auth_bsd_okay,&auth_okayed_lookup,a));
> + 
> +-                    CIRCLEQ_REMOVE(&auth_okayed_cache,a,cqe);
> ++                    TAILQ_REMOVE(&auth_okayed_cache,a,cqe);
> +                     auth_okayed_num--;
> +             } else if (!(a = malloc(sizeof *a)))
> +                     return NULL;
> +@@ -609,7 +609,7 @@ static struct auth_attempt *authd_userokay_cache(struc
> +             if ((e = 
> SPLAY_INSERT(mod_auth_bsd_okay,&auth_okayed_lookup,a))) {
> +                     e->timestamp    = now;
> + 
> +-                    CIRCLEQ_REMOVE(&auth_okayed_cache,e,cqe);
> ++                    TAILQ_REMOVE(&auth_okayed_cache,e,cqe);
> +                     auth_okayed_num--;
> + 
> +                     free(a);
> +@@ -617,23 +617,23 @@ static struct auth_attempt *authd_userokay_cache(struc
> +                     a       = e;                    
> +             }
> + 
> +-            CIRCLEQ_INSERT_TAIL(&auth_okayed_cache,a,cqe);
> ++            TAILQ_INSERT_TAIL(&auth_okayed_cache,a,cqe);
> +             auth_okayed_num++;
> +     } else {
> +             authd_hash_fail(k.key,pkt);
> + 
> +             if ((a = SPLAY_FIND(mod_auth_bsd_fail,&auth_failed_lookup,&k))) 
> {
> +-                    CIRCLEQ_REMOVE(&auth_failed_cache,a,cqe);
> ++                    TAILQ_REMOVE(&auth_failed_cache,a,cqe);
> +                     auth_failed_num--;
> + 
> +                     if (now - a->timestamp > cache_ttl)
> +                             a->result.failed.count  = 0;
> +             } else {
> +-                    if ((a = CIRCLEQ_FIRST(&auth_failed_cache)) != 
> CIRCLEQ_END(&auth_failed_cache)
> ++                    if ((a = TAILQ_FIRST(&auth_failed_cache)) != 
> TAILQ_END(&auth_failed_cache)
> +                     &&  (now - a->timestamp > cache_ttl || auth_failed_num 
> >= cache_size)) {
> +                             
> assert(SPLAY_REMOVE(mod_auth_bsd_fail,&auth_failed_lookup,a));
> + 
> +-                            CIRCLEQ_REMOVE(&auth_failed_cache,a,cqe);
> ++                            TAILQ_REMOVE(&auth_failed_cache,a,cqe);
> +                             auth_failed_num--;
> +                     } else if (!(a = malloc(sizeof *a)))
> +                             return NULL;
> +@@ -649,7 +649,7 @@ static struct auth_attempt *authd_userokay_cache(struc
> +             a->timestamp    = now;
> +             a->result.failed.count++;
> + 
> +-            CIRCLEQ_INSERT_TAIL(&auth_failed_cache,a,cqe);
> ++            TAILQ_INSERT_TAIL(&auth_failed_cache,a,cqe);
> +             auth_failed_num++;
> +     }
> + 
> +@@ -1147,10 +1147,10 @@ static int authd_init(server_rec *s) {
> +     int status;
> + 
> +     SPLAY_INIT(&auth_failed_lookup);
> +-    CIRCLEQ_INIT(&auth_failed_cache);
> ++    TAILQ_INIT(&auth_failed_cache);
> + 
> +     SPLAY_INIT(&auth_okayed_lookup);
> +-    CIRCLEQ_INIT(&auth_okayed_cache);
> ++    TAILQ_INIT(&auth_okayed_cache);
> + 
> + 
> +     ap_log_error(APLOG_MARK,APLOG_NOTICE|APLOG_NOERRNO,s,"[AuthBSD] 
> Preparing auth daemon");
>


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to