]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
remove ISC_QUEUE as it is no longer used
authorEvan Hunt <each@isc.org>
Wed, 6 Nov 2019 00:39:58 +0000 (16:39 -0800)
committerEvan Hunt <each@isc.org>
Thu, 7 Nov 2019 19:55:37 +0000 (11:55 -0800)
15 files changed:
doc/dev/dev.md
lib/dns/include/dns/fixedname.h
lib/isc/app.c
lib/isc/include/isc/buffer.h
lib/isc/include/isc/event.h
lib/isc/include/isc/list.h
lib/isc/include/isc/sockaddr.h
lib/isc/include/isc/types.h
lib/isc/tests/Kyuafile
lib/isc/tests/Makefile.in
lib/isc/tests/queue_test.c [deleted file]
lib/ns/client.c
lib/ns/include/ns/client.h
lib/ns/notify.c
util/copyrights

index d769d6f18b6596c3eeba2d3d03ce399df69a4e85..7fbbc8ac867b126c45d76b9f757b170f969f4365 100644 (file)
@@ -654,10 +654,6 @@ Items can be removed from the list using `ISC_LIST_UNLINK`:
 
         ISC_LIST_UNLINK(foolist, foo, link);
 
-A similar but smaller set of `ISC_QUEUE` macros, including `ISC_QUEUE_PUSH`
-and `ISC_QUEUE_POP`, are provided to implement strict FIFO lists, with
-built-in fine-grained locking.
-
 #### <a name="names"></a>Names
 
 The `dns_name` API has facilities for processing DNS names and labels,
index 623313439cb419dd02e4b588b50876d3d4cf8250..6a9b5551050dcfacfba687c5dabac5701016ed7c 100644 (file)
@@ -51,7 +51,6 @@
 
 #include <isc/buffer.h>
 #include <isc/lang.h>
-#include <isc/list.h>
 
 #include <dns/name.h>
 
index 9f228278bb554b9f41679c3a299c8ee41a4c14ab..1a013f1f01174d9b910591ef54f30b4794b1ca59 100644 (file)
@@ -29,7 +29,6 @@
 #include <isc/atomic.h>
 #include <isc/app.h>
 #include <isc/condition.h>
-#include <isc/list.h>
 #include <isc/mem.h>
 #include <isc/mutex.h>
 #include <isc/event.h>
index 6dec61ef6412104420ec4c1499b04e04346c86b3..07d259956c884bed01e54c57ba614912aff2e771 100644 (file)
 #include <isc/assertions.h>
 #include <isc/formatcheck.h>
 #include <isc/lang.h>
-#include <isc/list.h>
 #include <isc/likely.h>
 #include <isc/magic.h>
 #include <isc/types.h>
index 3e9fe19c8a66c982a05a486e5ea958e0d7267648..99d867cd5a3f7020f30a843205367f83ba42dd83 100644 (file)
@@ -16,7 +16,6 @@
 /*! \file isc/event.h */
 
 #include <isc/lang.h>
-#include <isc/list.h>
 #include <isc/types.h>
 
 /*****
index b7b245c1bd92c75db41eea739343bfa4f75be7d5..bc90bb974ef345e5b947fdf74a50b035286f1cf3 100644 (file)
@@ -9,14 +9,11 @@
  * information regarding copyright ownership.
  */
 
+
 #ifndef ISC_LIST_H
 #define ISC_LIST_H 1
 
-#include <stdbool.h>
-
 #include <isc/assertions.h>
-#include <isc/mutex.h>
-#include <isc/types.h>
 
 #ifdef ISC_LIST_CHECKINIT
 #define ISC_LINK_INSIST(x) ISC_INSIST(x)
@@ -24,6 +21,7 @@
 #define ISC_LINK_INSIST(x)
 #endif
 
+#define ISC_LIST(type) struct { type *head, *tail; }
 #define ISC_LIST_INIT(list) \
        do { (list).head = NULL; (list).tail = NULL; } while (0)
 
 #define __ISC_LIST_DEQUEUEUNSAFE_TYPE(list, elt, link, type) \
        __ISC_LIST_UNLINKUNSAFE_TYPE(list, elt, link, type)
 
-/*
- * This is a generic implementation of a two-lock concurrent queue.
- * There are built-in mutex locks for the head and tail of the queue,
- * allowing elements to be safely added and removed at the same time.
- *
- * NULL is "end of list"
- * -1 is "not linked"
- */
-
-#ifdef ISC_QUEUE_CHECKINIT
-#define ISC_QLINK_INSIST(x) ISC_INSIST(x)
-#else
-#define ISC_QLINK_INSIST(x) (void)0
-#endif
-
-#define ISC_QLINK(type) struct { type *prev, *next; }
-
-#define ISC_QLINK_INIT(elt, link) \
-       do { \
-               (elt)->link.next = (elt)->link.prev = (void *)(-1); \
-       } while(0)
-
-#define ISC_QLINK_LINKED(elt, link) ((void*)(elt)->link.next != (void*)(-1))
-
-#define ISC_QUEUE(type) struct { \
-       type *head, *tail; \
-       isc_mutex_t headlock, taillock; \
-}
-
-#define ISC_QUEUE_INIT(queue, link) \
-       do { \
-               isc_mutex_init(&(queue).taillock); \
-               isc_mutex_init(&(queue).headlock); \
-               (queue).tail = (queue).head = NULL; \
-       } while (0)
-
-#define ISC_QUEUE_EMPTY(queue) ((queue).head == NULL)
-
-#define ISC_QUEUE_DESTROY(queue) \
-       do { \
-               ISC_QLINK_INSIST(ISC_QUEUE_EMPTY(queue)); \
-               isc_mutex_destroy(&(queue).taillock); \
-               isc_mutex_destroy(&(queue).headlock); \
-       } while (0)
-
-/*
- * queues are meant to separate the locks at either end.  For best effect, that
- * means keeping the ends separate - i.e. non-empty queues work best.
- *
- * a push to an empty queue has to take the pop lock to update
- * the pop side of the queue.
- * Popping the last entry has to take the push lock to update
- * the push side of the queue.
- *
- * The order is (pop, push), because a pop is presumably in the
- * latency path and a push is when we're done.
- *
- * We do an MT hot test in push to see if we need both locks, so we can
- * acquire them in order.  Hopefully that makes the case where we get
- * the push lock and find we need the pop lock (and have to release it) rare.
- *
- * > 1 entry - no collision, push works on one end, pop on the other
- *   0 entry - headlock race
- *     pop wins - return(NULL), push adds new as both head/tail
- *     push wins - updates head/tail, becomes 1 entry case.
- *   1 entry - taillock race
- *     pop wins - return(pop) sets head/tail NULL, becomes 0 entry case
- *     push wins - updates {head,tail}->link.next, pop updates head
- *                 with new ->link.next and doesn't update tail
- *
- */
-#define ISC_QUEUE_PUSH(queue, elt, link) \
-       do { \
-               bool headlocked = false; \
-               ISC_QLINK_INSIST(!ISC_QLINK_LINKED(elt, link)); \
-               if ((queue).head == NULL) { \
-                       LOCK(&(queue).headlock); \
-                       headlocked = true; \
-               } \
-               LOCK(&(queue).taillock); \
-               if ((queue).tail == NULL && !headlocked) { \
-                       UNLOCK(&(queue).taillock); \
-                       LOCK(&(queue).headlock); \
-                       LOCK(&(queue).taillock); \
-                       headlocked = true; \
-               } \
-               (elt)->link.prev = (queue).tail; \
-               (elt)->link.next = NULL; \
-               if ((queue).tail != NULL) \
-                       (queue).tail->link.next = (elt); \
-               (queue).tail = (elt); \
-               UNLOCK(&(queue).taillock); \
-               if (headlocked) { \
-                       if ((queue).head == NULL) \
-                               (queue).head = (elt); \
-                       UNLOCK(&(queue).headlock); \
-               } \
-       } while (0)
-
-#define ISC_QUEUE_POP(queue, link, ret) \
-       do { \
-               LOCK(&(queue).headlock); \
-               ret = (queue).head; \
-               while (ret != NULL) { \
-                       if (ret->link.next == NULL) { \
-                               LOCK(&(queue).taillock); \
-                               if (ret->link.next == NULL) { \
-                                       (queue).head = (queue).tail = NULL; \
-                                       UNLOCK(&(queue).taillock); \
-                                       break; \
-                               }\
-                               UNLOCK(&(queue).taillock); \
-                       } \
-                       (queue).head = ret->link.next; \
-                       (queue).head->link.prev = NULL; \
-                       break; \
-               } \
-               UNLOCK(&(queue).headlock); \
-               if (ret != NULL) \
-                       (ret)->link.next = (ret)->link.prev = (void *)(-1); \
-       } while(0)
-
-#define ISC_QUEUE_UNLINK(queue, elt, link) \
-       do { \
-               ISC_QLINK_INSIST(ISC_QLINK_LINKED(elt, link)); \
-               LOCK(&(queue).headlock); \
-               LOCK(&(queue).taillock); \
-               if ((elt)->link.prev == NULL) \
-                       (queue).head = (elt)->link.next; \
-               else \
-                       (elt)->link.prev->link.next = (elt)->link.next; \
-               if ((elt)->link.next == NULL) \
-                       (queue).tail = (elt)->link.prev; \
-               else \
-                       (elt)->link.next->link.prev = (elt)->link.prev; \
-               UNLOCK(&(queue).taillock); \
-               UNLOCK(&(queue).headlock); \
-               (elt)->link.next = (elt)->link.prev = (void *)(-1); \
-       } while(0)
-
 #endif /* ISC_LIST_H */
index a1d50808813b10c712fed581cc37b2a1b30aefcf..1588ba9645e57a9fcbbcda34b92e2783c056ee97 100644 (file)
@@ -18,7 +18,6 @@
 #include <stdbool.h>
 
 #include <isc/lang.h>
-#include <isc/list.h>
 #include <isc/net.h>
 #include <isc/types.h>
 #ifdef ISC_PLATFORM_HAVESYSUNH
index 5548d9989dd38ed3a906d6c11c0559352e50ca65..3d1eb779b7b5441b8391174b67d0b53e5568581a 100644 (file)
  */
 #include <inttypes.h>
 #include <stdbool.h>
-
-#include <isc/lang.h>
 #include <isc/offset.h>
 
-/* Core Types.  Alphabetized by defined type. */
-
 /*
- * Defined here so we don't need to include list.h.
+ * XXXDCL This is just for ISC_LIST and ISC_LINK, but gets all of the other
+ * list macros too.
  */
-#define ISC_LIST(type) struct { type *head, *tail; }
+#include <isc/list.h>
+
+/* Core Types.  Alphabetized by defined type. */
 
 typedef struct isc_astack              isc_astack_t;           /*%< Array-based fast stack */
 typedef struct isc_appctx              isc_appctx_t;           /*%< Application context */
index 4f25e1939254b6a307c5af8f3ca70d6f4f8b76b9..834261b3214af0dc5453ba7489417984a2c223fb 100644 (file)
@@ -16,7 +16,6 @@ tap_test_program{name='mem_test'}
 tap_test_program{name='netaddr_test'}
 tap_test_program{name='parse_test'}
 tap_test_program{name='pool_test'}
-tap_test_program{name='queue_test'}
 tap_test_program{name='radix_test'}
 tap_test_program{name='regex_test'}
 tap_test_program{name='result_test'}
index abeca57a6273b42f7b1674da59ecb39f96e255bc..046b8dcff3fab5980c7956927014b899e93df7aa 100644 (file)
@@ -33,7 +33,7 @@ SRCS =                isctest.c aes_test.c buffer_test.c \
                counter_test.c crc64_test.c errno_test.c file_test.c hash_test.c \
                heap_test.c hmac_test.c ht_test.c lex_test.c \
                mem_test.c md_test.c netaddr_test.c parse_test.c pool_test.c \
-               queue_test.c radix_test.c random_test.c \
+               radix_test.c random_test.c \
                regex_test.c result_test.c safe_test.c siphash_test.c sockaddr_test.c \
                socket_test.c socket_test.c symtab_test.c task_test.c \
                taskpool_test.c time_test.c timer_test.c
@@ -46,7 +46,7 @@ TARGETS =     aes_test@EXEEXT@ buffer_test@EXEEXT@ \
                ht_test@EXEEXT@ \
                lex_test@EXEEXT@ mem_test@EXEEXT@ md_test@EXEEXT@ \
                netaddr_test@EXEEXT@ parse_test@EXEEXT@ pool_test@EXEEXT@ \
-               queue_test@EXEEXT@ radix_test@EXEEXT@ \
+               radix_test@EXEEXT@ \
                random_test@EXEEXT@ regex_test@EXEEXT@ result_test@EXEEXT@ \
                safe_test@EXEEXT@ siphash_test@EXEEXT@ sockaddr_test@EXEEXT@ socket_test@EXEEXT@ \
                socket_test@EXEEXT@ symtab_test@EXEEXT@ task_test@EXEEXT@ \
@@ -134,11 +134,6 @@ pool_test@EXEEXT@: pool_test.@O@ isctest.@O@ ${ISCDEPLIBS}
                ${LDFLAGS} -o $@ pool_test.@O@ isctest.@O@ \
                ${ISCLIBS} ${LIBS}
 
-queue_test@EXEEXT@: queue_test.@O@ isctest.@O@ ${ISCDEPLIBS}
-       ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} \
-               ${LDFLAGS} -o $@ queue_test.@O@ isctest.@O@ \
-               ${ISCLIBS} ${LIBS}
-
 radix_test@EXEEXT@: radix_test.@O@ isctest.@O@ ${ISCDEPLIBS}
        ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} \
                ${LDFLAGS} -o $@ radix_test.@O@ isctest.@O@ \
diff --git a/lib/isc/tests/queue_test.c b/lib/isc/tests/queue_test.c
deleted file mode 100644 (file)
index 7302577..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#if HAVE_CMOCKA
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-
-#include <sched.h> /* IWYU pragma: keep */
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-
-#define UNIT_TESTING
-#include <cmocka.h>
-
-#include <isc/list.h>
-#include <isc/util.h>
-
-#include "isctest.h"
-
-static int
-_setup(void **state) {
-       isc_result_t result;
-
-       UNUSED(state);
-
-       result = isc_test_begin(NULL, true, 0);
-       assert_int_equal(result, ISC_R_SUCCESS);
-
-       return (0);
-}
-
-static int
-_teardown(void **state) {
-       UNUSED(state);
-
-       isc_test_end();
-
-       return (0);
-}
-
-typedef struct item item_t;
-struct item {
-       int                     value;
-       ISC_QLINK(item_t)       qlink;
-};
-
-typedef ISC_QUEUE(item_t) item_queue_t;
-
-static void
-item_init(item_t *item, int value) {
-       item->value = value;
-       ISC_QLINK_INIT(item, qlink);
-}
-
-/* Test UDP sendto/recv (IPv4) */
-static void
-queue_valid(void **state) {
-       item_queue_t queue;
-       item_t one, two, three, four, five;
-       item_t *p;
-
-       UNUSED(state);
-
-       ISC_QUEUE_INIT(queue, qlink);
-
-       item_init(&one, 1);
-       item_init(&two, 2);
-       item_init(&three, 3);
-       item_init(&four, 4);
-       item_init(&five, 5);
-
-       assert_true(ISC_QUEUE_EMPTY(queue));
-
-       ISC_QUEUE_POP(queue, qlink, p);
-       assert_null(p);
-
-       assert_false(ISC_QLINK_LINKED(&one, qlink));
-       ISC_QUEUE_PUSH(queue, &one, qlink);
-       assert_true(ISC_QLINK_LINKED(&one, qlink));
-
-       assert_false(ISC_QUEUE_EMPTY(queue));
-
-       ISC_QUEUE_POP(queue, qlink, p);
-       assert_non_null(p);
-       assert_int_equal(p->value, 1);
-       assert_true(ISC_QUEUE_EMPTY(queue));
-       assert_false(ISC_QLINK_LINKED(p, qlink));
-
-       ISC_QUEUE_PUSH(queue, p, qlink);
-       assert_false(ISC_QUEUE_EMPTY(queue));
-       assert_true(ISC_QLINK_LINKED(p, qlink));
-
-       assert_false(ISC_QLINK_LINKED(&two, qlink));
-       ISC_QUEUE_PUSH(queue, &two, qlink);
-       assert_true(ISC_QLINK_LINKED(&two, qlink));
-
-       assert_false(ISC_QLINK_LINKED(&three, qlink));
-       ISC_QUEUE_PUSH(queue, &three, qlink);
-       assert_true(ISC_QLINK_LINKED(&three, qlink));
-
-       assert_false(ISC_QLINK_LINKED(&four, qlink));
-       ISC_QUEUE_PUSH(queue, &four, qlink);
-       assert_true(ISC_QLINK_LINKED(&four, qlink));
-
-       assert_false(ISC_QLINK_LINKED(&five, qlink));
-       ISC_QUEUE_PUSH(queue, &five, qlink);
-       assert_true(ISC_QLINK_LINKED(&five, qlink));
-
-       /* Test unlink by removing one item from the middle */
-       ISC_QUEUE_UNLINK(queue, &three, qlink);
-
-       ISC_QUEUE_POP(queue, qlink, p);
-       assert_non_null(p);
-       assert_int_equal(p->value, 1);
-
-       ISC_QUEUE_POP(queue, qlink, p);
-       assert_non_null(p);
-       assert_int_equal(p->value, 2);
-
-       ISC_QUEUE_POP(queue, qlink, p);
-       assert_non_null(p);
-       assert_int_equal(p->value, 4);
-
-       ISC_QUEUE_POP(queue, qlink, p);
-       assert_non_null(p);
-       assert_int_equal(p->value, 5);
-
-       assert_null(queue.head);
-       assert_null(queue.tail);
-       assert_true(ISC_QUEUE_EMPTY(queue));
-
-       ISC_QUEUE_DESTROY(queue);
-}
-
-int
-main(void) {
-       const struct CMUnitTest tests[] = {
-               cmocka_unit_test_setup_teardown(queue_valid,
-                                               _setup, _teardown),
-       };
-
-       return (cmocka_run_group_tests(tests, NULL, NULL));
-}
-
-#else /* HAVE_CMOCKA */
-
-#include <stdio.h>
-
-int
-main(void) {
-       printf("1..0 # Skipped: cmocka not available\n");
-       return (0);
-}
-
-#endif
index 9104c3809ea58af6c390f8288f9a892d21e6f548..69400141a1e836c3067af1bc3a45b2a1c14ad7a4 100644 (file)
@@ -16,7 +16,6 @@
 #include <isc/formatcheck.h>
 #include <isc/fuzz.h>
 #include <isc/hmac.h>
-#include <isc/list.h>
 #include <isc/mutex.h>
 #include <isc/once.h>
 #include <isc/nonce.h>
index 0ad452ad8a1775af668b5745716495e79553f67c..613a91f822c27724739e651c967fcabed6238765 100644 (file)
@@ -58,7 +58,6 @@
 #include <stdbool.h>
 
 #include <isc/buffer.h>
-#include <isc/list.h>
 #include <isc/magic.h>
 #include <isc/netmgr.h>
 #include <isc/stdtime.h>
index be4ef5dca79725734692d1541916daccd78f157f..3c0ad5db17024882f840c6cedec7a8912cefb2b6 100644 (file)
@@ -9,7 +9,6 @@
  * information regarding copyright ownership.
  */
 
-#include <isc/list.h>
 #include <isc/log.h>
 #include <isc/print.h>
 
index 66eb5bed7dc4ac0795f47444caf9d6d152da03f1..92a4506c57aa5eb3dfdf5acfde4b5182a2c2135d 100644 (file)
 ./lib/isc/tests/netaddr_test.c                 C       2016,2018,2019
 ./lib/isc/tests/parse_test.c                   C       2012,2013,2016,2018,2019
 ./lib/isc/tests/pool_test.c                    C       2013,2016,2018,2019
-./lib/isc/tests/queue_test.c                   C       2011,2012,2016,2018,2019
 ./lib/isc/tests/radix_test.c                   C       2014,2016,2018,2019
 ./lib/isc/tests/random_test.c                  C       2014,2015,2016,2017,2018,2019
 ./lib/isc/tests/regex_test.c                   C       2013,2015,2016,2018,2019