summaryrefslogtreecommitdiffstats
path: root/usr.bin/dig/lib/isc
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/dig/lib/isc')
-rw-r--r--usr.bin/dig/lib/isc/app_api.c77
-rw-r--r--usr.bin/dig/lib/isc/buffer.c35
-rw-r--r--usr.bin/dig/lib/isc/bufferlist.c4
-rw-r--r--usr.bin/dig/lib/isc/hash.c7
-rw-r--r--usr.bin/dig/lib/isc/heap.c16
-rw-r--r--usr.bin/dig/lib/isc/include/isc/app.h37
-rw-r--r--usr.bin/dig/lib/isc/include/isc/buffer.h15
-rw-r--r--usr.bin/dig/lib/isc/include/isc/magic.h42
-rw-r--r--usr.bin/dig/lib/isc/include/isc/socket.h37
-rw-r--r--usr.bin/dig/lib/isc/include/isc/task.h33
-rw-r--r--usr.bin/dig/lib/isc/include/isc/timer.h33
-rw-r--r--usr.bin/dig/lib/isc/lex.c20
-rw-r--r--usr.bin/dig/lib/isc/log.c54
-rw-r--r--usr.bin/dig/lib/isc/socket_api.c116
-rw-r--r--usr.bin/dig/lib/isc/symtab.c15
-rw-r--r--usr.bin/dig/lib/isc/task.c505
-rw-r--r--usr.bin/dig/lib/isc/task_p.h6
-rw-r--r--usr.bin/dig/lib/isc/timer.c189
-rw-r--r--usr.bin/dig/lib/isc/timer_p.h6
-rw-r--r--usr.bin/dig/lib/isc/unix/app.c222
-rw-r--r--usr.bin/dig/lib/isc/unix/socket.c283
-rw-r--r--usr.bin/dig/lib/isc/unix/socket_p.h6
22 files changed, 277 insertions, 1481 deletions
diff --git a/usr.bin/dig/lib/isc/app_api.c b/usr.bin/dig/lib/isc/app_api.c
deleted file mode 100644
index 3a366b25151..00000000000
--- a/usr.bin/dig/lib/isc/app_api.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* $Id: app_api.c,v 1.2 2020/02/17 18:58:39 jung Exp $ */
-
-
-
-#include <unistd.h>
-
-#include <isc/app.h>
-#include <isc/magic.h>
-#include <isc/util.h>
-
-static isc_appctxcreatefunc_t appctx_createfunc = NULL;
-static isc_boolean_t is_running = ISC_FALSE;
-
-#define ISCAPI_APPMETHODS_VALID(m) ISC_MAGIC_VALID(m, ISCAPI_APPMETHODS_MAGIC)
-
-isc_result_t
-isc_app_start(void) {
- return (isc__app_start());
-}
-
-isc_result_t
-isc_app_onrun(isc_task_t *task,
- isc_taskaction_t action, void *arg)
-{
- return (isc__app_onrun(task, action, arg));
-}
-
-isc_result_t
-isc_app_run() {
- isc_result_t result;
-
- is_running = ISC_TRUE;
- result = isc__app_run();
- is_running = ISC_FALSE;
- return (result);
-}
-
-isc_boolean_t
-isc_app_isrunning() {
- return (is_running);
-}
-
-isc_result_t
-isc_app_shutdown(void) {
- return (isc__app_shutdown());
-}
-
-void
-isc_app_finish(void) {
- isc__app_finish();
-}
-
-void
-isc_app_block(void) {
- isc__app_block();
-}
-
-void
-isc_app_unblock(void) {
- isc__app_unblock();
-}
diff --git a/usr.bin/dig/lib/isc/buffer.c b/usr.bin/dig/lib/isc/buffer.c
index 9e4a8ee732c..5a5bd276775 100644
--- a/usr.bin/dig/lib/isc/buffer.c
+++ b/usr.bin/dig/lib/isc/buffer.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: buffer.c,v 1.2 2020/02/12 13:05:04 jsg Exp $ */
+/* $Id: buffer.c,v 1.3 2020/02/18 18:11:27 florian Exp $ */
/*! \file */
@@ -54,7 +54,6 @@ isc__buffer_invalidate(isc_buffer_t *b) {
* Make 'b' an invalid buffer.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(!ISC_LINK_LINKED(b, link));
ISC__BUFFER_INVALIDATE(b);
@@ -66,7 +65,6 @@ isc__buffer_region(isc_buffer_t *b, isc_region_t *r) {
* Make 'r' refer to the region of 'b'.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(r != NULL);
ISC__BUFFER_REGION(b, r);
@@ -78,7 +76,6 @@ isc__buffer_usedregion(isc_buffer_t *b, isc_region_t *r) {
* Make 'r' refer to the used region of 'b'.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(r != NULL);
ISC__BUFFER_USEDREGION(b, r);
@@ -90,7 +87,6 @@ isc__buffer_availableregion(isc_buffer_t *b, isc_region_t *r) {
* Make 'r' refer to the available region of 'b'.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(r != NULL);
ISC__BUFFER_AVAILABLEREGION(b, r);
@@ -102,7 +98,6 @@ isc__buffer_add(isc_buffer_t *b, unsigned int n) {
* Increase the 'used' region of 'b' by 'n' bytes.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(b->used + n <= b->length);
ISC__BUFFER_ADD(b, n);
@@ -114,7 +109,6 @@ isc__buffer_subtract(isc_buffer_t *b, unsigned int n) {
* Decrease the 'used' region of 'b' by 'n' bytes.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(b->used >= n);
ISC__BUFFER_SUBTRACT(b, n);
@@ -126,8 +120,6 @@ isc__buffer_clear(isc_buffer_t *b) {
* Make the used region empty.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
-
ISC__BUFFER_CLEAR(b);
}
@@ -137,7 +129,6 @@ isc__buffer_consumedregion(isc_buffer_t *b, isc_region_t *r) {
* Make 'r' refer to the consumed region of 'b'.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(r != NULL);
ISC__BUFFER_CONSUMEDREGION(b, r);
@@ -149,7 +140,6 @@ isc__buffer_remainingregion(isc_buffer_t *b, isc_region_t *r) {
* Make 'r' refer to the remaining region of 'b'.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(r != NULL);
ISC__BUFFER_REMAININGREGION(b, r);
@@ -161,7 +151,6 @@ isc__buffer_activeregion(isc_buffer_t *b, isc_region_t *r) {
* Make 'r' refer to the active region of 'b'.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(r != NULL);
ISC__BUFFER_ACTIVEREGION(b, r);
@@ -173,7 +162,6 @@ isc__buffer_setactive(isc_buffer_t *b, unsigned int n) {
* Sets the end of the active region 'n' bytes after current.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(b->current + n <= b->used);
ISC__BUFFER_SETACTIVE(b, n);
@@ -185,8 +173,6 @@ isc__buffer_first(isc_buffer_t *b) {
* Make the consumed region empty.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
-
ISC__BUFFER_FIRST(b);
}
@@ -196,7 +182,6 @@ isc__buffer_forward(isc_buffer_t *b, unsigned int n) {
* Increase the 'consumed' region of 'b' by 'n' bytes.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(b->current + n <= b->used);
ISC__BUFFER_FORWARD(b, n);
@@ -208,7 +193,6 @@ isc__buffer_back(isc_buffer_t *b, unsigned int n) {
* Decrease the 'consumed' region of 'b' by 'n' bytes.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(n <= b->current);
ISC__BUFFER_BACK(b, n);
@@ -225,8 +209,6 @@ isc_buffer_compact(isc_buffer_t *b) {
* of the consumed region, and the consumed region is then made empty.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
-
src = isc_buffer_current(b);
length = isc_buffer_remaininglength(b);
(void)memmove(b->base, src, (size_t)length);
@@ -248,7 +230,6 @@ isc_buffer_getuint8(isc_buffer_t *b) {
* Read an unsigned 8-bit integer from 'b' and return it.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(b->used - b->current >= 1);
cp = isc_buffer_current(b);
@@ -260,7 +241,6 @@ isc_buffer_getuint8(isc_buffer_t *b) {
void
isc__buffer_putuint8(isc_buffer_t *b, uint8_t val) {
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(b->used + 1 <= b->length);
ISC__BUFFER_PUTUINT8(b, val);
@@ -276,7 +256,6 @@ isc_buffer_getuint16(isc_buffer_t *b) {
* convert it to host byte order, and return it.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(b->used - b->current >= 2);
cp = isc_buffer_current(b);
@@ -289,7 +268,6 @@ isc_buffer_getuint16(isc_buffer_t *b) {
void
isc__buffer_putuint16(isc_buffer_t *b, uint16_t val) {
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(b->used + 2 <= b->length);
ISC__BUFFER_PUTUINT16(b, val);
@@ -297,7 +275,6 @@ isc__buffer_putuint16(isc_buffer_t *b, uint16_t val) {
void
isc__buffer_putuint24(isc_buffer_t *b, uint32_t val) {
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(b->used + 3 <= b->length);
ISC__BUFFER_PUTUINT24(b, val);
@@ -313,7 +290,6 @@ isc_buffer_getuint32(isc_buffer_t *b) {
* convert it to host byte order, and return it.
*/
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(b->used - b->current >= 4);
cp = isc_buffer_current(b);
@@ -328,7 +304,6 @@ isc_buffer_getuint32(isc_buffer_t *b) {
void
isc__buffer_putuint32(isc_buffer_t *b, uint32_t val) {
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(b->used + 4 <= b->length);
ISC__BUFFER_PUTUINT32(b, val);
@@ -339,7 +314,6 @@ isc__buffer_putuint48(isc_buffer_t *b, uint64_t val) {
uint16_t valhi;
uint32_t vallo;
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(b->used + 6 <= b->length);
valhi = (uint16_t)(val >> 32);
@@ -352,7 +326,6 @@ void
isc__buffer_putmem(isc_buffer_t *b, const unsigned char *base,
unsigned int length)
{
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(b->used + length <= b->length);
ISC__BUFFER_PUTMEM(b, base, length);
@@ -363,7 +336,6 @@ isc__buffer_putstr(isc_buffer_t *b, const char *source) {
unsigned int l;
unsigned char *cp;
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(source != NULL);
/*
@@ -383,7 +355,6 @@ isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r) {
unsigned char *base;
unsigned int available;
- REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(r != NULL);
/*
@@ -415,8 +386,6 @@ isc_buffer_allocate(isc_buffer_t **dynbuffer,
isc_buffer_init(dbuf, ((unsigned char *)dbuf) + sizeof(isc_buffer_t),
length);
- ENSURE(ISC_BUFFER_VALID(dbuf));
-
*dynbuffer = dbuf;
return (ISC_R_SUCCESS);
@@ -428,8 +397,6 @@ isc_buffer_free(isc_buffer_t **dynbuffer) {
isc_buffer_t *dbuf;
REQUIRE(dynbuffer != NULL);
- REQUIRE(ISC_BUFFER_VALID(*dynbuffer));
-
dbuf = *dynbuffer;
*dynbuffer = NULL; /* destroy external reference */
diff --git a/usr.bin/dig/lib/isc/bufferlist.c b/usr.bin/dig/lib/isc/bufferlist.c
index 22dd18937a4..33e428efe37 100644
--- a/usr.bin/dig/lib/isc/bufferlist.c
+++ b/usr.bin/dig/lib/isc/bufferlist.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: bufferlist.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */
+/* $Id: bufferlist.c,v 1.2 2020/02/18 18:11:27 florian Exp $ */
/*! \file */
@@ -36,7 +36,6 @@ isc_bufferlist_usedcount(isc_bufferlist_t *bl) {
length = 0;
buffer = ISC_LIST_HEAD(*bl);
while (buffer != NULL) {
- REQUIRE(ISC_BUFFER_VALID(buffer));
length += isc_buffer_usedlength(buffer);
buffer = ISC_LIST_NEXT(buffer, link);
}
@@ -54,7 +53,6 @@ isc_bufferlist_availablecount(isc_bufferlist_t *bl) {
length = 0;
buffer = ISC_LIST_HEAD(*bl);
while (buffer != NULL) {
- REQUIRE(ISC_BUFFER_VALID(buffer));
length += isc_buffer_availablelength(buffer);
buffer = ISC_LIST_NEXT(buffer, link);
}
diff --git a/usr.bin/dig/lib/isc/hash.c b/usr.bin/dig/lib/isc/hash.c
index 8e848f08ca6..befa9110003 100644
--- a/usr.bin/dig/lib/isc/hash.c
+++ b/usr.bin/dig/lib/isc/hash.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: hash.c,v 1.2 2020/02/17 18:58:39 jung Exp $ */
+/* $Id: hash.c,v 1.3 2020/02/18 18:11:27 florian Exp $ */
/*! \file
* Some portion of this code was derived from universal hash function
@@ -59,14 +59,10 @@ if advised of the possibility of such damage.
#include <stdlib.h>
#include <isc/hash.h>
-#include <isc/magic.h>
#include <isc/refcount.h>
#include <string.h>
#include <isc/util.h>
-#define HASH_MAGIC ISC_MAGIC('H', 'a', 's', 'h')
-#define VALID_HASH(h) ISC_MAGIC_VALID((h), HASH_MAGIC)
-
/*%
* A large 32-bit prime number that specifies the range of the hash output.
*/
@@ -83,7 +79,6 @@ typedef uint16_t hash_random_t;
/*% isc hash structure */
struct isc_hash {
- unsigned int magic;
isc_boolean_t initialized;
isc_refcount_t refcnt;
size_t limit; /*%< upper limit of key length */
diff --git a/usr.bin/dig/lib/isc/heap.c b/usr.bin/dig/lib/isc/heap.c
index 98d240bd0a1..53326533eae 100644
--- a/usr.bin/dig/lib/isc/heap.c
+++ b/usr.bin/dig/lib/isc/heap.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: heap.c,v 1.3 2020/02/13 08:18:44 florian Exp $ */
+/* $Id: heap.c,v 1.4 2020/02/18 18:11:27 florian Exp $ */
/*! \file
* Heap implementation of priority queues adapted from the following:
@@ -29,7 +29,6 @@
#include <stdlib.h>
#include <isc/heap.h>
-#include <isc/magic.h>
#include <string.h>
#include <isc/util.h>
@@ -46,9 +45,6 @@
#define SIZE_INCREMENT 1024
-#define HEAP_MAGIC ISC_MAGIC('H', 'E', 'A', 'P')
-#define VALID_HEAP(h) ISC_MAGIC_VALID(h, HEAP_MAGIC)
-
/*%
* When the heap is in a consistent state, the following invariant
* holds true: for every element i > 1, heap_parent(i) has a priority
@@ -60,7 +56,6 @@
/*% ISC heap structure. */
struct isc_heap {
- unsigned int magic;
unsigned int size;
unsigned int size_increment;
unsigned int last;
@@ -82,7 +77,6 @@ isc_heap_create(isc_heapcompare_t compare,
heap = malloc(sizeof(*heap));
if (heap == NULL)
return (ISC_R_NOMEMORY);
- heap->magic = HEAP_MAGIC;
heap->size = 0;
if (size_increment == 0)
heap->size_increment = SIZE_INCREMENT;
@@ -104,10 +98,8 @@ isc_heap_destroy(isc_heap_t **heapp) {
REQUIRE(heapp != NULL);
heap = *heapp;
- REQUIRE(VALID_HEAP(heap));
free(heap->array);
- heap->magic = 0;
free(heap);
*heapp = NULL;
@@ -118,7 +110,6 @@ resize(isc_heap_t *heap) {
void **new_array;
unsigned int new_size;
- REQUIRE(VALID_HEAP(heap));
new_size = heap->size + heap->size_increment;
new_array = malloc(new_size * sizeof(void *));
@@ -181,7 +172,6 @@ isc_result_t
isc_heap_insert(isc_heap_t *heap, void *elt) {
unsigned int new_last;
- REQUIRE(VALID_HEAP(heap));
new_last = heap->last + 1;
RUNTIME_CHECK(new_last > 0); /* overflow check */
@@ -199,7 +189,6 @@ isc_heap_delete(isc_heap_t *heap, unsigned int idx) {
void *elt;
isc_boolean_t less;
- REQUIRE(VALID_HEAP(heap));
REQUIRE(idx >= 1 && idx <= heap->last);
if (heap->index != NULL)
@@ -223,7 +212,6 @@ isc_heap_delete(isc_heap_t *heap, unsigned int idx) {
void
isc_heap_increased(isc_heap_t *heap, unsigned int idx) {
- REQUIRE(VALID_HEAP(heap));
REQUIRE(idx >= 1 && idx <= heap->last);
float_up(heap, idx, heap->array[idx]);
@@ -231,7 +219,6 @@ isc_heap_increased(isc_heap_t *heap, unsigned int idx) {
void
isc_heap_decreased(isc_heap_t *heap, unsigned int idx) {
- REQUIRE(VALID_HEAP(heap));
REQUIRE(idx >= 1 && idx <= heap->last);
sink_down(heap, idx, heap->array[idx]);
@@ -239,7 +226,6 @@ isc_heap_decreased(isc_heap_t *heap, unsigned int idx) {
void *
isc_heap_element(isc_heap_t *heap, unsigned int idx) {
- REQUIRE(VALID_HEAP(heap));
REQUIRE(idx >= 1);
if (idx <= heap->last)
diff --git a/usr.bin/dig/lib/isc/include/isc/app.h b/usr.bin/dig/lib/isc/include/isc/app.h
index e371d54b59d..d403b5c0ea3 100644
--- a/usr.bin/dig/lib/isc/include/isc/app.h
+++ b/usr.bin/dig/lib/isc/include/isc/app.h
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: app.h,v 1.4 2020/02/18 18:10:17 florian Exp $ */
+/* $Id: app.h,v 1.5 2020/02/18 18:11:27 florian Exp $ */
#ifndef ISC_APP_H
#define ISC_APP_H 1
@@ -77,7 +77,6 @@
*/
#include <isc/eventclass.h>
-#include <isc/magic.h>
#include <isc/result.h>
/***
@@ -90,24 +89,6 @@ typedef isc_event_t isc_appevent_t;
#define ISC_APPEVENT_SHUTDOWN (ISC_EVENTCLASS_APP + 1)
#define ISC_APPEVENT_LASTEVENT (ISC_EVENTCLASS_APP + 65535)
-/*%
- * This structure is actually just the common prefix of an application context
- * implementation's version of an isc_appctx_t.
- * \brief
- * Direct use of this structure by clients is forbidden. app implementations
- * may change the structure. 'magic' must be ISCAPI_APPCTX_MAGIC for any
- * of the isc_app_ routines to work. app implementations must maintain
- * all app context invariants.
- */
-struct isc_appctx {
- unsigned int impmagic;
- unsigned int magic;
-};
-
-#define ISCAPI_APPCTX_MAGIC ISC_MAGIC('A','a','p','c')
-#define ISCAPI_APPCTX_VALID(c) ((c) != NULL && \
- (c)->magic == ISCAPI_APPCTX_MAGIC)
-
isc_result_t
isc_app_start(void);
/*!<
@@ -188,22 +169,6 @@ isc_app_shutdown(void);
*/
void
-isc_app_finish(void);
-/*!<
- * \brief Finish an ISC library application.
- *
- * Notes:
- *\li This call should be made at or near the end of main().
- *
- * Requires:
- *\li isc_app_start() has been called.
- *\li 'ctx' is a valid application context (for app_ctxfinish()).
- *
- * Ensures:
- *\li Any resources allocated by isc_app_start() have been released.
- */
-
-void
isc_app_block(void);
/*!<
* \brief Indicate that a blocking operation will be performed.
diff --git a/usr.bin/dig/lib/isc/include/isc/buffer.h b/usr.bin/dig/lib/isc/include/isc/buffer.h
index 190a6496b24..acc84999da2 100644
--- a/usr.bin/dig/lib/isc/include/isc/buffer.h
+++ b/usr.bin/dig/lib/isc/include/isc/buffer.h
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: buffer.h,v 1.5 2020/02/15 10:56:25 florian Exp $ */
+/* $Id: buffer.h,v 1.6 2020/02/18 18:11:27 florian Exp $ */
#ifndef ISC_BUFFER_H
#define ISC_BUFFER_H 1
@@ -108,8 +108,6 @@
#include <inttypes.h>
-
-#include <isc/magic.h>
#include <isc/types.h>
/*!
@@ -118,14 +116,6 @@
*/
/* #define ISC_BUFFER_USEINLINE */
-/*@{*/
-/*!
- *** Magic numbers
- ***/
-#define ISC_BUFFER_MAGIC 0x42756621U /* Buf!. */
-#define ISC_BUFFER_VALID(b) ISC_MAGIC_VALID(b, ISC_BUFFER_MAGIC)
-/*@}*/
-
/*
* The following macros MUST be used only on valid buffers. It is the
* caller's responsibility to ensure this by using the ISC_BUFFER_VALID
@@ -165,7 +155,6 @@
*/
struct isc_buffer {
- unsigned int magic;
void *base;
/*@{*/
/*! The following integers are byte offsets from 'base'. */
@@ -648,14 +637,12 @@ isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r);
(_b)->current = 0; \
(_b)->active = 0; \
ISC_LINK_INIT(_b, link); \
- (_b)->magic = ISC_BUFFER_MAGIC; \
} while (0)
#define ISC__BUFFER_INITNULL(_b) ISC__BUFFER_INIT(_b, NULL, 0)
#define ISC__BUFFER_INVALIDATE(_b) \
do { \
- (_b)->magic = 0; \
(_b)->base = NULL; \
(_b)->length = 0; \
(_b)->used = 0; \
diff --git a/usr.bin/dig/lib/isc/include/isc/magic.h b/usr.bin/dig/lib/isc/include/isc/magic.h
deleted file mode 100644
index 02d1bd595ad..00000000000
--- a/usr.bin/dig/lib/isc/include/isc/magic.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* $Id: magic.h,v 1.1 2020/02/07 09:58:54 florian Exp $ */
-
-#ifndef ISC_MAGIC_H
-#define ISC_MAGIC_H 1
-
-
-
-/*! \file isc/magic.h */
-
-typedef struct {
- unsigned int magic;
-} isc__magic_t;
-
-
-/*%
- * To use this macro the magic number MUST be the first thing in the
- * structure, and MUST be of type "unsigned int".
- * The intent of this is to allow magic numbers to be checked even though
- * the object is otherwise opaque.
- */
-#define ISC_MAGIC_VALID(a,b) (((a) != NULL) && \
- (((const isc__magic_t *)(a))->magic == (b)))
-
-#define ISC_MAGIC(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d))
-
-#endif /* ISC_MAGIC_H */
diff --git a/usr.bin/dig/lib/isc/include/isc/socket.h b/usr.bin/dig/lib/isc/include/isc/socket.h
index 23de1086474..3f15155163a 100644
--- a/usr.bin/dig/lib/isc/include/isc/socket.h
+++ b/usr.bin/dig/lib/isc/include/isc/socket.h
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: socket.h,v 1.4 2020/02/18 18:10:17 florian Exp $ */
+/* $Id: socket.h,v 1.5 2020/02/18 18:11:27 florian Exp $ */
#ifndef ISC_SOCKET_H
#define ISC_SOCKET_H 1
@@ -190,41 +190,6 @@ typedef enum {
#define ISC_SOCKFDWATCH_WRITE 0x00000002 /*%< watch for writable */
/*@}*/
-/*%
- * This structure is actually just the common prefix of a socket manager
- * object implementation's version of an isc_socketmgr_t.
- * \brief
- * Direct use of this structure by clients is forbidden. socket implementations
- * may change the structure. 'magic' must be ISCAPI_SOCKETMGR_MAGIC for any
- * of the isc_socket_ routines to work. socket implementations must maintain
- * all socket invariants.
- * In effect, this definition is used only for non-BIND9 version ("export")
- * of the library, and the export version does not work for win32. So, to avoid
- * the definition conflict with win32/socket.c, we enable this definition only
- * for non-Win32 (i.e. Unix) platforms.
- */
-struct isc_socketmgr {
- unsigned int impmagic;
- unsigned int magic;
-};
-
-#define ISCAPI_SOCKETMGR_MAGIC ISC_MAGIC('A','s','m','g')
-#define ISCAPI_SOCKETMGR_VALID(m) ((m) != NULL && \
- (m)->magic == ISCAPI_SOCKETMGR_MAGIC)
-
-/*%
- * This is the common prefix of a socket object. The same note as
- * that for the socketmgr structure applies.
- */
-struct isc_socket {
- unsigned int impmagic;
- unsigned int magic;
-};
-
-#define ISCAPI_SOCKET_MAGIC ISC_MAGIC('A','s','c','t')
-#define ISCAPI_SOCKET_VALID(s) ((s) != NULL && \
- (s)->magic == ISCAPI_SOCKET_MAGIC)
-
/***
*** Socket and Socket Manager Functions
***
diff --git a/usr.bin/dig/lib/isc/include/isc/task.h b/usr.bin/dig/lib/isc/include/isc/task.h
index d493d182d79..887f0f1183d 100644
--- a/usr.bin/dig/lib/isc/include/isc/task.h
+++ b/usr.bin/dig/lib/isc/include/isc/task.h
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: task.h,v 1.5 2020/02/18 18:10:17 florian Exp $ */
+/* $Id: task.h,v 1.6 2020/02/18 18:11:27 florian Exp $ */
#ifndef ISC_TASK_H
#define ISC_TASK_H 1
@@ -100,37 +100,6 @@ typedef enum {
isc_taskmgrmode_privileged
} isc_taskmgrmode_t;
-/*%
- * This structure is actually just the common prefix of a task manager
- * object implementation's version of an isc_taskmgr_t.
- * \brief
- * Direct use of this structure by clients is forbidden. task implementations
- * may change the structure. 'magic' must be ISCAPI_TASKMGR_MAGIC for any
- * of the isc_task_ routines to work. task implementations must maintain
- * all task invariants.
- */
-struct isc_taskmgr {
- unsigned int impmagic;
- unsigned int magic;
-};
-
-#define ISCAPI_TASKMGR_MAGIC ISC_MAGIC('A','t','m','g')
-#define ISCAPI_TASKMGR_VALID(m) ((m) != NULL && \
- (m)->magic == ISCAPI_TASKMGR_MAGIC)
-
-/*%
- * This is the common prefix of a task object. The same note as
- * that for the taskmgr structure applies.
- */
-struct isc_task {
- unsigned int impmagic;
- unsigned int magic;
-};
-
-#define ISCAPI_TASK_MAGIC ISC_MAGIC('A','t','s','t')
-#define ISCAPI_TASK_VALID(s) ((s) != NULL && \
- (s)->magic == ISCAPI_TASK_MAGIC)
-
isc_result_t
isc_task_create(isc_taskmgr_t *manager, unsigned int quantum,
isc_task_t **taskp);
diff --git a/usr.bin/dig/lib/isc/include/isc/timer.h b/usr.bin/dig/lib/isc/include/isc/timer.h
index 1dc618598e1..6eb76fa61a3 100644
--- a/usr.bin/dig/lib/isc/include/isc/timer.h
+++ b/usr.bin/dig/lib/isc/include/isc/timer.h
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: timer.h,v 1.9 2020/02/16 21:08:59 florian Exp $ */
+/* $Id: timer.h,v 1.10 2020/02/18 18:11:27 florian Exp $ */
#ifndef ISC_TIMER_H
#define ISC_TIMER_H 1
@@ -93,37 +93,6 @@ typedef struct isc_timerevent {
#define ISC_TIMEREVENT_LIFE (ISC_EVENTCLASS_TIMER + 3)
#define ISC_TIMEREVENT_LASTEVENT (ISC_EVENTCLASS_TIMER + 65535)
-/*%
- * This structure is actually just the common prefix of a timer manager
- * object implementation's version of an isc_timermgr_t.
- * \brief
- * Direct use of this structure by clients is forbidden. timer implementations
- * may change the structure. 'magic' must be ISCAPI_TIMERMGR_MAGIC for any
- * of the isc_timer_ routines to work. timer implementations must maintain
- * all timer invariants.
- */
-struct isc_timermgr {
- unsigned int impmagic;
- unsigned int magic;
-};
-
-#define ISCAPI_TIMERMGR_MAGIC ISC_MAGIC('A','t','m','g')
-#define ISCAPI_TIMERMGR_VALID(m) ((m) != NULL && \
- (m)->magic == ISCAPI_TIMERMGR_MAGIC)
-
-/*%
- * This is the common prefix of a timer object. The same note as
- * that for the timermgr structure applies.
- */
-struct isc_timer {
- unsigned int impmagic;
- unsigned int magic;
-};
-
-#define ISCAPI_TIMER_MAGIC ISC_MAGIC('A','t','m','r')
-#define ISCAPI_TIMER_VALID(s) ((s) != NULL && \
- (s)->magic == ISCAPI_TIMER_MAGIC)
-
/***
*** Timer and Timer Manager Functions
***
diff --git a/usr.bin/dig/lib/isc/lex.c b/usr.bin/dig/lib/isc/lex.c
index 439eef3beac..22aaaad37d8 100644
--- a/usr.bin/dig/lib/isc/lex.c
+++ b/usr.bin/dig/lib/isc/lex.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: lex.c,v 1.4 2020/02/17 19:45:00 jung Exp $ */
+/* $Id: lex.c,v 1.5 2020/02/18 18:11:27 florian Exp $ */
/*! \file */
@@ -50,12 +50,8 @@ typedef struct inputsource {
ISC_LINK(struct inputsource) link;
} inputsource;
-#define LEX_MAGIC ISC_MAGIC('L', 'e', 'x', '!')
-#define VALID_LEX(l) ISC_MAGIC_VALID(l, LEX_MAGIC)
-
struct isc_lex {
/* Unlocked. */
- unsigned int magic;
size_t max_token;
char * data;
unsigned int comments;
@@ -113,7 +109,6 @@ isc_lex_create(size_t max_token, isc_lex_t **lexp) {
lex->saved_paren_count = 0;
memset(lex->specials, 0, 256);
INIT_LIST(lex->sources);
- lex->magic = LEX_MAGIC;
*lexp = lex;
@@ -130,13 +125,11 @@ isc_lex_destroy(isc_lex_t **lexp) {
REQUIRE(lexp != NULL);
lex = *lexp;
- REQUIRE(VALID_LEX(lex));
while (!EMPTY(lex->sources))
RUNTIME_CHECK(isc_lex_close(lex) == ISC_R_SUCCESS);
if (lex->data != NULL)
free(lex->data);
- lex->magic = 0;
free(lex);
*lexp = NULL;
@@ -148,7 +141,6 @@ isc_lex_setcomments(isc_lex_t *lex, unsigned int comments) {
* Set allowed lexer commenting styles.
*/
- REQUIRE(VALID_LEX(lex));
lex->comments = comments;
}
@@ -160,7 +152,6 @@ isc_lex_setspecials(isc_lex_t *lex, isc_lexspecials_t specials) {
* whitespace, they delimit strings and numbers.
*/
- REQUIRE(VALID_LEX(lex));
memmove(lex->specials, specials, 256);
}
@@ -210,7 +201,6 @@ isc_lex_openfile(isc_lex_t *lex, const char *filename) {
* Open 'filename' and make it the current input source for 'lex'.
*/
- REQUIRE(VALID_LEX(lex));
if ((stream = fopen(filename, "r")) == NULL)
return (isc__errno2result(errno));
@@ -229,7 +219,6 @@ isc_lex_close(isc_lex_t *lex) {
* Close the most recently opened object (i.e. file or buffer).
*/
- REQUIRE(VALID_LEX(lex));
source = HEAD(lex->sources);
if (source == NULL)
@@ -318,7 +307,6 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) {
* Get the next token.
*/
- REQUIRE(VALID_LEX(lex));
source = HEAD(lex->sources);
REQUIRE(tokenp != NULL);
@@ -802,7 +790,6 @@ isc_lex_ungettoken(isc_lex_t *lex, isc_token_t *tokenp) {
* Unget the current token.
*/
- REQUIRE(VALID_LEX(lex));
source = HEAD(lex->sources);
REQUIRE(source != NULL);
REQUIRE(tokenp != NULL);
@@ -822,7 +809,6 @@ isc_lex_getlasttokentext(isc_lex_t *lex, isc_token_t *tokenp, isc_region_t *r)
{
inputsource *source;
- REQUIRE(VALID_LEX(lex));
source = HEAD(lex->sources);
REQUIRE(source != NULL);
REQUIRE(tokenp != NULL);
@@ -843,7 +829,6 @@ char *
isc_lex_getsourcename(isc_lex_t *lex) {
inputsource *source;
- REQUIRE(VALID_LEX(lex));
source = HEAD(lex->sources);
if (source == NULL)
@@ -856,7 +841,6 @@ unsigned long
isc_lex_getsourceline(isc_lex_t *lex) {
inputsource *source;
- REQUIRE(VALID_LEX(lex));
source = HEAD(lex->sources);
if (source == NULL)
@@ -869,8 +853,6 @@ isc_boolean_t
isc_lex_isfile(isc_lex_t *lex) {
inputsource *source;
- REQUIRE(VALID_LEX(lex));
-
source = HEAD(lex->sources);
if (source == NULL)
diff --git a/usr.bin/dig/lib/isc/log.c b/usr.bin/dig/lib/isc/log.c
index 820a3e9ad3d..857c1f69a3a 100644
--- a/usr.bin/dig/lib/isc/log.c
+++ b/usr.bin/dig/lib/isc/log.c
@@ -14,28 +14,20 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: log.c,v 1.14 2020/02/17 18:58:39 jung Exp $ */
+/* $Id: log.c,v 1.15 2020/02/18 18:11:27 florian Exp $ */
/*! \file
* \author Principal Authors: DCL */
-
-#include <stdlib.h>
#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
#include <syslog.h>
#include <isc/log.h>
-#include <isc/magic.h>
-#include <string.h>
#include <isc/time.h>
#include <isc/util.h>
-#define LCTX_MAGIC ISC_MAGIC('L', 'c', 't', 'x')
-#define VALID_CONTEXT(lctx) ISC_MAGIC_VALID(lctx, LCTX_MAGIC)
-
-#define LCFG_MAGIC ISC_MAGIC('L', 'c', 'f', 'g')
-#define VALID_CONFIG(lcfg) ISC_MAGIC_VALID(lcfg, LCFG_MAGIC)
-
/*
* XXXDCL make dynamic?
*/
@@ -97,7 +89,6 @@ struct isc_logmessage {
* into a program, or the debug_level which is dynamic state information.
*/
struct isc_logconfig {
- unsigned int magic;
isc_log_t * lctx;
ISC_LIST(isc_logchannel_t) channels;
ISC_LIST(isc_logchannellist_t) *channellists;
@@ -127,7 +118,6 @@ struct isc_logconfig {
*/
struct isc_log {
/* Not locked. */
- unsigned int magic;
isc_logcategory_t * categories;
unsigned int category_count;
isc_logmodule_t * modules;
@@ -257,15 +247,6 @@ isc_log_create(isc_log_t **lctxp, isc_logconfig_t **lcfgp) {
ISC_LIST_INIT(lctx->messages);
- /*
- * Normally setting the magic number is the last step done
- * in a creation function, but a valid log context is needed
- * by isc_log_registercategories and isc_logconfig_create.
- * If either fails, the lctx is destroyed and not returned
- * to the caller.
- */
- lctx->magic = LCTX_MAGIC;
-
isc_log_registercategories(lctx, isc_categories);
isc_log_registermodules(lctx, isc_modules);
result = isc_logconfig_create(lctx, &lcfg);
@@ -301,7 +282,6 @@ isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp) {
int level = ISC_LOG_INFO;
REQUIRE(lcfgp != NULL && *lcfgp == NULL);
- REQUIRE(VALID_CONTEXT(lctx));
lcfg = malloc(sizeof(*lcfg));
@@ -316,14 +296,6 @@ isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp) {
ISC_LIST_INIT(lcfg->channels);
- /*
- * Normally the magic number is the last thing set in the
- * structure, but isc_log_createchannel() needs a valid
- * config. If the channel creation fails, the lcfg is not
- * returned to the caller.
- */
- lcfg->magic = LCFG_MAGIC;
-
} else
result = ISC_R_NOMEMORY;
@@ -391,7 +363,7 @@ isc_log_destroy(isc_log_t **lctxp) {
isc_logconfig_t *lcfg;
isc_logmessage_t *message;
- REQUIRE(lctxp != NULL && VALID_CONTEXT(*lctxp));
+ REQUIRE(lctxp != NULL);
lctx = *lctxp;
if (lctx->logconfig != NULL) {
@@ -412,10 +384,7 @@ isc_log_destroy(isc_log_t **lctxp) {
lctx->category_count = 0;
lctx->modules = NULL;
lctx->module_count = 0;
- lctx->magic = 0;
-
free(lctx);
-
*lctxp = NULL;
}
@@ -426,7 +395,7 @@ isc_logconfig_destroy(isc_logconfig_t **lcfgp) {
isc_logchannellist_t *item;
unsigned int i;
- REQUIRE(lcfgp != NULL && VALID_CONFIG(*lcfgp));
+ REQUIRE(lcfgp != NULL);
lcfg = *lcfgp;
@@ -458,10 +427,7 @@ isc_logconfig_destroy(isc_logconfig_t **lcfgp) {
lcfg->tag = NULL;
lcfg->highest_level = 0;
lcfg->duplicate_interval = 0;
- lcfg->magic = 0;
-
free(lcfg);
-
*lcfgp = NULL;
}
@@ -469,7 +435,6 @@ void
isc_log_registercategories(isc_log_t *lctx, isc_logcategory_t categories[]) {
isc_logcategory_t *catp;
- REQUIRE(VALID_CONTEXT(lctx));
REQUIRE(categories != NULL && categories[0].name != NULL);
/*
@@ -513,7 +478,6 @@ void
isc_log_registermodules(isc_log_t *lctx, isc_logmodule_t modules[]) {
isc_logmodule_t *modp;
- REQUIRE(VALID_CONTEXT(lctx));
REQUIRE(modules != NULL && modules[0].name != NULL);
/*
@@ -561,7 +525,6 @@ isc_log_createchannel(isc_logconfig_t *lcfg, const char *name,
{
isc_logchannel_t *channel;
- REQUIRE(VALID_CONFIG(lcfg));
REQUIRE(name != NULL);
REQUIRE(type == ISC_LOG_TOSYSLOG ||
type == ISC_LOG_TOFILEDESC || type == ISC_LOG_TONULL);
@@ -631,7 +594,6 @@ isc_log_usechannel(isc_logconfig_t *lcfg, const char *name,
isc_result_t result = ISC_R_SUCCESS;
unsigned int i;
- REQUIRE(VALID_CONFIG(lcfg));
REQUIRE(name != NULL);
lctx = lcfg->lctx;
@@ -686,7 +648,6 @@ isc_log_setcontext(isc_log_t *lctx) {
void
isc_log_setdebuglevel(isc_log_t *lctx, unsigned int level) {
- REQUIRE(VALID_CONTEXT(lctx));
lctx->debug_level = level;
}
@@ -703,8 +664,6 @@ assignchannel(isc_logconfig_t *lcfg, unsigned int category_id,
isc_log_t *lctx;
isc_result_t result;
- REQUIRE(VALID_CONFIG(lcfg));
-
lctx = lcfg->lctx;
REQUIRE(category_id < lctx->category_count);
@@ -752,8 +711,6 @@ sync_channellist(isc_logconfig_t *lcfg) {
isc_log_t *lctx;
void *lists;
- REQUIRE(VALID_CONFIG(lcfg));
-
lctx = lcfg->lctx;
REQUIRE(lctx->category_count != 0);
@@ -822,7 +779,6 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
isc_logchannel_t *channel;
isc_logchannellist_t *category_channels;
- REQUIRE(lctx == NULL || VALID_CONTEXT(lctx));
REQUIRE(category != NULL);
REQUIRE(module != NULL);
REQUIRE(level != ISC_LOG_DYNAMIC);
diff --git a/usr.bin/dig/lib/isc/socket_api.c b/usr.bin/dig/lib/isc/socket_api.c
deleted file mode 100644
index 92d40346fd2..00000000000
--- a/usr.bin/dig/lib/isc/socket_api.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* $Id: socket_api.c,v 1.1 2020/02/07 09:58:54 florian Exp $ */
-
-
-
-#include <isc/app.h>
-#include <isc/magic.h>
-#include <isc/socket.h>
-#include <isc/util.h>
-
-isc_result_t
-isc_socketmgr_create(isc_socketmgr_t **managerp) {
- return (isc__socketmgr_create(managerp));
-}
-
-void
-isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
- REQUIRE(managerp != NULL && ISCAPI_SOCKETMGR_VALID(*managerp));
-
- isc__socketmgr_destroy(managerp);
-
- ENSURE(*managerp == NULL);
-}
-
-isc_result_t
-isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
- isc_socket_t **socketp)
-{
- REQUIRE(ISCAPI_SOCKETMGR_VALID(manager));
-
- return (isc__socket_create(manager, pf, type, socketp));
-}
-
-void
-isc_socket_attach(isc_socket_t *sock, isc_socket_t **socketp) {
- REQUIRE(ISCAPI_SOCKET_VALID(sock));
- REQUIRE(socketp != NULL && *socketp == NULL);
-
- isc__socket_attach(sock, socketp);
-
- ENSURE(*socketp == sock);
-}
-
-void
-isc_socket_detach(isc_socket_t **socketp) {
- REQUIRE(socketp != NULL && ISCAPI_SOCKET_VALID(*socketp));
-
- isc__socket_detach(socketp);
-
- ENSURE(*socketp == NULL);
-}
-
-isc_result_t
-isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr,
- unsigned int options)
-{
- REQUIRE(ISCAPI_SOCKET_VALID(sock));
-
- return (isc__socket_bind(sock, sockaddr, options));
-}
-
-isc_result_t
-isc_socket_connect(isc_socket_t *sock, isc_sockaddr_t *addr, isc_task_t *task,
- isc_taskaction_t action, void *arg)
-{
- REQUIRE(ISCAPI_SOCKET_VALID(sock));
-
- return (isc__socket_connect(sock, addr, task, action, arg));
-}
-
-void
-isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) {
- REQUIRE(ISCAPI_SOCKET_VALID(sock));
-
- isc__socket_cancel(sock, task, how);
-}
-
-isc_result_t
-isc_socket_recvv(isc_socket_t *sock, isc_bufferlist_t *buflist,
- unsigned int minimum, isc_task_t *task,
- isc_taskaction_t action, void *arg)
-{
- return (isc__socket_recvv(sock, buflist, minimum, task, action, arg));
-}
-
-isc_result_t
-isc_socket_sendv(isc_socket_t *sock, isc_bufferlist_t *buflist,
- isc_task_t *task, isc_taskaction_t action, void *arg)
-{
- return (isc__socket_sendv(sock, buflist, task, action, arg));
-}
-
-isc_result_t
-isc_socket_sendtov2(isc_socket_t *sock, isc_bufferlist_t *buflist,
- isc_task_t *task, isc_taskaction_t action, void *arg,
- isc_sockaddr_t *address, struct in6_pktinfo *pktinfo,
- unsigned int flags)
-{
- return (isc__socket_sendtov2(sock, buflist, task, action, arg,
- address, pktinfo, flags));
-}
diff --git a/usr.bin/dig/lib/isc/symtab.c b/usr.bin/dig/lib/isc/symtab.c
index e9392002020..616afff494d 100644
--- a/usr.bin/dig/lib/isc/symtab.c
+++ b/usr.bin/dig/lib/isc/symtab.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: symtab.c,v 1.2 2020/02/17 18:58:39 jung Exp $ */
+/* $Id: symtab.c,v 1.3 2020/02/18 18:11:27 florian Exp $ */
/*! \file */
@@ -22,7 +22,6 @@
#include <ctype.h>
#include <stdlib.h>
-#include <isc/magic.h>
#include <string.h>
#include <isc/symtab.h>
#include <isc/util.h>
@@ -36,12 +35,8 @@ typedef struct elt {
typedef LIST(elt_t) eltlist_t;
-#define SYMTAB_MAGIC ISC_MAGIC('S', 'y', 'm', 'T')
-#define VALID_SYMTAB(st) ISC_MAGIC_VALID(st, SYMTAB_MAGIC)
-
struct isc_symtab {
/* Unlocked. */
- unsigned int magic;
unsigned int size;
unsigned int count;
unsigned int maxload;
@@ -81,10 +76,7 @@ isc_symtab_create(unsigned int size,
symtab->undefine_action = undefine_action;
symtab->undefine_arg = undefine_arg;
symtab->case_sensitive = case_sensitive;
- symtab->magic = SYMTAB_MAGIC;
-
*symtabp = symtab;
-
return (ISC_R_SUCCESS);
}
@@ -96,7 +88,6 @@ isc_symtab_destroy(isc_symtab_t **symtabp) {
REQUIRE(symtabp != NULL);
symtab = *symtabp;
- REQUIRE(VALID_SYMTAB(symtab));
for (i = 0; i < symtab->size; i++) {
for (elt = HEAD(symtab->table[i]); elt != NULL; elt = nelt) {
@@ -110,9 +101,7 @@ isc_symtab_destroy(isc_symtab_t **symtabp) {
}
}
free(symtab->table);
- symtab->magic = 0;
free(symtab);
-
*symtabp = NULL;
}
@@ -165,7 +154,6 @@ isc_symtab_lookup(isc_symtab_t *symtab, const char *key, unsigned int type,
unsigned int bucket;
elt_t *elt;
- REQUIRE(VALID_SYMTAB(symtab));
REQUIRE(key != NULL);
FIND(symtab, key, type, bucket, elt);
@@ -225,7 +213,6 @@ isc_symtab_define(isc_symtab_t *symtab, const char *key, unsigned int type,
unsigned int bucket;
elt_t *elt;
- REQUIRE(VALID_SYMTAB(symtab));
REQUIRE(key != NULL);
REQUIRE(type != 0);
diff --git a/usr.bin/dig/lib/isc/task.c b/usr.bin/dig/lib/isc/task.c
index 95ea423d6fc..e9e9ae5c9e1 100644
--- a/usr.bin/dig/lib/isc/task.c
+++ b/usr.bin/dig/lib/isc/task.c
@@ -28,7 +28,6 @@
#include <time.h>
#include <isc/event.h>
-#include <isc/magic.h>
#include <isc/task.h>
#include <isc/util.h>
@@ -43,16 +42,12 @@ typedef enum {
task_state_done
} task_state_t;
-#define TASK_MAGIC ISC_MAGIC('T', 'A', 'S', 'K')
-#define VALID_TASK(t) ISC_MAGIC_VALID(t, TASK_MAGIC)
+typedef struct isc_task isc_task_t;
+typedef struct isc_taskmgr isc_taskmgr_t;
-typedef struct isc__task isc__task_t;
-typedef struct isc__taskmgr isc__taskmgr_t;
-
-struct isc__task {
+struct isc_task {
/* Not locked. */
- isc_task_t common;
- isc__taskmgr_t * manager;
+ isc_taskmgr_t * manager;
/* Locked by task lock. */
task_state_t state;
unsigned int references;
@@ -65,9 +60,9 @@ struct isc__task {
char name[16];
void * tag;
/* Locked by task manager lock. */
- LINK(isc__task_t) link;
- LINK(isc__task_t) ready_link;
- LINK(isc__task_t) ready_priority_link;
+ LINK(isc_task_t) link;
+ LINK(isc_task_t) ready_link;
+ LINK(isc_task_t) ready_priority_link;
};
#define TASK_F_SHUTTINGDOWN 0x01
@@ -76,19 +71,15 @@ struct isc__task {
#define TASK_SHUTTINGDOWN(t) (((t)->flags & TASK_F_SHUTTINGDOWN) \
!= 0)
-#define TASK_MANAGER_MAGIC ISC_MAGIC('T', 'S', 'K', 'M')
-#define VALID_MANAGER(m) ISC_MAGIC_VALID(m, TASK_MANAGER_MAGIC)
-
-typedef ISC_LIST(isc__task_t) isc__tasklist_t;
+typedef ISC_LIST(isc_task_t) isc_tasklist_t;
-struct isc__taskmgr {
+struct isc_taskmgr {
/* Not locked. */
- isc_taskmgr_t common;
/* Locked by task manager lock. */
unsigned int default_quantum;
- LIST(isc__task_t) tasks;
- isc__tasklist_t ready_tasks;
- isc__tasklist_t ready_priority_tasks;
+ LIST(isc_task_t) tasks;
+ isc_tasklist_t ready_tasks;
+ isc_tasklist_t ready_priority_tasks;
isc_taskmgrmode_t mode;
unsigned int tasks_running;
unsigned int tasks_ready;
@@ -101,7 +92,7 @@ struct isc__taskmgr {
* to protect the access. We can't use 'lock' since isc_task_detach()
* will try to acquire it.
*/
- isc__task_t *excl;
+ isc_task_t *excl;
unsigned int refs;
};
@@ -109,93 +100,26 @@ struct isc__taskmgr {
#define DEFAULT_DEFAULT_QUANTUM 5
#define FINISHED(m) ((m)->exiting && EMPTY((m)->tasks))
-static isc__taskmgr_t *taskmgr = NULL;
-
-/*%
- * The following are intended for internal use (indicated by "isc__"
- * prefix) but are not declared as static, allowing direct access from
- * unit tests etc.
- */
-
-isc_result_t
-isc__task_create(isc_taskmgr_t *manager0, unsigned int quantum,
- isc_task_t **taskp);
-void
-isc__task_attach(isc_task_t *source0, isc_task_t **targetp);
-void
-isc__task_detach(isc_task_t **taskp);
-void
-isc__task_send(isc_task_t *task0, isc_event_t **eventp);
-void
-isc__task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp);
-unsigned int
-isc__task_purgerange(isc_task_t *task0, void *sender, isc_eventtype_t first,
- isc_eventtype_t last, void *tag);
-unsigned int
-isc__task_purge(isc_task_t *task, void *sender, isc_eventtype_t type,
- void *tag);
-isc_boolean_t
-isc_task_purgeevent(isc_task_t *task0, isc_event_t *event);
-unsigned int
-isc__task_unsendrange(isc_task_t *task, void *sender, isc_eventtype_t first,
- isc_eventtype_t last, void *tag,
- isc_eventlist_t *events);
-unsigned int
-isc__task_unsend(isc_task_t *task, void *sender, isc_eventtype_t type,
- void *tag, isc_eventlist_t *events);
-isc_result_t
-isc__task_onshutdown(isc_task_t *task0, isc_taskaction_t action,
- void *arg);
-void
-isc__task_shutdown(isc_task_t *task0);
-void
-isc__task_destroy(isc_task_t **taskp);
-void
-isc__task_setname(isc_task_t *task0, const char *name, void *tag);
-const char *
-isc__task_getname(isc_task_t *task0);
-void *
-isc__task_gettag(isc_task_t *task0);
-void
-isc__task_getcurrenttime(isc_task_t *task0, time_t *t);
-isc_result_t
-isc__taskmgr_create(unsigned int workers,
- unsigned int default_quantum, isc_taskmgr_t **managerp);
-void
-isc__taskmgr_destroy(isc_taskmgr_t **managerp);
-void
-isc_taskmgr_setexcltask(isc_taskmgr_t *mgr0, isc_task_t *task0);
-isc_result_t
-isc_taskmgr_excltask(isc_taskmgr_t *mgr0, isc_task_t **taskp);
-isc_result_t
-isc__task_beginexclusive(isc_task_t *task);
-void
-isc__task_endexclusive(isc_task_t *task0);
-void
-isc__task_setprivilege(isc_task_t *task0, isc_boolean_t priv);
-isc_boolean_t
-isc__task_privilege(isc_task_t *task0);
-void
-isc__taskmgr_setmode(isc_taskmgr_t *manager0, isc_taskmgrmode_t mode);
-isc_taskmgrmode_t
-isc__taskmgr_mode(isc_taskmgr_t *manager0);
+static isc_taskmgr_t *taskmgr = NULL;
static inline isc_boolean_t
-empty_readyq(isc__taskmgr_t *manager);
+empty_readyq(isc_taskmgr_t *manager);
-static inline isc__task_t *
-pop_readyq(isc__taskmgr_t *manager);
+static inline isc_task_t *
+pop_readyq(isc_taskmgr_t *manager);
static inline void
-push_readyq(isc__taskmgr_t *manager, isc__task_t *task);
+push_readyq(isc_taskmgr_t *manager, isc_task_t *task);
+
+
/***
*** Tasks.
***/
static void
-task_finished(isc__task_t *task) {
- isc__taskmgr_t *manager = task->manager;
+task_finished(isc_task_t *task) {
+ isc_taskmgr_t *manager = task->manager;
REQUIRE(EMPTY(task->events));
REQUIRE(task->nevents == 0);
@@ -205,20 +129,16 @@ task_finished(isc__task_t *task) {
UNLINK(manager->tasks, task, link);
- task->common.impmagic = 0;
- task->common.magic = 0;
free(task);
}
isc_result_t
-isc__task_create(isc_taskmgr_t *manager0, unsigned int quantum,
+isc_task_create(isc_taskmgr_t *manager, unsigned int quantum,
isc_task_t **taskp)
{
- isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
- isc__task_t *task;
+ isc_task_t *task;
isc_boolean_t exiting;
- REQUIRE(VALID_MANAGER(manager));
REQUIRE(taskp != NULL && *taskp == NULL);
task = malloc(sizeof(*task));
@@ -252,22 +172,18 @@ isc__task_create(isc_taskmgr_t *manager0, unsigned int quantum,
return (ISC_R_SHUTTINGDOWN);
}
- task->common.magic = ISCAPI_TASK_MAGIC;
- task->common.impmagic = TASK_MAGIC;
*taskp = (isc_task_t *)task;
-
return (ISC_R_SUCCESS);
}
void
-isc__task_attach(isc_task_t *source0, isc_task_t **targetp) {
- isc__task_t *source = (isc__task_t *)source0;
+isc_task_attach(isc_task_t *source0, isc_task_t **targetp) {
+ isc_task_t *source = (isc_task_t *)source0;
/*
* Attach *targetp to source.
*/
- REQUIRE(VALID_TASK(source));
REQUIRE(targetp != NULL && *targetp == NULL);
source->references++;
@@ -276,7 +192,7 @@ isc__task_attach(isc_task_t *source0, isc_task_t **targetp) {
}
static inline isc_boolean_t
-task_shutdown(isc__task_t *task) {
+task_shutdown(isc_task_t *task) {
isc_boolean_t was_idle = ISC_FALSE;
isc_event_t *event, *prev;
@@ -316,17 +232,16 @@ task_shutdown(isc__task_t *task) {
* Caller must NOT hold manager lock.
*/
static inline void
-task_ready(isc__task_t *task) {
- isc__taskmgr_t *manager = task->manager;
+task_ready(isc_task_t *task) {
+ isc_taskmgr_t *manager = task->manager;
- REQUIRE(VALID_MANAGER(manager));
REQUIRE(task->state == task_state_ready);
push_readyq(manager, task);
}
static inline isc_boolean_t
-task_detach(isc__task_t *task) {
+task_detach(isc_task_t *task) {
/*
* Caller must be holding the task lock.
@@ -353,8 +268,8 @@ task_detach(isc__task_t *task) {
}
void
-isc__task_detach(isc_task_t **taskp) {
- isc__task_t *task;
+isc_task_detach(isc_task_t **taskp) {
+ isc_task_t *task;
isc_boolean_t was_idle;
/*
@@ -362,8 +277,7 @@ isc__task_detach(isc_task_t **taskp) {
*/
REQUIRE(taskp != NULL);
- task = (isc__task_t *)*taskp;
- REQUIRE(VALID_TASK(task));
+ task = (isc_task_t *)*taskp;
was_idle = task_detach(task);
@@ -374,7 +288,7 @@ isc__task_detach(isc_task_t **taskp) {
}
static inline isc_boolean_t
-task_send(isc__task_t *task, isc_event_t **eventp) {
+task_send(isc_task_t *task, isc_event_t **eventp) {
isc_boolean_t was_idle = ISC_FALSE;
isc_event_t *event;
@@ -404,15 +318,13 @@ task_send(isc__task_t *task, isc_event_t **eventp) {
}
void
-isc__task_send(isc_task_t *task0, isc_event_t **eventp) {
- isc__task_t *task = (isc__task_t *)task0;
+isc_task_send(isc_task_t *task, isc_event_t **eventp) {
isc_boolean_t was_idle;
/*
* Send '*event' to 'task'.
*/
- REQUIRE(VALID_TASK(task));
/*
* We're trying hard to hold locks for as short a time as possible.
@@ -442,9 +354,9 @@ isc__task_send(isc_task_t *task0, isc_event_t **eventp) {
}
void
-isc__task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp) {
+isc_task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp) {
isc_boolean_t idle1, idle2;
- isc__task_t *task;
+ isc_task_t *task;
/*
* Send '*event' to '*taskp' and then detach '*taskp' from its
@@ -452,8 +364,7 @@ isc__task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp) {
*/
REQUIRE(taskp != NULL);
- task = (isc__task_t *)*taskp;
- REQUIRE(VALID_TASK(task));
+ task = (isc_task_t *)*taskp;
idle1 = task_send(task, eventp);
idle2 = task_detach(task);
@@ -474,14 +385,13 @@ isc__task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp) {
#define PURGE_OK(event) (((event)->ev_attributes & ISC_EVENTATTR_NOPURGE) == 0)
static unsigned int
-dequeue_events(isc__task_t *task, void *sender, isc_eventtype_t first,
+dequeue_events(isc_task_t *task, void *sender, isc_eventtype_t first,
isc_eventtype_t last, void *tag,
isc_eventlist_t *events, isc_boolean_t purging)
{
isc_event_t *event, *next_event;
unsigned int count = 0;
- REQUIRE(VALID_TASK(task));
REQUIRE(last >= first);
/*
@@ -509,10 +419,9 @@ dequeue_events(isc__task_t *task, void *sender, isc_eventtype_t first,
}
unsigned int
-isc__task_purgerange(isc_task_t *task0, void *sender, isc_eventtype_t first,
+isc_task_purgerange(isc_task_t *task, void *sender, isc_eventtype_t first,
isc_eventtype_t last, void *tag)
{
- isc__task_t *task = (isc__task_t *)task0;
unsigned int count;
isc_eventlist_t events;
isc_event_t *event, *next_event;
@@ -539,20 +448,8 @@ isc__task_purgerange(isc_task_t *task0, void *sender, isc_eventtype_t first,
return (count);
}
-unsigned int
-isc__task_purge(isc_task_t *task, void *sender, isc_eventtype_t type,
- void *tag)
-{
- /*
- * Purge events from a task's event queue.
- */
-
- return (isc__task_purgerange(task, sender, type, type, tag));
-}
-
isc_boolean_t
-isc_task_purgeevent(isc_task_t *task0, isc_event_t *event) {
- isc__task_t *task = (isc__task_t *)task0;
+isc_task_purgeevent(isc_task_t *task, isc_event_t *event) {
isc_event_t *curr_event, *next_event;
/*
@@ -561,7 +458,6 @@ isc_task_purgeevent(isc_task_t *task0, isc_event_t *event) {
* XXXRTH: WARNING: This method may be removed before beta.
*/
- REQUIRE(VALID_TASK(task));
/*
* If 'event' is on the task's event queue, it will be purged,
@@ -593,7 +489,7 @@ isc_task_purgeevent(isc_task_t *task0, isc_event_t *event) {
}
unsigned int
-isc__task_unsendrange(isc_task_t *task, void *sender, isc_eventtype_t first,
+isc_task_unsendrange(isc_task_t *task, void *sender, isc_eventtype_t first,
isc_eventtype_t last, void *tag,
isc_eventlist_t *events)
{
@@ -601,69 +497,30 @@ isc__task_unsendrange(isc_task_t *task, void *sender, isc_eventtype_t first,
* Remove events from a task's event queue.
*/
- return (dequeue_events((isc__task_t *)task, sender, first,
+ return (dequeue_events((isc_task_t *)task, sender, first,
last, tag, events, ISC_FALSE));
}
unsigned int
-isc__task_unsend(isc_task_t *task, void *sender, isc_eventtype_t type,
+isc_task_unsend(isc_task_t *task, void *sender, isc_eventtype_t type,
void *tag, isc_eventlist_t *events)
{
/*
* Remove events from a task's event queue.
*/
- return (dequeue_events((isc__task_t *)task, sender, type,
+ return (dequeue_events((isc_task_t *)task, sender, type,
type, tag, events, ISC_FALSE));
}
-isc_result_t
-isc__task_onshutdown(isc_task_t *task0, isc_taskaction_t action,
- void *arg)
-{
- isc__task_t *task = (isc__task_t *)task0;
- isc_boolean_t disallowed = ISC_FALSE;
- isc_result_t result = ISC_R_SUCCESS;
- isc_event_t *event;
-
- /*
- * Send a shutdown event with action 'action' and argument 'arg' when
- * 'task' is shutdown.
- */
-
- REQUIRE(VALID_TASK(task));
- REQUIRE(action != NULL);
-
- event = isc_event_allocate(NULL,
- ISC_TASKEVENT_SHUTDOWN,
- action,
- arg,
- sizeof(*event));
- if (event == NULL)
- return (ISC_R_NOMEMORY);
-
- if (TASK_SHUTTINGDOWN(task)) {
- disallowed = ISC_TRUE;
- result = ISC_R_SHUTTINGDOWN;
- } else
- ENQUEUE(task->on_shutdown, event, ev_link);
-
- if (disallowed)
- free(event);
-
- return (result);
-}
-
void
-isc__task_shutdown(isc_task_t *task0) {
- isc__task_t *task = (isc__task_t *)task0;
+isc_task_shutdown(isc_task_t *task) {
isc_boolean_t was_idle;
/*
* Shutdown 'task'.
*/
- REQUIRE(VALID_TASK(task));
was_idle = task_shutdown(task);
@@ -672,60 +529,26 @@ isc__task_shutdown(isc_task_t *task0) {
}
void
-isc__task_destroy(isc_task_t **taskp) {
-
- /*
- * Destroy '*taskp'.
- */
-
- REQUIRE(taskp != NULL);
-
- isc_task_shutdown(*taskp);
- isc_task_detach(taskp);
-}
-
-void
-isc__task_setname(isc_task_t *task0, const char *name, void *tag) {
- isc__task_t *task = (isc__task_t *)task0;
-
+isc_task_setname(isc_task_t *task, const char *name, void *tag) {
/*
* Name 'task'.
*/
- REQUIRE(VALID_TASK(task));
strlcpy(task->name, name, sizeof(task->name));
task->tag = tag;
}
const char *
-isc__task_getname(isc_task_t *task0) {
- isc__task_t *task = (isc__task_t *)task0;
-
- REQUIRE(VALID_TASK(task));
-
+isc_task_getname(isc_task_t *task) {
return (task->name);
}
void *
-isc__task_gettag(isc_task_t *task0) {
- isc__task_t *task = (isc__task_t *)task0;
-
- REQUIRE(VALID_TASK(task));
-
+isc_task_gettag(isc_task_t *task) {
return (task->tag);
}
-void
-isc__task_getcurrenttime(isc_task_t *task0, time_t *t) {
- isc__task_t *task = (isc__task_t *)task0;
-
- REQUIRE(VALID_TASK(task));
- REQUIRE(t != NULL);
-
- *t = task->now;
-}
-
/***
*** Task Manager.
***/
@@ -738,8 +561,8 @@ isc__task_getcurrenttime(isc_task_t *task0, time_t *t) {
* Caller must hold the task manager lock.
*/
static inline isc_boolean_t
-empty_readyq(isc__taskmgr_t *manager) {
- isc__tasklist_t queue;
+empty_readyq(isc_taskmgr_t *manager) {
+ isc_tasklist_t queue;
if (manager->mode == isc_taskmgrmode_normal)
queue = manager->ready_tasks;
@@ -757,9 +580,9 @@ empty_readyq(isc__taskmgr_t *manager) {
*
* Caller must hold the task manager lock.
*/
-static inline isc__task_t *
-pop_readyq(isc__taskmgr_t *manager) {
- isc__task_t *task;
+static inline isc_task_t *
+pop_readyq(isc_taskmgr_t *manager) {
+ isc_task_t *task;
if (manager->mode == isc_taskmgrmode_normal)
task = HEAD(manager->ready_tasks);
@@ -783,7 +606,7 @@ pop_readyq(isc__taskmgr_t *manager) {
* Caller must hold the task manager lock.
*/
static inline void
-push_readyq(isc__taskmgr_t *manager, isc__task_t *task) {
+push_readyq(isc_taskmgr_t *manager, isc_task_t *task) {
ENQUEUE(manager->ready_tasks, task, ready_link);
if ((task->flags & TASK_F_PRIVILEGED) != 0)
ENQUEUE(manager->ready_priority_tasks, task,
@@ -792,14 +615,13 @@ push_readyq(isc__taskmgr_t *manager, isc__task_t *task) {
}
static void
-dispatch(isc__taskmgr_t *manager) {
- isc__task_t *task;
+dispatch(isc_taskmgr_t *manager) {
+ isc_task_t *task;
unsigned int total_dispatch_count = 0;
- isc__tasklist_t new_ready_tasks;
- isc__tasklist_t new_priority_tasks;
+ isc_tasklist_t new_ready_tasks;
+ isc_tasklist_t new_priority_tasks;
unsigned int tasks_ready = 0;
- REQUIRE(VALID_MANAGER(manager));
ISC_LIST_INIT(new_ready_tasks);
ISC_LIST_INIT(new_priority_tasks);
@@ -817,8 +639,6 @@ dispatch(isc__taskmgr_t *manager) {
isc_boolean_t finished = ISC_FALSE;
isc_event_t *event;
- INSIST(VALID_TASK(task));
-
/*
* Note we only unlock the manager lock if we actually
* have a task to do. We must reacquire the manager
@@ -955,22 +775,18 @@ dispatch(isc__taskmgr_t *manager) {
}
static void
-manager_free(isc__taskmgr_t *manager) {
-
- manager->common.impmagic = 0;
- manager->common.magic = 0;
+manager_free(isc_taskmgr_t *manager) {
free(manager);
-
taskmgr = NULL;
}
isc_result_t
-isc__taskmgr_create(unsigned int workers,
+isc_taskmgr_create(unsigned int workers,
unsigned int default_quantum, isc_taskmgr_t **managerp)
{
isc_result_t result;
unsigned int i, started = 0;
- isc__taskmgr_t *manager;
+ isc_taskmgr_t *manager;
/*
* Create a new task manager.
@@ -993,8 +809,6 @@ isc__taskmgr_create(unsigned int workers,
manager = malloc(sizeof(*manager));
if (manager == NULL)
return (ISC_R_NOMEMORY);
- manager->common.impmagic = TASK_MANAGER_MAGIC;
- manager->common.magic = ISCAPI_TASKMGR_MAGIC;
manager->mode = isc_taskmgrmode_normal;
if (default_quantum == 0)
@@ -1022,9 +836,9 @@ isc__taskmgr_create(unsigned int workers,
}
void
-isc__taskmgr_destroy(isc_taskmgr_t **managerp) {
- isc__taskmgr_t *manager;
- isc__task_t *task;
+isc_taskmgr_destroy(isc_taskmgr_t **managerp) {
+ isc_taskmgr_t *manager;
+ isc_task_t *task;
unsigned int i;
/*
@@ -1032,8 +846,7 @@ isc__taskmgr_destroy(isc_taskmgr_t **managerp) {
*/
REQUIRE(managerp != NULL);
- manager = (isc__taskmgr_t *)*managerp;
- REQUIRE(VALID_MANAGER(manager));
+ manager = (isc_taskmgr_t *)*managerp;
UNUSED(i);
@@ -1055,7 +868,7 @@ isc__taskmgr_destroy(isc_taskmgr_t **managerp) {
* Detach the exclusive task before acquiring the manager lock
*/
if (manager->excl != NULL)
- isc__task_detach((isc_task_t **) &manager->excl);
+ isc_task_detach((isc_task_t **) &manager->excl);
/*
* Make sure we only get called once.
@@ -1081,8 +894,8 @@ isc__taskmgr_destroy(isc_taskmgr_t **managerp) {
/*
* Dispatch the shutdown events.
*/
- while (isc__taskmgr_ready((isc_taskmgr_t *)manager))
- (void)isc__taskmgr_dispatch((isc_taskmgr_t *)manager);
+ while (isc_taskmgr_ready((isc_taskmgr_t *)manager))
+ (void)isc_taskmgr_dispatch((isc_taskmgr_t *)manager);
INSIST(ISC_LIST_EMPTY(manager->tasks));
taskmgr = NULL;
@@ -1091,24 +904,8 @@ isc__taskmgr_destroy(isc_taskmgr_t **managerp) {
*managerp = NULL;
}
-void
-isc__taskmgr_setmode(isc_taskmgr_t *manager0, isc_taskmgrmode_t mode) {
- isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
-
- manager->mode = mode;
-}
-
-isc_taskmgrmode_t
-isc__taskmgr_mode(isc_taskmgr_t *manager0) {
- isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
- isc_taskmgrmode_t mode;
- mode = manager->mode;
- return (mode);
-}
-
isc_boolean_t
-isc__taskmgr_ready(isc_taskmgr_t *manager0) {
- isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
+isc_taskmgr_ready(isc_taskmgr_t *manager) {
isc_boolean_t is_ready;
if (manager == NULL)
@@ -1122,9 +919,7 @@ isc__taskmgr_ready(isc_taskmgr_t *manager0) {
}
isc_result_t
-isc__taskmgr_dispatch(isc_taskmgr_t *manager0) {
- isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
-
+isc_taskmgr_dispatch(isc_taskmgr_t *manager) {
if (manager == NULL)
manager = taskmgr;
if (manager == NULL)
@@ -1136,171 +931,25 @@ isc__taskmgr_dispatch(isc_taskmgr_t *manager0) {
}
void
-isc_taskmgr_setexcltask(isc_taskmgr_t *mgr0, isc_task_t *task0) {
- isc__taskmgr_t *mgr = (isc__taskmgr_t *) mgr0;
- isc__task_t *task = (isc__task_t *) task0;
+isc_taskmgr_setexcltask(isc_taskmgr_t *mgr0, isc_task_t *task) {
+ isc_taskmgr_t *mgr = (isc_taskmgr_t *) mgr0;
- REQUIRE(VALID_MANAGER(mgr));
- REQUIRE(VALID_TASK(task));
if (mgr->excl != NULL)
- isc__task_detach((isc_task_t **) &mgr->excl);
- isc__task_attach(task0, (isc_task_t **) &mgr->excl);
+ isc_task_detach((isc_task_t **) &mgr->excl);
+ isc_task_attach(task, (isc_task_t **) &mgr->excl);
}
isc_result_t
isc_taskmgr_excltask(isc_taskmgr_t *mgr0, isc_task_t **taskp) {
- isc__taskmgr_t *mgr = (isc__taskmgr_t *) mgr0;
+ isc_taskmgr_t *mgr = (isc_taskmgr_t *) mgr0;
isc_result_t result = ISC_R_SUCCESS;
- REQUIRE(VALID_MANAGER(mgr));
REQUIRE(taskp != NULL && *taskp == NULL);
if (mgr->excl != NULL)
- isc__task_attach((isc_task_t *) mgr->excl, taskp);
+ isc_task_attach((isc_task_t *) mgr->excl, taskp);
else
result = ISC_R_NOTFOUND;
return (result);
}
-
-isc_result_t
-isc__task_beginexclusive(isc_task_t *task0) {
- UNUSED(task0);
- return (ISC_R_SUCCESS);
-}
-
-void
-isc__task_endexclusive(isc_task_t *task0) {
- UNUSED(task0);
-}
-
-void
-isc__task_setprivilege(isc_task_t *task0, isc_boolean_t priv) {
- isc__task_t *task = (isc__task_t *)task0;
- isc__taskmgr_t *manager = task->manager;
- isc_boolean_t oldpriv;
-
- oldpriv = ISC_TF((task->flags & TASK_F_PRIVILEGED) != 0);
- if (priv)
- task->flags |= TASK_F_PRIVILEGED;
- else
- task->flags &= ~TASK_F_PRIVILEGED;
-
- if (priv == oldpriv)
- return;
-
- if (priv && ISC_LINK_LINKED(task, ready_link))
- ENQUEUE(manager->ready_priority_tasks, task,
- ready_priority_link);
- else if (!priv && ISC_LINK_LINKED(task, ready_priority_link))
- DEQUEUE(manager->ready_priority_tasks, task,
- ready_priority_link);
-}
-
-isc_boolean_t
-isc__task_privilege(isc_task_t *task0) {
- isc__task_t *task = (isc__task_t *)task0;
- isc_boolean_t priv;
-
- priv = ISC_TF((task->flags & TASK_F_PRIVILEGED) != 0);
- return (priv);
-}
-
-isc_result_t
-isc_taskmgr_create(unsigned int workers,
- unsigned int default_quantum, isc_taskmgr_t **managerp)
-{
- return (isc__taskmgr_create(workers, default_quantum, managerp));
-}
-
-void
-isc_taskmgr_destroy(isc_taskmgr_t **managerp) {
- REQUIRE(managerp != NULL && ISCAPI_TASKMGR_VALID(*managerp));
-
- isc__taskmgr_destroy(managerp);
-
- ENSURE(*managerp == NULL);
-}
-
-isc_result_t
-isc_task_create(isc_taskmgr_t *manager, unsigned int quantum,
- isc_task_t **taskp)
-{
- REQUIRE(ISCAPI_TASKMGR_VALID(manager));
- REQUIRE(taskp != NULL && *taskp == NULL);
-
- return (isc__task_create(manager, quantum, taskp));
-}
-
-void
-isc_task_attach(isc_task_t *source, isc_task_t **targetp) {
- REQUIRE(ISCAPI_TASK_VALID(source));
- REQUIRE(targetp != NULL && *targetp == NULL);
-
- isc__task_attach(source, targetp);
-
- ENSURE(*targetp == source);
-}
-
-void
-isc_task_detach(isc_task_t **taskp) {
- REQUIRE(taskp != NULL && ISCAPI_TASK_VALID(*taskp));
-
- isc__task_detach(taskp);
-
- ENSURE(*taskp == NULL);
-}
-
-void
-isc_task_send(isc_task_t *task, isc_event_t **eventp) {
- REQUIRE(ISCAPI_TASK_VALID(task));
- REQUIRE(eventp != NULL && *eventp != NULL);
-
- isc__task_send(task, eventp);
-}
-
-void
-isc_task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp) {
- REQUIRE(taskp != NULL && ISCAPI_TASK_VALID(*taskp));
- REQUIRE(eventp != NULL && *eventp != NULL);
-
- isc__task_sendanddetach(taskp, eventp);
-
- ENSURE(*taskp == NULL);
-}
-
-unsigned int
-isc_task_unsend(isc_task_t *task, void *sender, isc_eventtype_t type,
- void *tag, isc_eventlist_t *events)
-{
- REQUIRE(ISCAPI_TASK_VALID(task));
-
- return (isc__task_unsend(task, sender, type, tag, events));
-}
-
-void
-isc_task_shutdown(isc_task_t *task) {
- REQUIRE(ISCAPI_TASK_VALID(task));
-
- isc__task_shutdown(task);
-}
-
-void
-isc_task_setname(isc_task_t *task, const char *name, void *tag) {
- REQUIRE(ISCAPI_TASK_VALID(task));
-
- isc__task_setname(task, name, tag);
-}
-
-/*%
- * This is necessary for libisc's internal timer implementation. Other
- * implementation might skip implementing this.
- */
-unsigned int
-isc_task_purgerange(isc_task_t *task, void *sender, isc_eventtype_t first,
- isc_eventtype_t last, void *tag)
-{
- REQUIRE(ISCAPI_TASK_VALID(task));
-
- return (isc__task_purgerange(task, sender, first, last, tag));
-}
diff --git a/usr.bin/dig/lib/isc/task_p.h b/usr.bin/dig/lib/isc/task_p.h
index 35286f2372e..a0163a10cb3 100644
--- a/usr.bin/dig/lib/isc/task_p.h
+++ b/usr.bin/dig/lib/isc/task_p.h
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: task_p.h,v 1.1 2020/02/07 09:58:54 florian Exp $ */
+/* $Id: task_p.h,v 1.2 2020/02/18 18:11:27 florian Exp $ */
#ifndef ISC_TASK_P_H
#define ISC_TASK_P_H
@@ -22,9 +22,9 @@
/*! \file */
isc_boolean_t
-isc__taskmgr_ready(isc_taskmgr_t *taskmgr);
+isc_taskmgr_ready(isc_taskmgr_t *taskmgr);
isc_result_t
-isc__taskmgr_dispatch(isc_taskmgr_t *taskmgr);
+isc_taskmgr_dispatch(isc_taskmgr_t *taskmgr);
#endif /* ISC_TASK_P_H */
diff --git a/usr.bin/dig/lib/isc/timer.c b/usr.bin/dig/lib/isc/timer.c
index 20e472b99f9..b99db8147eb 100644
--- a/usr.bin/dig/lib/isc/timer.c
+++ b/usr.bin/dig/lib/isc/timer.c
@@ -14,14 +14,13 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: timer.c,v 1.18 2020/02/16 21:11:02 florian Exp $ */
+/* $Id: timer.c,v 1.19 2020/02/18 18:11:27 florian Exp $ */
/*! \file */
#include <stdlib.h>
#include <isc/heap.h>
-#include <isc/magic.h>
#include <isc/task.h>
#include <isc/time.h>
#include <isc/timer.h>
@@ -29,16 +28,12 @@
#include "timer_p.h"
-#define TIMER_MAGIC ISC_MAGIC('T', 'I', 'M', 'R')
-#define VALID_TIMER(t) ISC_MAGIC_VALID(t, TIMER_MAGIC)
+typedef struct isc_timer isc_timer_t;
+typedef struct isc_timermgr isc_timermgr_t;
-typedef struct isc__timer isc__timer_t;
-typedef struct isc__timermgr isc__timermgr_t;
-
-struct isc__timer {
+struct isc_timer {
/*! Not locked. */
- isc_timer_t common;
- isc__timermgr_t * manager;
+ isc_timermgr_t * manager;
/*! Locked by timer lock. */
unsigned int references;
struct timespec idle;
@@ -49,18 +44,14 @@ struct isc__timer {
void * arg;
unsigned int index;
struct timespec due;
- LINK(isc__timer_t) link;
+ LINK(isc_timer_t) link;
};
-#define TIMER_MANAGER_MAGIC ISC_MAGIC('T', 'I', 'M', 'M')
-#define VALID_MANAGER(m) ISC_MAGIC_VALID(m, TIMER_MANAGER_MAGIC)
-
-struct isc__timermgr {
+struct isc_timermgr {
/* Not locked. */
- isc_timermgr_t common;
/* Locked by manager lock. */
isc_boolean_t done;
- LIST(isc__timer_t) timers;
+ LIST(isc_timer_t) timers;
unsigned int nscheduled;
struct timespec due;
unsigned int refs;
@@ -73,33 +64,15 @@ struct isc__timermgr {
* unit tests etc.
*/
-isc_result_t
-isc__timer_create(isc_timermgr_t *manager, const struct timespec *interval,
- isc_task_t *task, isc_taskaction_t action, void *arg,
- isc_timer_t **timerp);
-isc_result_t
-isc__timer_reset(isc_timer_t *timer, const struct timespec *interval,
- isc_boolean_t purge);
-void
-isc__timer_touch(isc_timer_t *timer);
-void
-isc__timer_attach(isc_timer_t *timer0, isc_timer_t **timerp);
-void
-isc__timer_detach(isc_timer_t **timerp);
-isc_result_t
-isc__timermgr_create(isc_timermgr_t **managerp);
-void
-isc__timermgr_destroy(isc_timermgr_t **managerp);
-
/*!
* If the manager is supposed to be shared, there can be only one.
*/
-static isc__timermgr_t *timermgr = NULL;
+static isc_timermgr_t *timermgr = NULL;
static inline isc_result_t
-schedule(isc__timer_t *timer, struct timespec *now, isc_boolean_t signal_ok) {
+schedule(isc_timer_t *timer, struct timespec *now, isc_boolean_t signal_ok) {
isc_result_t result;
- isc__timermgr_t *manager;
+ isc_timermgr_t *manager;
struct timespec due;
/*!
@@ -152,8 +125,8 @@ schedule(isc__timer_t *timer, struct timespec *now, isc_boolean_t signal_ok) {
}
static inline void
-deschedule(isc__timer_t *timer) {
- isc__timermgr_t *manager;
+deschedule(isc_timer_t *timer) {
+ isc_timermgr_t *manager;
/*
* The caller must ensure locking.
@@ -169,8 +142,8 @@ deschedule(isc__timer_t *timer) {
}
static void
-destroy(isc__timer_t *timer) {
- isc__timermgr_t *manager = timer->manager;
+destroy(isc_timer_t *timer) {
+ isc_timermgr_t *manager = timer->manager;
/*
* The caller must ensure it is safe to destroy the timer.
@@ -185,18 +158,16 @@ destroy(isc__timer_t *timer) {
UNLINK(manager->timers, timer, link);
isc_task_detach(&timer->task);
- timer->common.impmagic = 0;
- timer->common.magic = 0;
free(timer);
}
isc_result_t
-isc__timer_create(isc_timermgr_t *manager0, const struct timespec *interval,
+isc_timer_create(isc_timermgr_t *manager0, const struct timespec *interval,
isc_task_t *task, isc_taskaction_t action, void *arg,
isc_timer_t **timerp)
{
- isc__timermgr_t *manager = (isc__timermgr_t *)manager0;
- isc__timer_t *timer;
+ isc_timermgr_t *manager = (isc_timermgr_t *)manager0;
+ isc_timer_t *timer;
isc_result_t result;
struct timespec now;
@@ -208,7 +179,6 @@ isc__timer_create(isc_timermgr_t *manager0, const struct timespec *interval,
* in 'timerp'.
*/
- REQUIRE(VALID_MANAGER(manager));
REQUIRE(task != NULL);
REQUIRE(action != NULL);
REQUIRE(interval != NULL);
@@ -247,16 +217,12 @@ isc__timer_create(isc_timermgr_t *manager0, const struct timespec *interval,
DE_CONST(arg, timer->arg);
timer->index = 0;
ISC_LINK_INIT(timer, link);
- timer->common.impmagic = TIMER_MAGIC;
- timer->common.magic = ISCAPI_TIMER_MAGIC;
result = schedule(timer, &now, ISC_TRUE);
if (result == ISC_R_SUCCESS)
APPEND(manager->timers, timer, link);
if (result != ISC_R_SUCCESS) {
- timer->common.impmagic = 0;
- timer->common.magic = 0;
isc_task_detach(&timer->task);
free(timer);
return (result);
@@ -268,12 +234,11 @@ isc__timer_create(isc_timermgr_t *manager0, const struct timespec *interval,
}
isc_result_t
-isc__timer_reset(isc_timer_t *timer0, const struct timespec *interval,
+isc_timer_reset(isc_timer_t *timer, const struct timespec *interval,
isc_boolean_t purge)
{
- isc__timer_t *timer = (isc__timer_t *)timer0;
struct timespec now;
- isc__timermgr_t *manager;
+ isc_timermgr_t *manager;
isc_result_t result;
/*
@@ -282,9 +247,7 @@ isc__timer_reset(isc_timer_t *timer0, const struct timespec *interval,
* are purged from its task's event queue.
*/
- REQUIRE(VALID_TIMER(timer));
manager = timer->manager;
- REQUIRE(VALID_MANAGER(manager));
REQUIRE(interval != NULL);
REQUIRE(timespecisset(interval));
@@ -312,39 +275,21 @@ isc__timer_reset(isc_timer_t *timer0, const struct timespec *interval,
}
void
-isc__timer_touch(isc_timer_t *timer0) {
- isc__timer_t *timer = (isc__timer_t *)timer0;
+isc_timer_touch(isc_timer_t *timer) {
struct timespec now;
/*
* Set the last-touched time of 'timer' to the current time.
*/
- REQUIRE(VALID_TIMER(timer));
clock_gettime(CLOCK_REALTIME, &now);
timespecadd(&now, &timer->interval, &timer->idle);
}
void
-isc__timer_attach(isc_timer_t *timer0, isc_timer_t **timerp) {
- isc__timer_t *timer = (isc__timer_t *)timer0;
-
- /*
- * Attach *timerp to timer.
- */
-
- REQUIRE(VALID_TIMER(timer));
- REQUIRE(timerp != NULL && *timerp == NULL);
-
- timer->references++;
-
- *timerp = (isc_timer_t *)timer;
-}
-
-void
-isc__timer_detach(isc_timer_t **timerp) {
- isc__timer_t *timer;
+isc_timer_detach(isc_timer_t **timerp) {
+ isc_timer_t *timer;
isc_boolean_t free_timer = ISC_FALSE;
/*
@@ -352,8 +297,7 @@ isc__timer_detach(isc_timer_t **timerp) {
*/
REQUIRE(timerp != NULL);
- timer = (isc__timer_t *)*timerp;
- REQUIRE(VALID_TIMER(timer));
+ timer = (isc_timer_t *)*timerp;
REQUIRE(timer->references > 0);
timer->references--;
@@ -367,11 +311,11 @@ isc__timer_detach(isc_timer_t **timerp) {
}
static void
-dispatch(isc__timermgr_t *manager, struct timespec *now) {
+dispatch(isc_timermgr_t *manager, struct timespec *now) {
isc_boolean_t done = ISC_FALSE, post_event, need_schedule;
isc_timerevent_t *event;
isc_eventtype_t type = 0;
- isc__timer_t *timer;
+ isc_timer_t *timer;
isc_result_t result;
isc_boolean_t idle;
@@ -443,12 +387,10 @@ dispatch(isc__timermgr_t *manager, struct timespec *now) {
static isc_boolean_t
sooner(void *v1, void *v2) {
- isc__timer_t *t1, *t2;
+ isc_timer_t *t1, *t2;
t1 = v1;
t2 = v2;
- REQUIRE(VALID_TIMER(t1));
- REQUIRE(VALID_TIMER(t2));
if (timespeccmp(&t1->due, &t2->due, <))
return (ISC_TRUE);
@@ -457,17 +399,16 @@ sooner(void *v1, void *v2) {
static void
set_index(void *what, unsigned int index) {
- isc__timer_t *timer;
+ isc_timer_t *timer;
timer = what;
- REQUIRE(VALID_TIMER(timer));
timer->index = index;
}
isc_result_t
-isc__timermgr_create(isc_timermgr_t **managerp) {
- isc__timermgr_t *manager;
+isc_timermgr_create(isc_timermgr_t **managerp) {
+ isc_timermgr_t *manager;
isc_result_t result;
/*
@@ -486,8 +427,6 @@ isc__timermgr_create(isc_timermgr_t **managerp) {
if (manager == NULL)
return (ISC_R_NOMEMORY);
- manager->common.impmagic = TIMER_MANAGER_MAGIC;
- manager->common.magic = ISCAPI_TIMERMGR_MAGIC;
manager->done = ISC_FALSE;
INIT_LIST(manager->timers);
manager->nscheduled = 0;
@@ -508,16 +447,15 @@ isc__timermgr_create(isc_timermgr_t **managerp) {
}
void
-isc__timermgr_destroy(isc_timermgr_t **managerp) {
- isc__timermgr_t *manager;
+isc_timermgr_destroy(isc_timermgr_t **managerp) {
+ isc_timermgr_t *manager;
/*
* Destroy a timer manager.
*/
REQUIRE(managerp != NULL);
- manager = (isc__timermgr_t *)*managerp;
- REQUIRE(VALID_MANAGER(manager));
+ manager = (isc_timermgr_t *)*managerp;
manager->refs--;
if (manager->refs > 0) {
@@ -526,7 +464,7 @@ isc__timermgr_destroy(isc_timermgr_t **managerp) {
}
timermgr = NULL;
- isc__timermgr_dispatch((isc_timermgr_t *)manager);
+ isc_timermgr_dispatch((isc_timermgr_t *)manager);
REQUIRE(EMPTY(manager->timers));
manager->done = ISC_TRUE;
@@ -535,8 +473,6 @@ isc__timermgr_destroy(isc_timermgr_t **managerp) {
* Clean up.
*/
isc_heap_destroy(&manager->heap);
- manager->common.impmagic = 0;
- manager->common.magic = 0;
free(manager);
*managerp = NULL;
@@ -545,8 +481,8 @@ isc__timermgr_destroy(isc_timermgr_t **managerp) {
}
isc_result_t
-isc__timermgr_nextevent(isc_timermgr_t *manager0, struct timespec *when) {
- isc__timermgr_t *manager = (isc__timermgr_t *)manager0;
+isc_timermgr_nextevent(isc_timermgr_t *manager0, struct timespec *when) {
+ isc_timermgr_t *manager = (isc_timermgr_t *)manager0;
if (manager == NULL)
manager = timermgr;
@@ -557,8 +493,8 @@ isc__timermgr_nextevent(isc_timermgr_t *manager0, struct timespec *when) {
}
void
-isc__timermgr_dispatch(isc_timermgr_t *manager0) {
- isc__timermgr_t *manager = (isc__timermgr_t *)manager0;
+isc_timermgr_dispatch(isc_timermgr_t *manager0) {
+ isc_timermgr_t *manager = (isc_timermgr_t *)manager0;
struct timespec now;
if (manager == NULL)
@@ -569,52 +505,3 @@ isc__timermgr_dispatch(isc_timermgr_t *manager0) {
dispatch(manager, &now);
}
-isc_result_t
-isc_timermgr_create(isc_timermgr_t **managerp) {
- return (isc__timermgr_create(managerp));
-}
-
-void
-isc_timermgr_destroy(isc_timermgr_t **managerp) {
- REQUIRE(*managerp != NULL && ISCAPI_TIMERMGR_VALID(*managerp));
-
- isc__timermgr_destroy(managerp);
-
- ENSURE(*managerp == NULL);
-}
-
-isc_result_t
-isc_timer_create(isc_timermgr_t *manager, const struct timespec *interval,
- isc_task_t *task, isc_taskaction_t action, void *arg,
- isc_timer_t **timerp)
-{
- REQUIRE(ISCAPI_TIMERMGR_VALID(manager));
-
- return (isc__timer_create(manager, interval,
- task, action, arg, timerp));
-}
-
-void
-isc_timer_detach(isc_timer_t **timerp) {
- REQUIRE(timerp != NULL && ISCAPI_TIMER_VALID(*timerp));
-
- isc__timer_detach(timerp);
-
- ENSURE(*timerp == NULL);
-}
-
-isc_result_t
-isc_timer_reset(isc_timer_t *timer, const struct timespec *interval,
- isc_boolean_t purge)
-{
- REQUIRE(ISCAPI_TIMER_VALID(timer));
-
- return (isc__timer_reset(timer, interval, purge));
-}
-
-void
-isc_timer_touch(isc_timer_t *timer) {
- REQUIRE(ISCAPI_TIMER_VALID(timer));
-
- isc__timer_touch(timer);
-}
diff --git a/usr.bin/dig/lib/isc/timer_p.h b/usr.bin/dig/lib/isc/timer_p.h
index c3a95313869..ec287c36911 100644
--- a/usr.bin/dig/lib/isc/timer_p.h
+++ b/usr.bin/dig/lib/isc/timer_p.h
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: timer_p.h,v 1.2 2020/02/16 18:05:09 florian Exp $ */
+/* $Id: timer_p.h,v 1.3 2020/02/18 18:11:27 florian Exp $ */
#ifndef ISC_TIMER_P_H
#define ISC_TIMER_P_H
@@ -22,9 +22,9 @@
/*! \file */
isc_result_t
-isc__timermgr_nextevent(isc_timermgr_t *timermgr, struct timespec *when);
+isc_timermgr_nextevent(isc_timermgr_t *timermgr, struct timespec *when);
void
-isc__timermgr_dispatch(isc_timermgr_t *timermgr);
+isc_timermgr_dispatch(isc_timermgr_t *timermgr);
#endif /* ISC_TIMER_P_H */
diff --git a/usr.bin/dig/lib/isc/unix/app.c b/usr.bin/dig/lib/isc/unix/app.c
index 555079e0bb7..e06046316e2 100644
--- a/usr.bin/dig/lib/isc/unix/app.c
+++ b/usr.bin/dig/lib/isc/unix/app.c
@@ -16,8 +16,6 @@
/*! \file */
-
-
#include <stddef.h>
#include <stdlib.h>
#include <errno.h>
@@ -26,8 +24,6 @@
#include <isc/app.h>
#include <isc/boolean.h>
-
-
#include <isc/event.h>
#include <string.h>
@@ -45,43 +41,12 @@
#include "../task_p.h"
#include "socket_p.h"
-/*%
- * The following are intended for internal use (indicated by "isc__"
- * prefix) but are not declared as static, allowing direct access from
- * unit tests etc.
- */
-isc_result_t isc__app_start(void);
-isc_result_t isc__app_ctxstart(isc_appctx_t *ctx);
-isc_result_t isc__app_onrun(isc_task_t *task,
- isc_taskaction_t action, void *arg);
-isc_result_t isc__app_ctxrun(isc_appctx_t *ctx);
-isc_result_t isc__app_run(void);
-isc_result_t isc__app_ctxshutdown(isc_appctx_t *ctx);
-isc_result_t isc__app_shutdown(void);
-isc_result_t isc__app_reload(void);
-isc_result_t isc__app_ctxsuspend(isc_appctx_t *ctx);
-void isc__app_ctxfinish(isc_appctx_t *ctx);
-void isc__app_finish(void);
-void isc__app_block(void);
-void isc__app_unblock(void);
-isc_result_t isc__appctx_create(isc_appctx_t **ctxp);
-void isc__appctx_destroy(isc_appctx_t **ctxp);
-void isc__appctx_settaskmgr(isc_appctx_t *ctx, isc_taskmgr_t *taskmgr);
-void isc__appctx_setsocketmgr(isc_appctx_t *ctx, isc_socketmgr_t *socketmgr);
-void isc__appctx_settimermgr(isc_appctx_t *ctx, isc_timermgr_t *timermgr);
-isc_result_t isc__app_ctxonrun(isc_appctx_t *ctx,
- isc_task_t *task, isc_taskaction_t action,
- void *arg);
-
/*
* The application context of this module. This implementation actually
* doesn't use it. (This may change in the future).
*/
-#define APPCTX_MAGIC ISC_MAGIC('A', 'p', 'c', 'x')
-#define VALID_APPCTX(c) ISC_MAGIC_VALID(c, APPCTX_MAGIC)
-typedef struct isc__appctx {
- isc_appctx_t common;
+typedef struct isc_appctx {
isc_eventlist_t on_run;
isc_boolean_t shutdown_requested;
isc_boolean_t running;
@@ -100,9 +65,13 @@ typedef struct isc__appctx {
isc_taskmgr_t *taskmgr;
isc_socketmgr_t *socketmgr;
isc_timermgr_t *timermgr;
-} isc__appctx_t;
+} isc_appctx_t;
+
+static isc_appctx_t isc_g_appctx;
+static isc_boolean_t is_running = ISC_FALSE;
-static isc__appctx_t isc_g_appctx;
+static isc_result_t isc_app_ctxonrun(isc_appctx_t *ctx, isc_task_t *task,
+ isc_taskaction_t action, void *arg);
static void
reload_action(int arg) {
@@ -128,15 +97,12 @@ handle_signal(int sig, void (*handler)(int)) {
return (ISC_R_SUCCESS);
}
-isc_result_t
-isc__app_ctxstart(isc_appctx_t *ctx0) {
- isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
+static isc_result_t
+isc_app_ctxstart(isc_appctx_t *ctx) {
isc_result_t result;
int presult;
sigset_t sset;
- REQUIRE(VALID_APPCTX(ctx));
-
/*
* Start an ISC library application.
*/
@@ -209,27 +175,24 @@ isc__app_ctxstart(isc_appctx_t *ctx0) {
}
isc_result_t
-isc__app_start(void) {
- isc_g_appctx.common.impmagic = APPCTX_MAGIC;
- isc_g_appctx.common.magic = ISCAPI_APPCTX_MAGIC;
+isc_app_start(void) {
/* The remaining members will be initialized in ctxstart() */
- return (isc__app_ctxstart((isc_appctx_t *)&isc_g_appctx));
+ return (isc_app_ctxstart((isc_appctx_t *)&isc_g_appctx));
}
isc_result_t
-isc__app_onrun(isc_task_t *task, isc_taskaction_t action,
+isc_app_onrun(isc_task_t *task, isc_taskaction_t action,
void *arg)
{
- return (isc__app_ctxonrun((isc_appctx_t *)&isc_g_appctx,
+ return (isc_app_ctxonrun((isc_appctx_t *)&isc_g_appctx,
task, action, arg));
}
isc_result_t
-isc__app_ctxonrun(isc_appctx_t *ctx0, isc_task_t *task,
+isc_app_ctxonrun(isc_appctx_t *ctx, isc_task_t *task,
isc_taskaction_t action, void *arg)
{
- isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
isc_event_t *event;
isc_task_t *cloned_task = NULL;
isc_result_t result;
@@ -264,7 +227,7 @@ isc__app_ctxonrun(isc_appctx_t *ctx0, isc_task_t *task,
* Event loop for nonthreaded programs.
*/
static isc_result_t
-evloop(isc__appctx_t *ctx) {
+evloop(isc_appctx_t *ctx) {
isc_result_t result;
while (!ctx->want_shutdown) {
@@ -278,8 +241,8 @@ evloop(isc__appctx_t *ctx) {
/*
* Check the reload (or suspend) case first for exiting the
* loop as fast as possible in case:
- * - the direct call to isc__taskmgr_dispatch() in
- * isc__app_ctxrun() completes all the tasks so far,
+ * - the direct call to isc_taskmgr_dispatch() in
+ * isc_app_ctxrun() completes all the tasks so far,
* - there is thus currently no active task, and
* - there is a timer event
*/
@@ -288,14 +251,14 @@ evloop(isc__appctx_t *ctx) {
return (ISC_R_RELOAD);
}
- readytasks = isc__taskmgr_ready(ctx->taskmgr);
+ readytasks = isc_taskmgr_ready(ctx->taskmgr);
if (readytasks) {
tv.tv_sec = 0;
tv.tv_usec = 0;
tvp = &tv;
call_timer_dispatch = ISC_TRUE;
} else {
- result = isc__timermgr_nextevent(ctx->timermgr, &when);
+ result = isc_timermgr_nextevent(ctx->timermgr, &when);
if (result != ISC_R_SUCCESS)
tvp = NULL;
else {
@@ -312,11 +275,11 @@ evloop(isc__appctx_t *ctx) {
}
swait = NULL;
- n = isc__socketmgr_waitevents(ctx->socketmgr, tvp, &swait);
+ n = isc_socketmgr_waitevents(ctx->socketmgr, tvp, &swait);
if (n == 0 || call_timer_dispatch) {
/*
- * We call isc__timermgr_dispatch() only when
+ * We call isc_timermgr_dispatch() only when
* necessary, in order to reduce overhead. If the
* select() call indicates a timeout, we need the
* dispatch. Even if not, if we set the 0-timeout
@@ -329,24 +292,21 @@ evloop(isc__appctx_t *ctx) {
* call, since this loop only runs in the non-thread
* mode.
*/
- isc__timermgr_dispatch(ctx->timermgr);
+ isc_timermgr_dispatch(ctx->timermgr);
}
if (n > 0)
- (void)isc__socketmgr_dispatch(ctx->socketmgr, swait);
- (void)isc__taskmgr_dispatch(ctx->taskmgr);
+ (void)isc_socketmgr_dispatch(ctx->socketmgr, swait);
+ (void)isc_taskmgr_dispatch(ctx->taskmgr);
}
return (ISC_R_SUCCESS);
}
-isc_result_t
-isc__app_ctxrun(isc_appctx_t *ctx0) {
- isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
+static isc_result_t
+isc_app_ctxrun(isc_appctx_t *ctx) {
int result;
isc_event_t *event, *next_event;
isc_task_t *task;
- REQUIRE(VALID_APPCTX(ctx));
-
if (!ctx->running) {
ctx->running = ISC_TRUE;
@@ -371,23 +331,20 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
return (ISC_R_SUCCESS);
}
- (void) isc__taskmgr_dispatch(ctx->taskmgr);
+ (void) isc_taskmgr_dispatch(ctx->taskmgr);
result = evloop(ctx);
return (result);
}
isc_result_t
-isc__app_run(void) {
- return (isc__app_ctxrun((isc_appctx_t *)&isc_g_appctx));
+isc_app_run(void) {
+ return (isc_app_ctxrun((isc_appctx_t *)&isc_g_appctx));
}
-isc_result_t
-isc__app_ctxshutdown(isc_appctx_t *ctx0) {
- isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
+static isc_result_t
+isc_app_ctxshutdown(isc_appctx_t *ctx) {
isc_boolean_t want_kill = ISC_TRUE;
- REQUIRE(VALID_APPCTX(ctx));
-
REQUIRE(ctx->running);
if (ctx->shutdown_requested)
@@ -407,57 +364,18 @@ isc__app_ctxshutdown(isc_appctx_t *ctx0) {
return (ISC_R_SUCCESS);
}
-isc_result_t
-isc__app_shutdown(void) {
- return (isc__app_ctxshutdown((isc_appctx_t *)&isc_g_appctx));
-}
-
-isc_result_t
-isc__app_ctxsuspend(isc_appctx_t *ctx0) {
- isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
- isc_boolean_t want_kill = ISC_TRUE;
-
- REQUIRE(VALID_APPCTX(ctx));
-
- REQUIRE(ctx->running);
-
- /*
- * Don't send the reload signal if we're shutting down.
- */
- if (ctx->shutdown_requested)
- want_kill = ISC_FALSE;
-
- if (want_kill) {
- if (ctx != &isc_g_appctx)
- /* BIND9 internal, but using multiple contexts */
- ctx->want_reload = ISC_TRUE;
- else {
- ctx->want_reload = ISC_TRUE;
- }
- }
-
- return (ISC_R_SUCCESS);
+isc_boolean_t
+isc_app_isrunning() {
+ return (is_running);
}
isc_result_t
-isc__app_reload(void) {
- return (isc__app_ctxsuspend((isc_appctx_t *)&isc_g_appctx));
+isc_app_shutdown(void) {
+ return (isc_app_ctxshutdown((isc_appctx_t *)&isc_g_appctx));
}
void
-isc__app_ctxfinish(isc_appctx_t *ctx0) {
- isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
-
- REQUIRE(VALID_APPCTX(ctx));
-}
-
-void
-isc__app_finish(void) {
- isc__app_ctxfinish((isc_appctx_t *)&isc_g_appctx);
-}
-
-void
-isc__app_block(void) {
+isc_app_block(void) {
REQUIRE(isc_g_appctx.running);
REQUIRE(!isc_g_appctx.blocked);
@@ -465,7 +383,7 @@ isc__app_block(void) {
}
void
-isc__app_unblock(void) {
+isc_app_unblock(void) {
REQUIRE(isc_g_appctx.running);
REQUIRE(isc_g_appctx.blocked);
@@ -473,67 +391,3 @@ isc__app_unblock(void) {
isc_g_appctx.blocked = ISC_FALSE;
}
-
-isc_result_t
-isc__appctx_create(isc_appctx_t **ctxp) {
- isc__appctx_t *ctx;
-
- REQUIRE(ctxp != NULL && *ctxp == NULL);
-
- ctx = malloc(sizeof(*ctx));
- if (ctx == NULL)
- return (ISC_R_NOMEMORY);
-
- ctx->common.impmagic = APPCTX_MAGIC;
- ctx->common.magic = ISCAPI_APPCTX_MAGIC;
-
- ctx->taskmgr = NULL;
- ctx->socketmgr = NULL;
- ctx->timermgr = NULL;
-
- *ctxp = (isc_appctx_t *)ctx;
-
- return (ISC_R_SUCCESS);
-}
-
-void
-isc__appctx_destroy(isc_appctx_t **ctxp) {
- isc__appctx_t *ctx;
-
- REQUIRE(ctxp != NULL);
- ctx = (isc__appctx_t *)*ctxp;
- REQUIRE(VALID_APPCTX(ctx));
-
- free(ctx);
-
- *ctxp = NULL;
-}
-
-void
-isc__appctx_settaskmgr(isc_appctx_t *ctx0, isc_taskmgr_t *taskmgr) {
- isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
-
- REQUIRE(VALID_APPCTX(ctx));
-
- ctx->taskmgr = taskmgr;
-}
-
-void
-isc__appctx_setsocketmgr(isc_appctx_t *ctx0, isc_socketmgr_t *socketmgr) {
- isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
-
- REQUIRE(VALID_APPCTX(ctx));
-
- ctx->socketmgr = socketmgr;
-}
-
-void
-isc__appctx_settimermgr(isc_appctx_t *ctx0, isc_timermgr_t *timermgr) {
- isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
-
- REQUIRE(VALID_APPCTX(ctx));
-
- ctx->timermgr = timermgr;
-}
-
-#include "../app_api.c"
diff --git a/usr.bin/dig/lib/isc/unix/socket.c b/usr.bin/dig/lib/isc/unix/socket.c
index c6ce5c328e2..4af3b7529d3 100644
--- a/usr.bin/dig/lib/isc/unix/socket.c
+++ b/usr.bin/dig/lib/isc/unix/socket.c
@@ -97,9 +97,6 @@ int isc_dscp_check_value = -1;
typedef isc_event_t intev_t;
-#define SOCKET_MAGIC ISC_MAGIC('I', 'O', 'i', 'o')
-#define VALID_SOCKET(s) ISC_MAGIC_VALID(s, SOCKET_MAGIC)
-
/*!
* IPv6 control information. If the socket is an IPv6 socket we want
* to collect the destination address and interface so the client can
@@ -134,17 +131,16 @@ typedef isc_event_t intev_t;
*/
#define NRETRIES 10
-typedef struct isc__socket isc__socket_t;
-typedef struct isc__socketmgr isc__socketmgr_t;
+typedef struct isc_socket isc_socket_t;
+typedef struct isc_socketmgr isc_socketmgr_t;
-struct isc__socket {
+struct isc_socket {
/* Not locked. */
- isc_socket_t common;
- isc__socketmgr_t *manager;
+ isc_socketmgr_t *manager;
isc_sockettype_t type;
/* Locked by socket lock. */
- ISC_LINK(isc__socket_t) link;
+ ISC_LINK(isc_socket_t) link;
unsigned int references;
int fd;
int pf;
@@ -173,20 +169,16 @@ struct isc__socket {
unsigned int dscp;
};
-#define SOCKET_MANAGER_MAGIC ISC_MAGIC('I', 'O', 'm', 'g')
-#define VALID_MANAGER(m) ISC_MAGIC_VALID(m, SOCKET_MANAGER_MAGIC)
-
-struct isc__socketmgr {
+struct isc_socketmgr {
/* Not locked. */
- isc_socketmgr_t common;
int fd_bufsize;
unsigned int maxsocks;
- isc__socket_t **fds;
+ isc_socket_t **fds;
int *fdstate;
/* Locked by manager lock. */
- ISC_LIST(isc__socket_t) socklist;
+ ISC_LIST(isc_socket_t) socklist;
fd_set *read_fds;
fd_set *read_fds_copy;
fd_set *write_fds;
@@ -195,7 +187,7 @@ struct isc__socketmgr {
unsigned int refs;
};
-static isc__socketmgr_t *socketmgr = NULL;
+static isc_socketmgr_t *socketmgr = NULL;
#define CLOSED 0 /* this one must be zero */
#define MANAGED 1
@@ -210,64 +202,21 @@ static isc__socketmgr_t *socketmgr = NULL;
static isc_result_t socket_create(isc_socketmgr_t *manager0, int pf,
isc_sockettype_t type,
isc_socket_t **socketp);
-static void send_recvdone_event(isc__socket_t *, isc_socketevent_t **);
-static void send_senddone_event(isc__socket_t *, isc_socketevent_t **);
-static void free_socket(isc__socket_t **);
-static isc_result_t allocate_socket(isc__socketmgr_t *, isc_sockettype_t,
- isc__socket_t **);
-static void destroy(isc__socket_t **);
+static void send_recvdone_event(isc_socket_t *, isc_socketevent_t **);
+static void send_senddone_event(isc_socket_t *, isc_socketevent_t **);
+static void free_socket(isc_socket_t **);
+static isc_result_t allocate_socket(isc_socketmgr_t *, isc_sockettype_t,
+ isc_socket_t **);
+static void destroy(isc_socket_t **);
static void internal_connect(isc_task_t *, isc_event_t *);
static void internal_recv(isc_task_t *, isc_event_t *);
static void internal_send(isc_task_t *, isc_event_t *);
-static void process_cmsg(isc__socket_t *, struct msghdr *, isc_socketevent_t *);
-static void build_msghdr_send(isc__socket_t *, char *, isc_socketevent_t *,
+static void process_cmsg(isc_socket_t *, struct msghdr *, isc_socketevent_t *);
+static void build_msghdr_send(isc_socket_t *, char *, isc_socketevent_t *,
struct msghdr *, struct iovec *, size_t *);
-static void build_msghdr_recv(isc__socket_t *, char *, isc_socketevent_t *,
+static void build_msghdr_recv(isc_socket_t *, char *, isc_socketevent_t *,
struct msghdr *, struct iovec *, size_t *);
-/*%
- * The following are intended for internal use (indicated by "isc__"
- * prefix) but are not declared as static, allowing direct access from
- * unit tests etc.
- */
-
-isc_result_t
-isc__socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
- isc_socket_t **socketp);
-void
-isc__socket_attach(isc_socket_t *sock, isc_socket_t **socketp);
-void
-isc__socket_detach(isc_socket_t **socketp);
-isc_result_t
-isc__socket_recvv(isc_socket_t *sock, isc_bufferlist_t *buflist,
- unsigned int minimum, isc_task_t *task,
- isc_taskaction_t action, void *arg);
-isc_result_t
-isc__socket_sendv(isc_socket_t *sock, isc_bufferlist_t *buflist,
- isc_task_t *task, isc_taskaction_t action, void *arg);
-isc_result_t
-isc__socket_sendtov2(isc_socket_t *sock, isc_bufferlist_t *buflist,
- isc_task_t *task, isc_taskaction_t action, void *arg,
- isc_sockaddr_t *address, struct in6_pktinfo *pktinfo,
- unsigned int flags);
-isc_result_t
-isc__socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr,
- unsigned int options);
-isc_result_t
-isc__socket_connect(isc_socket_t *sock, isc_sockaddr_t *addr,
- isc_task_t *task, isc_taskaction_t action,
- void *arg);
-void
-isc__socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how);
-
-isc_result_t
-isc__socketmgr_create(isc_socketmgr_t **managerp);
-isc_result_t
-isc__socketmgr_create2(isc_socketmgr_t **managerp,
- unsigned int maxsocks);
-void
-isc__socketmgr_destroy(isc_socketmgr_t **managerp);
-
#define SELECT_POKE_SHUTDOWN (-1)
#define SELECT_POKE_READ (-3)
#define SELECT_POKE_WRITE (-4)
@@ -295,11 +244,11 @@ enum {
static void
-socket_log(isc__socket_t *sock, isc_sockaddr_t *address,
+socket_log(isc_socket_t *sock, isc_sockaddr_t *address,
isc_logcategory_t *category, isc_logmodule_t *module, int level,
const char *fmt, ...) __attribute__((__format__(__printf__, 6, 7)));
static void
-socket_log(isc__socket_t *sock, isc_sockaddr_t *address,
+socket_log(isc_socket_t *sock, isc_sockaddr_t *address,
isc_logcategory_t *category, isc_logmodule_t *module, int level,
const char *fmt, ...)
{
@@ -325,7 +274,7 @@ socket_log(isc__socket_t *sock, isc_sockaddr_t *address,
}
static inline isc_result_t
-watch_fd(isc__socketmgr_t *manager, int fd, int msg) {
+watch_fd(isc_socketmgr_t *manager, int fd, int msg) {
isc_result_t result = ISC_R_SUCCESS;
if (msg == SELECT_POKE_READ)
@@ -337,7 +286,7 @@ watch_fd(isc__socketmgr_t *manager, int fd, int msg) {
}
static inline isc_result_t
-unwatch_fd(isc__socketmgr_t *manager, int fd, int msg) {
+unwatch_fd(isc_socketmgr_t *manager, int fd, int msg) {
isc_result_t result = ISC_R_SUCCESS;
if (msg == SELECT_POKE_READ)
@@ -349,7 +298,7 @@ unwatch_fd(isc__socketmgr_t *manager, int fd, int msg) {
}
static void
-wakeup_socket(isc__socketmgr_t *manager, int fd, int msg) {
+wakeup_socket(isc_socketmgr_t *manager, int fd, int msg) {
isc_result_t result;
/*
@@ -406,7 +355,7 @@ wakeup_socket(isc__socketmgr_t *manager, int fd, int msg) {
* Update the state of the socketmgr when something changes.
*/
static void
-select_poke(isc__socketmgr_t *manager, int fd, int msg) {
+select_poke(isc_socketmgr_t *manager, int fd, int msg) {
if (msg == SELECT_POKE_SHUTDOWN)
return;
else if (fd >= 0)
@@ -457,7 +406,7 @@ cmsg_space(socklen_t len) {
* Process control messages received on a socket.
*/
static void
-process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
+process_cmsg(isc_socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
struct cmsghdr *cmsgp;
struct in6_pktinfo *pktinfop;
void *timevalp;
@@ -548,7 +497,7 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
* this transaction can send.
*/
static void
-build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev,
+build_msghdr_send(isc_socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev,
struct msghdr *msg, struct iovec *iov, size_t *write_countp)
{
unsigned int iovcount;
@@ -590,7 +539,6 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev,
*/
skip_count = dev->n;
while (buffer != NULL) {
- REQUIRE(ISC_BUFFER_VALID(buffer));
if (skip_count < isc_buffer_usedlength(buffer))
break;
skip_count -= isc_buffer_usedlength(buffer);
@@ -748,7 +696,7 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev,
* this transaction can receive.
*/
static void
-build_msghdr_recv(isc__socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
+build_msghdr_recv(isc_socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
struct msghdr *msg, struct iovec *iov, size_t *read_countp)
{
unsigned int iovcount;
@@ -788,7 +736,6 @@ build_msghdr_recv(isc__socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
* Skip empty buffers.
*/
while (buffer != NULL) {
- REQUIRE(ISC_BUFFER_VALID(buffer));
if (isc_buffer_availablelength(buffer) != 0)
break;
buffer = ISC_LIST_NEXT(buffer, link);
@@ -826,7 +773,7 @@ build_msghdr_recv(isc__socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev,
}
static void
-set_dev_address(isc_sockaddr_t *address, isc__socket_t *sock,
+set_dev_address(isc_sockaddr_t *address, isc_socket_t *sock,
isc_socketevent_t *dev)
{
if (sock->type == isc_sockettype_udp) {
@@ -883,7 +830,7 @@ allocate_socketevent(void *sender,
#define DOIO_EOF 3 /* EOF, no event sent */
static int
-doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) {
+doio_recv(isc_socket_t *sock, isc_socketevent_t *dev) {
int cc;
struct iovec iov[MAXSCATTERGATHER_RECV];
size_t read_count;
@@ -994,7 +941,6 @@ doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) {
actual_count = cc;
buffer = ISC_LIST_HEAD(dev->bufferlist);
while (buffer != NULL && actual_count > 0U) {
- REQUIRE(ISC_BUFFER_VALID(buffer));
if (isc_buffer_availablelength(buffer) <= actual_count) {
actual_count -= isc_buffer_availablelength(buffer);
isc_buffer_add(buffer,
@@ -1039,7 +985,7 @@ doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) {
* No other return values are possible.
*/
static int
-doio_send(isc__socket_t *sock, isc_socketevent_t *dev) {
+doio_send(isc_socket_t *sock, isc_socketevent_t *dev) {
int cc;
struct iovec iov[MAXSCATTERGATHER_SEND];
size_t write_count;
@@ -1140,7 +1086,7 @@ doio_send(isc__socket_t *sock, isc_socketevent_t *dev) {
* references exist.
*/
static void
-socketclose(isc__socketmgr_t *manager, isc__socket_t *sock, int fd) {
+socketclose(isc_socketmgr_t *manager, isc_socket_t *sock, int fd) {
/*
* No one has this socket open, so the watcher doesn't have to be
* poked, and the socket doesn't have to be locked.
@@ -1172,10 +1118,10 @@ socketclose(isc__socketmgr_t *manager, isc__socket_t *sock, int fd) {
}
static void
-destroy(isc__socket_t **sockp) {
+destroy(isc_socket_t **sockp) {
int fd;
- isc__socket_t *sock = *sockp;
- isc__socketmgr_t *manager = sock->manager;
+ isc_socket_t *sock = *sockp;
+ isc_socketmgr_t *manager = sock->manager;
socket_log(sock, NULL, CREATION, "destroying");
@@ -1197,18 +1143,16 @@ destroy(isc__socket_t **sockp) {
}
static isc_result_t
-allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
- isc__socket_t **socketp)
+allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type,
+ isc_socket_t **socketp)
{
- isc__socket_t *sock;
+ isc_socket_t *sock;
sock = malloc(sizeof(*sock));
if (sock == NULL)
return (ISC_R_NOMEMORY);
- sock->common.magic = 0;
- sock->common.impmagic = 0;
sock->references = 0;
sock->manager = manager;
@@ -1242,8 +1186,6 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
ISC_EVENTATTR_NOPURGE, NULL, ISC_SOCKEVENT_INTW,
NULL, sock, sock, NULL);
- sock->common.magic = ISCAPI_SOCKET_MAGIC;
- sock->common.impmagic = SOCKET_MAGIC;
*socketp = sock;
return (ISC_R_SUCCESS);
@@ -1251,16 +1193,15 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
/*
* This event requires that the various lists be empty, that the reference
- * count be 1, and that the magic number is valid. The other socket bits,
+ * count be 1. The other socket bits,
* like the lock, must be initialized as well. The fd associated must be
* marked as closed, by setting it to -1 on close, or this routine will
* also close the socket.
*/
static void
-free_socket(isc__socket_t **socketp) {
- isc__socket_t *sock = *socketp;
+free_socket(isc_socket_t **socketp) {
+ isc_socket_t *sock = *socketp;
- INSIST(VALID_SOCKET(sock));
INSIST(sock->references == 0);
INSIST(!sock->connecting);
INSIST(!sock->pending_recv);
@@ -1269,16 +1210,13 @@ free_socket(isc__socket_t **socketp) {
INSIST(ISC_LIST_EMPTY(sock->send_list));
INSIST(!ISC_LINK_LINKED(sock, link));
- sock->common.magic = 0;
- sock->common.impmagic = 0;
-
free(sock);
*socketp = NULL;
}
static void
-use_min_mtu(isc__socket_t *sock) {
+use_min_mtu(isc_socket_t *sock) {
/* use minimum MTU */
if (sock->pf == AF_INET6) {
int on = 1;
@@ -1288,14 +1226,14 @@ use_min_mtu(isc__socket_t *sock) {
}
static void
-set_tcp_maxseg(isc__socket_t *sock, int size) {
+set_tcp_maxseg(isc_socket_t *sock, int size) {
if (sock->type == isc_sockettype_tcp)
(void)setsockopt(sock->fd, IPPROTO_TCP, TCP_MAXSEG,
(void *)&size, sizeof(size));
}
static isc_result_t
-opensocket(isc__socket_t *sock)
+opensocket(isc_socket_t *sock)
{
isc_result_t result;
const char *err = "socket";
@@ -1392,11 +1330,10 @@ static isc_result_t
socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
isc_socket_t **socketp)
{
- isc__socket_t *sock = NULL;
- isc__socketmgr_t *manager = (isc__socketmgr_t *)manager0;
+ isc_socket_t *sock = NULL;
+ isc_socketmgr_t *manager = (isc_socketmgr_t *)manager0;
isc_result_t result;
- REQUIRE(VALID_MANAGER(manager));
REQUIRE(socketp != NULL && *socketp == NULL);
result = allocate_socket(manager, type, &sock);
@@ -1449,7 +1386,7 @@ socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
* in 'socketp'.
*/
isc_result_t
-isc__socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
+isc_socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
isc_socket_t **socketp)
{
return (socket_create(manager0, pf, type, socketp));
@@ -1459,10 +1396,9 @@ isc__socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
* Attach to a socket. Caller must explicitly detach when it is done.
*/
void
-isc__socket_attach(isc_socket_t *sock0, isc_socket_t **socketp) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
+isc_socket_attach(isc_socket_t *sock0, isc_socket_t **socketp) {
+ isc_socket_t *sock = (isc_socket_t *)sock0;
- REQUIRE(VALID_SOCKET(sock));
REQUIRE(socketp != NULL && *socketp == NULL);
sock->references++;
@@ -1475,13 +1411,12 @@ isc__socket_attach(isc_socket_t *sock0, isc_socket_t **socketp) {
* up by destroying the socket.
*/
void
-isc__socket_detach(isc_socket_t **socketp) {
- isc__socket_t *sock;
+isc_socket_detach(isc_socket_t **socketp) {
+ isc_socket_t *sock;
isc_boolean_t kill_socket = ISC_FALSE;
REQUIRE(socketp != NULL);
- sock = (isc__socket_t *)*socketp;
- REQUIRE(VALID_SOCKET(sock));
+ sock = (isc_socket_t *)*socketp;
REQUIRE(sock->references > 0);
sock->references--;
@@ -1503,7 +1438,7 @@ isc__socket_detach(isc_socket_t **socketp) {
* The socket and manager must be locked before calling this function.
*/
static void
-dispatch_recv(isc__socket_t *sock) {
+dispatch_recv(isc_socket_t *sock) {
intev_t *iev;
isc_socketevent_t *ev;
isc_task_t *sender;
@@ -1530,7 +1465,7 @@ dispatch_recv(isc__socket_t *sock) {
}
static void
-dispatch_send(isc__socket_t *sock) {
+dispatch_send(isc_socket_t *sock) {
intev_t *iev;
isc_socketevent_t *ev;
isc_task_t *sender;
@@ -1557,7 +1492,7 @@ dispatch_send(isc__socket_t *sock) {
}
static void
-dispatch_connect(isc__socket_t *sock) {
+dispatch_connect(isc_socket_t *sock) {
intev_t *iev;
isc_socket_connev_t *ev;
@@ -1587,7 +1522,7 @@ dispatch_connect(isc__socket_t *sock) {
* Caller must have the socket locked if the event is attached to the socket.
*/
static void
-send_recvdone_event(isc__socket_t *sock, isc_socketevent_t **dev) {
+send_recvdone_event(isc_socket_t *sock, isc_socketevent_t **dev) {
isc_task_t *task;
task = (*dev)->ev_sender;
@@ -1610,7 +1545,7 @@ send_recvdone_event(isc__socket_t *sock, isc_socketevent_t **dev) {
* Caller must have the socket locked if the event is attached to the socket.
*/
static void
-send_senddone_event(isc__socket_t *sock, isc_socketevent_t **dev) {
+send_senddone_event(isc_socket_t *sock, isc_socketevent_t **dev) {
isc_task_t *task;
INSIST(dev != NULL && *dev != NULL);
@@ -1631,12 +1566,11 @@ send_senddone_event(isc__socket_t *sock, isc_socketevent_t **dev) {
static void
internal_recv(isc_task_t *me, isc_event_t *ev) {
isc_socketevent_t *dev;
- isc__socket_t *sock;
+ isc_socket_t *sock;
INSIST(ev->ev_type == ISC_SOCKEVENT_INTR);
sock = ev->ev_sender;
- INSIST(VALID_SOCKET(sock));
socket_log(sock, NULL, IOEVENT,
"internal_recv: task %p got event %p", me, ev);
@@ -1691,15 +1625,14 @@ internal_recv(isc_task_t *me, isc_event_t *ev) {
static void
internal_send(isc_task_t *me, isc_event_t *ev) {
isc_socketevent_t *dev;
- isc__socket_t *sock;
+ isc_socket_t *sock;
INSIST(ev->ev_type == ISC_SOCKEVENT_INTW);
/*
* Find out what socket this is and lock it.
*/
- sock = (isc__socket_t *)ev->ev_sender;
- INSIST(VALID_SOCKET(sock));
+ sock = (isc_socket_t *)ev->ev_sender;
socket_log(sock, NULL, IOEVENT,
"internal_send: task %p got event %p", me, ev);
@@ -1742,10 +1675,10 @@ internal_send(isc_task_t *me, isc_event_t *ev) {
* and unlocking twice if both reads and writes are possible.
*/
static void
-process_fd(isc__socketmgr_t *manager, int fd, isc_boolean_t readable,
+process_fd(isc_socketmgr_t *manager, int fd, isc_boolean_t readable,
isc_boolean_t writeable)
{
- isc__socket_t *sock;
+ isc_socket_t *sock;
isc_boolean_t unwatch_read = ISC_FALSE, unwatch_write = ISC_FALSE;
/*
@@ -1792,7 +1725,7 @@ check_write:
}
static void
-process_fds(isc__socketmgr_t *manager, int maxfd, fd_set *readfds,
+process_fds(isc_socketmgr_t *manager, int maxfd, fd_set *readfds,
fd_set *writefds)
{
int i;
@@ -1810,7 +1743,7 @@ process_fds(isc__socketmgr_t *manager, int maxfd, fd_set *readfds,
*/
static isc_result_t
-setup_watcher(isc__socketmgr_t *manager) {
+setup_watcher(isc_socketmgr_t *manager) {
isc_result_t result;
UNUSED(result);
@@ -1851,7 +1784,7 @@ setup_watcher(isc__socketmgr_t *manager) {
}
static void
-cleanup_watcher(isc__socketmgr_t *manager) {
+cleanup_watcher(isc_socketmgr_t *manager) {
if (manager->read_fds != NULL)
free(manager->read_fds);
@@ -1863,16 +1796,11 @@ cleanup_watcher(isc__socketmgr_t *manager) {
free(manager->write_fds_copy);
}
-isc_result_t
-isc__socketmgr_create(isc_socketmgr_t **managerp) {
- return (isc__socketmgr_create2(managerp, 0));
-}
-
-isc_result_t
-isc__socketmgr_create2(isc_socketmgr_t **managerp,
+static isc_result_t
+isc_socketmgr_create2(isc_socketmgr_t **managerp,
unsigned int maxsocks)
{
- isc__socketmgr_t *manager;
+ isc_socketmgr_t *manager;
isc_result_t result;
REQUIRE(managerp != NULL && *managerp == NULL);
@@ -1897,7 +1825,7 @@ isc__socketmgr_create2(isc_socketmgr_t **managerp,
/* zero-clear so that necessary cleanup on failure will be easy */
memset(manager, 0, sizeof(*manager));
manager->maxsocks = maxsocks;
- manager->fds = malloc(manager->maxsocks * sizeof(isc__socket_t *));
+ manager->fds = malloc(manager->maxsocks * sizeof(isc_socket_t *));
if (manager->fds == NULL) {
result = ISC_R_NOMEMORY;
goto free_manager;
@@ -1908,8 +1836,6 @@ isc__socketmgr_create2(isc_socketmgr_t **managerp,
goto free_manager;
}
- manager->common.magic = ISCAPI_SOCKETMGR_MAGIC;
- manager->common.impmagic = SOCKET_MANAGER_MAGIC;
memset(manager->fds, 0, manager->maxsocks * sizeof(isc_socket_t *));
ISC_LIST_INIT(manager->socklist);
@@ -1943,9 +1869,14 @@ free_manager:
return (result);
}
+isc_result_t
+isc_socketmgr_create(isc_socketmgr_t **managerp) {
+ return (isc_socketmgr_create2(managerp, 0));
+}
+
void
-isc__socketmgr_destroy(isc_socketmgr_t **managerp) {
- isc__socketmgr_t *manager;
+isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
+ isc_socketmgr_t *manager;
int i;
/*
@@ -1953,8 +1884,7 @@ isc__socketmgr_destroy(isc_socketmgr_t **managerp) {
*/
REQUIRE(managerp != NULL);
- manager = (isc__socketmgr_t *)*managerp;
- REQUIRE(VALID_MANAGER(manager));
+ manager = (isc_socketmgr_t *)*managerp;
manager->refs--;
if (manager->refs > 0) {
@@ -1967,7 +1897,7 @@ isc__socketmgr_destroy(isc_socketmgr_t **managerp) {
* Wait for all sockets to be destroyed.
*/
while (!ISC_LIST_EMPTY(manager->socklist)) {
- isc__taskmgr_dispatch(NULL);
+ isc_taskmgr_dispatch(NULL);
}
/*
@@ -1989,8 +1919,6 @@ isc__socketmgr_destroy(isc_socketmgr_t **managerp) {
free(manager->fds);
free(manager->fdstate);
- manager->common.magic = 0;
- manager->common.impmagic = 0;
free(manager);
*managerp = NULL;
@@ -1999,7 +1927,7 @@ isc__socketmgr_destroy(isc_socketmgr_t **managerp) {
}
static isc_result_t
-socket_recv(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
+socket_recv(isc_socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
unsigned int flags)
{
int io_state;
@@ -2059,24 +1987,22 @@ socket_recv(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
}
isc_result_t
-isc__socket_recvv(isc_socket_t *sock0, isc_bufferlist_t *buflist,
+isc_socket_recvv(isc_socket_t *sock0, isc_bufferlist_t *buflist,
unsigned int minimum, isc_task_t *task,
isc_taskaction_t action, void *arg)
{
- isc__socket_t *sock = (isc__socket_t *)sock0;
+ isc_socket_t *sock = (isc_socket_t *)sock0;
isc_socketevent_t *dev;
- isc__socketmgr_t *manager;
+ isc_socketmgr_t *manager;
unsigned int iocount;
isc_buffer_t *buffer;
- REQUIRE(VALID_SOCKET(sock));
REQUIRE(buflist != NULL);
REQUIRE(!ISC_LIST_EMPTY(*buflist));
REQUIRE(task != NULL);
REQUIRE(action != NULL);
manager = sock->manager;
- REQUIRE(VALID_MANAGER(manager));
iocount = isc_bufferlist_availablecount(buflist);
REQUIRE(iocount > 0);
@@ -2114,7 +2040,7 @@ isc__socket_recvv(isc_socket_t *sock0, isc_bufferlist_t *buflist,
}
static isc_result_t
-socket_send(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
+socket_send(isc_socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
isc_sockaddr_t *address, struct in6_pktinfo *pktinfo,
unsigned int flags)
{
@@ -2195,33 +2121,31 @@ socket_send(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
}
isc_result_t
-isc__socket_sendv(isc_socket_t *sock, isc_bufferlist_t *buflist,
+isc_socket_sendv(isc_socket_t *sock, isc_bufferlist_t *buflist,
isc_task_t *task, isc_taskaction_t action, void *arg)
{
- return (isc__socket_sendtov2(sock, buflist, task, action, arg, NULL,
+ return (isc_socket_sendtov2(sock, buflist, task, action, arg, NULL,
NULL, 0));
}
isc_result_t
-isc__socket_sendtov2(isc_socket_t *sock0, isc_bufferlist_t *buflist,
+isc_socket_sendtov2(isc_socket_t *sock0, isc_bufferlist_t *buflist,
isc_task_t *task, isc_taskaction_t action, void *arg,
isc_sockaddr_t *address, struct in6_pktinfo *pktinfo,
unsigned int flags)
{
- isc__socket_t *sock = (isc__socket_t *)sock0;
+ isc_socket_t *sock = (isc_socket_t *)sock0;
isc_socketevent_t *dev;
- isc__socketmgr_t *manager;
+ isc_socketmgr_t *manager;
unsigned int iocount;
isc_buffer_t *buffer;
- REQUIRE(VALID_SOCKET(sock));
REQUIRE(buflist != NULL);
REQUIRE(!ISC_LIST_EMPTY(*buflist));
REQUIRE(task != NULL);
REQUIRE(action != NULL);
manager = sock->manager;
- REQUIRE(VALID_MANAGER(manager));
iocount = isc_bufferlist_usedcount(buflist);
REQUIRE(iocount > 0);
@@ -2245,13 +2169,11 @@ isc__socket_sendtov2(isc_socket_t *sock0, isc_bufferlist_t *buflist,
}
isc_result_t
-isc__socket_bind(isc_socket_t *sock0, isc_sockaddr_t *sockaddr,
+isc_socket_bind(isc_socket_t *sock0, isc_sockaddr_t *sockaddr,
unsigned int options) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
+ isc_socket_t *sock = (isc_socket_t *)sock0;
int on = 1;
- REQUIRE(VALID_SOCKET(sock));
-
INSIST(!sock->bound);
if (sock->pf != sockaddr->type.sa.sa_family) {
@@ -2293,23 +2215,21 @@ isc__socket_bind(isc_socket_t *sock0, isc_sockaddr_t *sockaddr,
}
isc_result_t
-isc__socket_connect(isc_socket_t *sock0, isc_sockaddr_t *addr,
+isc_socket_connect(isc_socket_t *sock0, isc_sockaddr_t *addr,
isc_task_t *task, isc_taskaction_t action, void *arg)
{
- isc__socket_t *sock = (isc__socket_t *)sock0;
+ isc_socket_t *sock = (isc_socket_t *)sock0;
isc_socket_connev_t *dev;
isc_task_t *ntask = NULL;
- isc__socketmgr_t *manager;
+ isc_socketmgr_t *manager;
int cc;
char addrbuf[ISC_SOCKADDR_FORMATSIZE];
- REQUIRE(VALID_SOCKET(sock));
REQUIRE(addr != NULL);
REQUIRE(task != NULL);
REQUIRE(action != NULL);
manager = sock->manager;
- REQUIRE(VALID_MANAGER(manager));
REQUIRE(addr != NULL);
if (isc_sockaddr_ismulticast(addr))
@@ -2420,7 +2340,7 @@ isc__socket_connect(isc_socket_t *sock0, isc_sockaddr_t *addr,
*/
static void
internal_connect(isc_task_t *me, isc_event_t *ev) {
- isc__socket_t *sock;
+ isc_socket_t *sock;
isc_socket_connev_t *dev;
isc_task_t *task;
int cc;
@@ -2431,7 +2351,6 @@ internal_connect(isc_task_t *me, isc_event_t *ev) {
INSIST(ev->ev_type == ISC_SOCKEVENT_INTW);
sock = ev->ev_sender;
- INSIST(VALID_SOCKET(sock));
/*
* When the internal event was sent the reference count was bumped
@@ -2523,10 +2442,8 @@ internal_connect(isc_task_t *me, isc_event_t *ev) {
* queued for task "task" of type "how". "how" is a bitmask.
*/
void
-isc__socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) {
- isc__socket_t *sock = (isc__socket_t *)sock0;
-
- REQUIRE(VALID_SOCKET(sock));
+isc_socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) {
+ isc_socket_t *sock = (isc_socket_t *)sock0;
/*
* Quick exit if there is nothing to do. Don't even bother locking
@@ -2619,10 +2536,10 @@ isc__socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) {
static isc_socketwait_t swait_private;
int
-isc__socketmgr_waitevents(isc_socketmgr_t *manager0, struct timeval *tvp,
+isc_socketmgr_waitevents(isc_socketmgr_t *manager0, struct timeval *tvp,
isc_socketwait_t **swaitp)
{
- isc__socketmgr_t *manager = (isc__socketmgr_t *)manager0;
+ isc_socketmgr_t *manager = (isc_socketmgr_t *)manager0;
int n;
REQUIRE(swaitp != NULL && *swaitp == NULL);
@@ -2648,8 +2565,8 @@ isc__socketmgr_waitevents(isc_socketmgr_t *manager0, struct timeval *tvp,
}
isc_result_t
-isc__socketmgr_dispatch(isc_socketmgr_t *manager0, isc_socketwait_t *swait) {
- isc__socketmgr_t *manager = (isc__socketmgr_t *)manager0;
+isc_socketmgr_dispatch(isc_socketmgr_t *manager0, isc_socketwait_t *swait) {
+ isc_socketmgr_t *manager = (isc_socketmgr_t *)manager0;
REQUIRE(swait == &swait_private);
@@ -2661,5 +2578,3 @@ isc__socketmgr_dispatch(isc_socketmgr_t *manager0, isc_socketwait_t *swait) {
process_fds(manager, swait->maxfd, swait->readset, swait->writeset);
return (ISC_R_SUCCESS);
}
-
-#include "../socket_api.c"
diff --git a/usr.bin/dig/lib/isc/unix/socket_p.h b/usr.bin/dig/lib/isc/unix/socket_p.h
index ec3a83042a5..84f52f045bb 100644
--- a/usr.bin/dig/lib/isc/unix/socket_p.h
+++ b/usr.bin/dig/lib/isc/unix/socket_p.h
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: socket_p.h,v 1.1 2020/02/07 09:58:54 florian Exp $ */
+/* $Id: socket_p.h,v 1.2 2020/02/18 18:11:27 florian Exp $ */
#ifndef ISC_SOCKET_P_H
#define ISC_SOCKET_P_H
@@ -24,7 +24,7 @@
#include <sys/select.h>
typedef struct isc_socketwait isc_socketwait_t;
-int isc__socketmgr_waitevents(isc_socketmgr_t *, struct timeval *,
+int isc_socketmgr_waitevents(isc_socketmgr_t *, struct timeval *,
isc_socketwait_t **);
-isc_result_t isc__socketmgr_dispatch(isc_socketmgr_t *, isc_socketwait_t *);
+isc_result_t isc_socketmgr_dispatch(isc_socketmgr_t *, isc_socketwait_t *);
#endif /* ISC_SOCKET_P_H */