]> jfr.im git - solanum.git/blobdiff - ircd/msgbuf.c
Support more human friendly k/d/x-line duration format
[solanum.git] / ircd / msgbuf.c
index 0d134e678eba24586b1707f02857d3170a8baca6..7040123a1782aebe818e39e39d4dff19db81f11a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * solanum - an advanced ircd.
- * Copyright (c) 2016 William Pitcock <nenolod@dereferenced.org>.
+ * Copyright (c) 2016 Ariadne Conill <ariadne@dereferenced.org>.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -440,8 +440,11 @@ msgbuf_cache_get(struct MsgBuf_cache *cache, unsigned int caps)
        struct MsgBuf_cache_entry *entry = cache->head;
        struct MsgBuf_cache_entry *prev = NULL;
        struct MsgBuf_cache_entry *result = NULL;
+       struct MsgBuf_cache_entry *tail = NULL;
        int n = 0;
 
+       caps &= cache->overall_capmask;
+
        while (entry != NULL) {
                if (entry->caps == caps) {
                        /* Cache hit */
@@ -449,6 +452,7 @@ msgbuf_cache_get(struct MsgBuf_cache *cache, unsigned int caps)
                        break;
                }
 
+               tail = prev;
                prev = entry;
                entry = entry->next;
                n++;
@@ -462,6 +466,8 @@ msgbuf_cache_get(struct MsgBuf_cache *cache, unsigned int caps)
                } else {
                        /* Cache full, replace the last entry */
                        result = prev;
+                       if (tail != NULL)
+                               tail->next = NULL;
                        prev = NULL;
 
                        rb_linebuf_donebuf(&result->linebuf);