summaryrefslogtreecommitdiff
path: root/usr.sbin/bind
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/bind')
-rw-r--r--usr.sbin/bind/bin/dig/dighost.c56
-rw-r--r--usr.sbin/bind/lib/dns/lib.c14
-rw-r--r--usr.sbin/bind/lib/dns/master.c16
-rw-r--r--usr.sbin/bind/lib/dns/openssl_link.c2
-rw-r--r--usr.sbin/bind/lib/dns/rdata/in_1/wks_11.c17
-rw-r--r--usr.sbin/bind/lib/isc/Makefile.in6
-rw-r--r--usr.sbin/bind/lib/isc/app_api.c15
-rw-r--r--usr.sbin/bind/lib/isc/hash.c38
-rw-r--r--usr.sbin/bind/lib/isc/include/isc/Makefile.in2
-rw-r--r--usr.sbin/bind/lib/isc/include/isc/mutexblock.h70
-rw-r--r--usr.sbin/bind/lib/isc/include/isc/queue.h10
-rw-r--r--usr.sbin/bind/lib/isc/include/isc/refcount.h3
-rw-r--r--usr.sbin/bind/lib/isc/include/isc/util.h16
-rw-r--r--usr.sbin/bind/lib/isc/log.c32
-rw-r--r--usr.sbin/bind/lib/isc/mutexblock.c57
-rw-r--r--usr.sbin/bind/lib/isc/nothreads/include/isc/Makefile.in4
-rw-r--r--usr.sbin/bind/lib/isc/nothreads/include/isc/condition.h8
-rw-r--r--usr.sbin/bind/lib/isc/nothreads/include/isc/mutex.h36
-rw-r--r--usr.sbin/bind/lib/isc/nothreads/mutex.c24
-rw-r--r--usr.sbin/bind/lib/isc/refcount.c3
-rw-r--r--usr.sbin/bind/lib/isc/result.c13
-rw-r--r--usr.sbin/bind/lib/isc/socket_api.c19
-rw-r--r--usr.sbin/bind/lib/isc/task.c155
-rw-r--r--usr.sbin/bind/lib/isc/timer.c79
-rw-r--r--usr.sbin/bind/lib/isc/unix/app.c30
-rw-r--r--usr.sbin/bind/lib/isc/unix/socket.c238
-rw-r--r--usr.sbin/bind/lib/isc/unix/strerror.c18
27 files changed, 26 insertions, 955 deletions
diff --git a/usr.sbin/bind/bin/dig/dighost.c b/usr.sbin/bind/bin/dig/dighost.c
index 600022a960b..91fb5c6aeab 100644
--- a/usr.sbin/bind/bin/dig/dighost.c
+++ b/usr.sbin/bind/bin/dig/dighost.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: dighost.c,v 1.33 2020/01/20 18:51:52 florian Exp $ */
+/* $Id: dighost.c,v 1.34 2020/01/21 23:59:20 tedu Exp $ */
/*! \file
* \note
@@ -168,7 +168,6 @@ isc_boolean_t debugging = ISC_FALSE;
isc_boolean_t debugtiming = ISC_FALSE;
isc_boolean_t memdebugging = ISC_FALSE;
char *progname = NULL;
-isc_mutex_t lookup_lock;
dig_lookup_t *current_lookup = NULL;
#ifdef DIG_SIGCHASE
@@ -313,21 +312,6 @@ struct_tk_list tk_list = { {NULL, NULL, NULL, NULL, NULL}, 0};
#define DIG_MAX_ADDRESSES 20
-/*%
- * Apply and clear locks at the event level in global task.
- * Can I get rid of these using shutdown events? XXX
- */
-#define LOCK_LOOKUP {\
- debug("lock_lookup %s:%d", __FILE__, __LINE__);\
- check_result(isc_mutex_lock((&lookup_lock)), "isc_mutex_lock");\
- debug("success");\
-}
-#define UNLOCK_LOOKUP {\
- debug("unlock_lookup %s:%d", __FILE__, __LINE__);\
- check_result(isc_mutex_unlock((&lookup_lock)),\
- "isc_mutex_unlock");\
-}
-
/* dynamic callbacks */
#ifdef DIG_SIGCHASE
@@ -1574,9 +1558,6 @@ setup_libs(void) {
result = dst_lib_init();
check_result(result, "dst_lib_init");
is_dst_up = ISC_TRUE;
-
- result = isc_mutex_init(&lookup_lock);
- check_result(result, "isc_mutex_init");
}
typedef struct dig_ednsoptname {
@@ -2733,8 +2714,6 @@ send_done(isc_task_t *_task, isc_event_t *event) {
UNUSED(_task);
- LOCK_LOOKUP;
-
debug("send_done()");
sendcount--;
debug("sendcount=%d", sendcount);
@@ -2764,7 +2743,6 @@ send_done(isc_task_t *_task, isc_event_t *event) {
free(query);
check_if_done();
- UNLOCK_LOOKUP;
}
/*%
@@ -3046,7 +3024,6 @@ connect_timeout(isc_task_t *task, isc_event_t *event) {
debug("connect_timeout()");
- LOCK_LOOKUP;
query = event->ev_arg;
l = query->lookup;
isc_event_free(&event);
@@ -3066,7 +3043,6 @@ connect_timeout(isc_task_t *task, isc_event_t *event) {
ISC_SOCKCANCEL_ALL);
send_tcp_connect(ISC_LIST_NEXT(cq, link));
}
- UNLOCK_LOOKUP;
return;
}
@@ -3099,7 +3075,6 @@ connect_timeout(isc_task_t *task, isc_event_t *event) {
if (exitcode < 9)
exitcode = 9;
}
- UNLOCK_LOOKUP;
}
/*%
@@ -3122,7 +3097,6 @@ tcp_length_done(isc_task_t *task, isc_event_t *event) {
debug("tcp_length_done()");
- LOCK_LOOKUP;
sevent = (isc_socketevent_t *)event;
query = event->ev_arg;
@@ -3138,7 +3112,6 @@ tcp_length_done(isc_task_t *task, isc_event_t *event) {
l = query->lookup;
clear_query(query);
check_next_lookup(l);
- UNLOCK_LOOKUP;
return;
}
if (sevent->result != ISC_R_SUCCESS) {
@@ -3162,14 +3135,12 @@ tcp_length_done(isc_task_t *task, isc_event_t *event) {
clear_query(query);
cancel_lookup(l);
check_next_lookup(l);
- UNLOCK_LOOKUP;
return;
}
length = isc_buffer_getuint16(b);
if (length == 0) {
isc_event_free(&event);
launch_next_query(query, ISC_FALSE);
- UNLOCK_LOOKUP;
return;
}
@@ -3190,7 +3161,6 @@ tcp_length_done(isc_task_t *task, isc_event_t *event) {
debug("resubmitted recv request with length %d, recvcount=%d",
length, recvcount);
isc_event_free(&event);
- UNLOCK_LOOKUP;
}
/*%
@@ -3278,7 +3248,6 @@ connect_done(isc_task_t *task, isc_event_t *event) {
debug("connect_done()");
- LOCK_LOOKUP;
sevent = (isc_socketevent_t *)event;
query = sevent->ev_arg;
@@ -3303,7 +3272,6 @@ connect_done(isc_task_t *task, isc_event_t *event) {
l = query->lookup;
clear_query(query);
check_next_lookup(l);
- UNLOCK_LOOKUP;
return;
}
if (sevent->result != ISC_R_SUCCESS) {
@@ -3337,7 +3305,6 @@ connect_done(isc_task_t *task, isc_event_t *event) {
send_tcp_connect(next);
} else
check_next_lookup(l);
- UNLOCK_LOOKUP;
return;
}
if (keep_open) {
@@ -3348,7 +3315,6 @@ connect_done(isc_task_t *task, isc_event_t *event) {
}
launch_next_query(query, ISC_TRUE);
isc_event_free(&event);
- UNLOCK_LOOKUP;
}
/*%
@@ -3627,7 +3593,6 @@ recv_done(isc_task_t *task, isc_event_t *event) {
debug("recv_done()");
- LOCK_LOOKUP;
recvcount--;
debug("recvcount=%d", recvcount);
INSIST(recvcount >= 0);
@@ -3655,7 +3620,6 @@ recv_done(isc_task_t *task, isc_event_t *event) {
isc_event_free(&event);
clear_query(query);
check_next_lookup(l);
- UNLOCK_LOOKUP;
return;
}
@@ -3681,7 +3645,6 @@ recv_done(isc_task_t *task, isc_event_t *event) {
clear_query(query);
cancel_lookup(l);
check_next_lookup(l);
- UNLOCK_LOOKUP;
return;
}
@@ -3743,7 +3706,6 @@ recv_done(isc_task_t *task, isc_event_t *event) {
clear_query(query);
cancel_lookup(l);
check_next_lookup(l);
- UNLOCK_LOOKUP;
return;
}
match = ISC_TRUE;
@@ -3811,7 +3773,6 @@ recv_done(isc_task_t *task, isc_event_t *event) {
clear_query(query);
cancel_lookup(l);
check_next_lookup(l);
- UNLOCK_LOOKUP;
return;
}
if (msg->counts[DNS_SECTION_QUESTION] != 0) {
@@ -3855,7 +3816,6 @@ recv_done(isc_task_t *task, isc_event_t *event) {
clear_query(query);
cancel_lookup(l);
check_next_lookup(l);
- UNLOCK_LOOKUP;
return;
} else
goto udp_mismatch;
@@ -3878,7 +3838,6 @@ recv_done(isc_task_t *task, isc_event_t *event) {
clear_query(query);
cancel_lookup(l);
check_next_lookup(l);
- UNLOCK_LOOKUP;
return;
}
if ((msg->flags & DNS_MESSAGEFLAG_TC) != 0 &&
@@ -3896,7 +3855,6 @@ recv_done(isc_task_t *task, isc_event_t *event) {
clear_query(query);
cancel_lookup(l);
check_next_lookup(l);
- UNLOCK_LOOKUP;
return;
}
if ((msg->rcode == dns_rcode_servfail && !l->servfail_stops) ||
@@ -3930,7 +3888,6 @@ recv_done(isc_task_t *task, isc_event_t *event) {
check_next_lookup(l);
dns_message_destroy(&msg);
isc_event_free(&event);
- UNLOCK_LOOKUP;
return;
}
}
@@ -4101,7 +4058,6 @@ recv_done(isc_task_t *task, isc_event_t *event) {
dns_message_destroy(&msg);
isc_event_free(&event);
query->waiting_connect = ISC_FALSE;
- UNLOCK_LOOKUP;
return;
}
if (!docancel)
@@ -4145,7 +4101,6 @@ recv_done(isc_task_t *task, isc_event_t *event) {
dns_message_destroy(&msg);
}
isc_event_free(&event);
- UNLOCK_LOOKUP;
return;
udp_mismatch:
@@ -4157,7 +4112,6 @@ recv_done(isc_task_t *task, isc_event_t *event) {
check_result(result, "isc_socket_recvv");
recvcount++;
isc_event_free(&event);
- UNLOCK_LOOKUP;
return;
}
@@ -4244,9 +4198,7 @@ onrun_callback(isc_task_t *task, isc_event_t *event) {
UNUSED(task);
isc_event_free(&event);
- LOCK_LOOKUP;
start_lookup();
- UNLOCK_LOOKUP;
}
/*%
@@ -4260,9 +4212,7 @@ cancel_all(void) {
debug("cancel_all()");
- LOCK_LOOKUP;
if (free_now) {
- UNLOCK_LOOKUP;
return;
}
cancel_now = ISC_TRUE;
@@ -4301,7 +4251,6 @@ cancel_all(void) {
try_clear_lookup(l);
l = n;
}
- UNLOCK_LOOKUP;
}
/*%
@@ -4330,7 +4279,6 @@ destroy_libs(void) {
debug("freeing taskmgr");
isc_taskmgr_destroy(&taskmgr);
}
- LOCK_LOOKUP;
REQUIRE(sockcount == 0);
REQUIRE(recvcount == 0);
REQUIRE(sendcount == 0);
@@ -4370,8 +4318,6 @@ destroy_libs(void) {
is_dst_up = ISC_FALSE;
}
- UNLOCK_LOOKUP;
- DESTROYLOCK(&lookup_lock);
#ifdef DIG_SIGCHASE
debug("Destroy the messages kept for sigchase");
diff --git a/usr.sbin/bind/lib/dns/lib.c b/usr.sbin/bind/lib/dns/lib.c
index fcba11db4aa..55dd08d1b04 100644
--- a/usr.sbin/bind/lib/dns/lib.c
+++ b/usr.sbin/bind/lib/dns/lib.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: lib.c,v 1.8 2020/01/20 18:51:52 florian Exp $ */
+/* $Id: lib.c,v 1.9 2020/01/21 23:59:20 tedu Exp $ */
/*! \file */
@@ -25,7 +25,6 @@
#include <isc/hash.h>
-#include <isc/mutex.h>
#include <isc/once.h>
#include <isc/util.h>
@@ -49,7 +48,6 @@ unsigned int dns_pps = 0U;
static isc_once_t init_once = ISC_ONCE_INIT;
static isc_boolean_t initialize_done = ISC_FALSE;
-static isc_mutex_t reflock;
static unsigned int references = 0;
static void
@@ -67,15 +65,9 @@ initialize(void) {
if (result != ISC_R_SUCCESS)
goto cleanup_hash;
- result = isc_mutex_init(&reflock);
- if (result != ISC_R_SUCCESS)
- goto cleanup_dst;
-
initialize_done = ISC_TRUE;
return;
- cleanup_dst:
- dst_lib_destroy();
cleanup_hash:
isc_hash_destroy();
}
@@ -96,9 +88,7 @@ dns_lib_init(void) {
if (!initialize_done)
return (ISC_R_FAILURE);
- LOCK(&reflock);
references++;
- UNLOCK(&reflock);
return (ISC_R_SUCCESS);
}
@@ -107,10 +97,8 @@ void
dns_lib_shutdown(void) {
isc_boolean_t cleanup_ok = ISC_FALSE;
- LOCK(&reflock);
if (--references == 0)
cleanup_ok = ISC_TRUE;
- UNLOCK(&reflock);
if (!cleanup_ok)
return;
diff --git a/usr.sbin/bind/lib/dns/master.c b/usr.sbin/bind/lib/dns/master.c
index fc78d33846d..1bfc0bfaef3 100644
--- a/usr.sbin/bind/lib/dns/master.c
+++ b/usr.sbin/bind/lib/dns/master.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: master.c,v 1.12 2020/01/20 18:51:52 florian Exp $ */
+/* $Id: master.c,v 1.13 2020/01/21 23:59:20 tedu Exp $ */
/*! \file */
@@ -23,7 +23,6 @@
#include <isc/event.h>
#include <isc/lex.h>
#include <isc/magic.h>
-#include <isc/mutex.h>
#include <isc/serial.h>
#include <isc/stdio.h>
@@ -152,7 +151,6 @@ struct dns_loadctx {
unsigned int loop_cnt; /*% records per quantum,
* 0 => all. */
isc_boolean_t canceled;
- isc_mutex_t lock;
isc_result_t result;
/* locked by lock */
uint32_t references;
@@ -403,11 +401,9 @@ dns_loadctx_attach(dns_loadctx_t *source, dns_loadctx_t **target) {
REQUIRE(target != NULL && *target == NULL);
REQUIRE(DNS_LCTX_VALID(source));
- LOCK(&source->lock);
INSIST(source->references > 0);
source->references++;
INSIST(source->references != 0); /* Overflow? */
- UNLOCK(&source->lock);
*target = source;
}
@@ -421,12 +417,10 @@ dns_loadctx_detach(dns_loadctx_t **lctxp) {
lctx = *lctxp;
REQUIRE(DNS_LCTX_VALID(lctx));
- LOCK(&lctx->lock);
INSIST(lctx->references > 0);
lctx->references--;
if (lctx->references == 0)
need_destroy = ISC_TRUE;
- UNLOCK(&lctx->lock);
if (need_destroy)
loadctx_destroy(lctx);
@@ -474,7 +468,6 @@ loadctx_destroy(dns_loadctx_t *lctx) {
if (lctx->task != NULL)
isc_task_detach(&lctx->task);
- DESTROYLOCK(&lctx->lock);
free(lctx);
}
@@ -540,11 +533,6 @@ loadctx_create(dns_masterformat_t format,
lctx = malloc(sizeof(*lctx));
if (lctx == NULL)
return (ISC_R_NOMEMORY);
- result = isc_mutex_init(&lctx->lock);
- if (result != ISC_R_SUCCESS) {
- free(lctx);
- return (result);
- }
lctx->inc = NULL;
result = incctx_create(origin, &lctx->inc);
@@ -3220,9 +3208,7 @@ void
dns_loadctx_cancel(dns_loadctx_t *lctx) {
REQUIRE(DNS_LCTX_VALID(lctx));
- LOCK(&lctx->lock);
lctx->canceled = ISC_TRUE;
- UNLOCK(&lctx->lock);
}
void
diff --git a/usr.sbin/bind/lib/dns/openssl_link.c b/usr.sbin/bind/lib/dns/openssl_link.c
index e084a2920e6..ecca3eaecdb 100644
--- a/usr.sbin/bind/lib/dns/openssl_link.c
+++ b/usr.sbin/bind/lib/dns/openssl_link.c
@@ -39,8 +39,6 @@
#include <stdlib.h>
-#include <isc/mutex.h>
-#include <isc/mutexblock.h>
#include <string.h>
#include <isc/thread.h>
#include <isc/util.h>
diff --git a/usr.sbin/bind/lib/dns/rdata/in_1/wks_11.c b/usr.sbin/bind/lib/dns/rdata/in_1/wks_11.c
index a4f6d1b6d0f..e081c62fedc 100644
--- a/usr.sbin/bind/lib/dns/rdata/in_1/wks_11.c
+++ b/usr.sbin/bind/lib/dns/rdata/in_1/wks_11.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: wks_11.c,v 1.10 2020/01/20 18:51:53 florian Exp $ */
+/* $Id: wks_11.c,v 1.11 2020/01/21 23:59:20 tedu Exp $ */
/* Reviewed: Fri Mar 17 15:01:49 PST 2000 by explorer */
@@ -26,8 +26,6 @@
#include <isc/net.h>
#include <isc/netdb.h>
-#include <isc/once.h>
-#include <isc/mutex.h>
/*
* Redefine CHECK here so cppcheck "sees" the define.
@@ -41,21 +39,13 @@
#define RRTYPE_WKS_ATTRIBUTES (0)
-static isc_mutex_t wks_lock;
-
-static void init_lock(void) {
- RUNTIME_CHECK(isc_mutex_init(&wks_lock) == ISC_R_SUCCESS);
-}
-
static isc_boolean_t
mygetprotobyname(const char *name, long *proto) {
struct protoent *pe;
- LOCK(&wks_lock);
pe = getprotobyname(name);
if (pe != NULL)
*proto = pe->p_proto;
- UNLOCK(&wks_lock);
return (ISC_TF(pe != NULL));
}
@@ -63,17 +53,14 @@ static isc_boolean_t
mygetservbyname(const char *name, const char *proto, long *port) {
struct servent *se;
- LOCK(&wks_lock);
se = getservbyname(name, proto);
if (se != NULL)
*port = ntohs(se->s_port);
- UNLOCK(&wks_lock);
return (ISC_TF(se != NULL));
}
static inline isc_result_t
fromtext_in_wks(ARGS_FROMTEXT) {
- static isc_once_t once = ISC_ONCE_INIT;
isc_token_t token;
isc_region_t region;
struct in_addr addr;
@@ -96,8 +83,6 @@ fromtext_in_wks(ARGS_FROMTEXT) {
UNUSED(options);
UNUSED(rdclass);
- RUNTIME_CHECK(isc_once_do(&once, init_lock) == ISC_R_SUCCESS);
-
/*
* IPv4 dotted quad.
*/
diff --git a/usr.sbin/bind/lib/isc/Makefile.in b/usr.sbin/bind/lib/isc/Makefile.in
index 1a4d672eea3..1f624aa6cd4 100644
--- a/usr.sbin/bind/lib/isc/Makefile.in
+++ b/usr.sbin/bind/lib/isc/Makefile.in
@@ -37,7 +37,7 @@ UNIXOBJS = @ISC_ISCIPV6_O@ @ISC_ISCPK11_API_O@ \
unix/socket.@O@ unix/stdio.@O@ \
unix/stdtime.@O@ unix/strerror.@O@ unix/syslog.@O@ unix/time.@O@
-THREADOPTOBJS = nothreads/condition.@O@ nothreads/mutex.@O@
+THREADOPTOBJS = nothreads/condition.@O@
THREADOBJS = nothreads/thread.@O@
@@ -49,7 +49,7 @@ OBJS = @ISC_EXTRA_OBJS@ @ISC_PK11_O@ @ISC_PK11_RESULT_O@ \
hash.@O@ heap.@O@ hex.@O@ hmacmd5.@O@ hmacsha.@O@ \
inet_aton.@O@ iterated_hash.@O@ \
lex.@O@ log.@O@ \
- md5.@O@ mutexblock.@O@ \
+ md5.@O@ \
netaddr.@O@ netscope.@O@ \
parseint.@O@ \
refcount.@O@ region.@O@ regex.@O@ result.@O@ \
@@ -65,8 +65,8 @@ SRCS = @ISC_EXTRA_SRCS@ @ISC_PK11_C@ @ISC_PK11_RESULT_C@ \
buffer.c bufferlist.c commandline.c \
error.c event.c heap.c hex.c hmacmd5.c hmacsha.c \
inet_aton.c iterated_hash.c \
+ md5.c \
lex.c log.c \
- md5.c mutexblock.c \
netaddr.c netscope.c \
parseint.c \
refcount.c region.c regex.c result.c rwlock.c \
diff --git a/usr.sbin/bind/lib/isc/app_api.c b/usr.sbin/bind/lib/isc/app_api.c
index eff52b5154c..20e5d107523 100644
--- a/usr.sbin/bind/lib/isc/app_api.c
+++ b/usr.sbin/bind/lib/isc/app_api.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: app_api.c,v 1.4 2020/01/21 10:11:09 deraadt Exp $ */
+/* $Id: app_api.c,v 1.5 2020/01/21 23:59:20 tedu Exp $ */
#include <config.h>
@@ -22,34 +22,21 @@
#include <isc/app.h>
#include <isc/magic.h>
-#include <isc/mutex.h>
-#include <isc/once.h>
#include <isc/util.h>
-static isc_mutex_t createlock;
-static isc_once_t once = ISC_ONCE_INIT;
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)
-static void
-initialize(void) {
- RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
-}
-
isc_result_t
isc_app_register(isc_appctxcreatefunc_t createfunc) {
isc_result_t result = ISC_R_SUCCESS;
- RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
-
- LOCK(&createlock);
if (appctx_createfunc == NULL)
appctx_createfunc = createfunc;
else
result = ISC_R_EXISTS;
- UNLOCK(&createlock);
return (result);
}
diff --git a/usr.sbin/bind/lib/isc/hash.c b/usr.sbin/bind/lib/isc/hash.c
index 97e3ce6b116..e4b48920a30 100644
--- a/usr.sbin/bind/lib/isc/hash.c
+++ b/usr.sbin/bind/lib/isc/hash.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: hash.c,v 1.10 2020/01/20 18:51:53 florian Exp $ */
+/* $Id: hash.c,v 1.11 2020/01/21 23:59:20 tedu Exp $ */
/*! \file
* Some portion of this code was derived from universal hash function
@@ -61,7 +61,6 @@ if advised of the possibility of such damage.
#include <isc/hash.h>
#include <isc/magic.h>
-#include <isc/mutex.h>
#include <isc/once.h>
#include <isc/refcount.h>
@@ -88,7 +87,6 @@ typedef uint16_t hash_random_t;
/*% isc hash structure */
struct isc_hash {
unsigned int magic;
- isc_mutex_t lock;
isc_boolean_t initialized;
isc_refcount_t refcnt;
size_t limit; /*%< upper limit of key length */
@@ -96,8 +94,6 @@ struct isc_hash {
hash_random_t *rndvector; /*%< random vector for universal hashing */
};
-static isc_mutex_t createlock;
-static isc_once_t once = ISC_ONCE_INIT;
static isc_hash_t *hash = NULL;
static unsigned char maptolower[] = {
@@ -168,13 +164,6 @@ isc_hash_ctxcreate(size_t limit, isc_hash_t **hctxp)
}
/*
- * We need a lock.
- */
- result = isc_mutex_init(&hctx->lock);
- if (result != ISC_R_SUCCESS)
- goto errout;
-
- /*
* From here down, no failures will/can occur.
*/
hctx->magic = HASH_MAGIC;
@@ -190,7 +179,6 @@ isc_hash_ctxcreate(size_t limit, isc_hash_t **hctxp)
return (ISC_R_SUCCESS);
cleanup_lock:
- DESTROYLOCK(&hctx->lock);
errout:
free(hctx);
if (rv != NULL)
@@ -199,41 +187,25 @@ isc_hash_ctxcreate(size_t limit, isc_hash_t **hctxp)
return (result);
}
-static void
-initialize_lock(void) {
- RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
-}
-
isc_result_t
isc_hash_create(size_t limit) {
isc_result_t result = ISC_R_SUCCESS;
INSIST(hash == NULL);
- RUNTIME_CHECK(isc_once_do(&once, initialize_lock) == ISC_R_SUCCESS);
-
- LOCK(&createlock);
-
if (hash == NULL)
result = isc_hash_ctxcreate(limit, &hash);
- UNLOCK(&createlock);
-
return (result);
}
void
isc_hash_ctxinit(isc_hash_t *hctx) {
- LOCK(&hctx->lock);
-
if (hctx->initialized == ISC_TRUE)
- goto out;
+ return
arc4random_buf(hctx->rndvector, hctx->vectorlen);
hctx->initialized = ISC_TRUE;
-
- out:
- UNLOCK(&hctx->lock);
}
void
@@ -260,17 +232,11 @@ destroy(isc_hash_t **hctxp) {
hctx = *hctxp;
*hctxp = NULL;
- LOCK(&hctx->lock);
-
isc_refcount_destroy(&hctx->refcnt);
if (hctx->rndvector != NULL)
free(hctx->rndvector);
- UNLOCK(&hctx->lock);
-
- DESTROYLOCK(&hctx->lock);
-
memset(hctx, 0, sizeof(isc_hash_t));
free(hctx);
}
diff --git a/usr.sbin/bind/lib/isc/include/isc/Makefile.in b/usr.sbin/bind/lib/isc/include/isc/Makefile.in
index 4d52dcce6e9..c934670a984 100644
--- a/usr.sbin/bind/lib/isc/include/isc/Makefile.in
+++ b/usr.sbin/bind/lib/isc/include/isc/Makefile.in
@@ -30,7 +30,7 @@ HEADERS = aes.h app.h assertions.h base32.h base64.h \
hash.h heap.h hex.h hmacmd5.h hmacsha.h \
@ISC_IPV6_H@ iterated_hash.h \
lang.h lex.h lib.h likely.h list.h log.h \
- magic.h md5.h msgs.h mutexblock.h \
+ magic.h md5.h msgs.h \
netaddr.h netscope.h parseint.h \
print.h queue.h \
refcount.h regex.h \
diff --git a/usr.sbin/bind/lib/isc/include/isc/mutexblock.h b/usr.sbin/bind/lib/isc/include/isc/mutexblock.h
deleted file mode 100644
index 4976abc45c9..00000000000
--- a/usr.sbin/bind/lib/isc/include/isc/mutexblock.h
+++ /dev/null
@@ -1,70 +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: mutexblock.h,v 1.3 2019/12/17 01:46:35 sthen Exp $ */
-
-#ifndef ISC_MUTEXBLOCK_H
-#define ISC_MUTEXBLOCK_H 1
-
-/*! \file isc/mutexblock.h */
-
-#include <isc/lang.h>
-#include <isc/mutex.h>
-#include <isc/types.h>
-
-ISC_LANG_BEGINDECLS
-
-isc_result_t
-isc_mutexblock_init(isc_mutex_t *block, unsigned int count);
-/*%<
- * Initialize a block of locks. If an error occurs all initialized locks
- * will be destroyed, if possible.
- *
- * Requires:
- *
- *\li block != NULL
- *
- *\li count > 0
- *
- * Returns:
- *
- *\li Any code isc_mutex_init() can return is a valid return for this
- * function.
- */
-
-isc_result_t
-isc_mutexblock_destroy(isc_mutex_t *block, unsigned int count);
-/*%<
- * Destroy a block of locks.
- *
- * Requires:
- *
- *\li block != NULL
- *
- *\li count > 0
- *
- *\li Each lock in the block be initialized via isc_mutex_init() or
- * the whole block was initialized via isc_mutex_initblock().
- *
- * Returns:
- *
- *\li Any code isc_mutex_init() can return is a valid return for this
- * function.
- */
-
-ISC_LANG_ENDDECLS
-
-#endif /* ISC_MUTEXBLOCK_H */
diff --git a/usr.sbin/bind/lib/isc/include/isc/queue.h b/usr.sbin/bind/lib/isc/include/isc/queue.h
index 52bcdb62716..749b99ccbf4 100644
--- a/usr.sbin/bind/lib/isc/include/isc/queue.h
+++ b/usr.sbin/bind/lib/isc/include/isc/queue.h
@@ -14,12 +14,10 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: queue.h,v 1.2 2019/12/17 01:46:35 sthen Exp $ */
+/* $Id: queue.h,v 1.3 2020/01/21 23:59:20 tedu Exp $ */
/*
* This is a generic implementation of a two-lock concurrent queue.
- * There are built-in mutex locks for the head and tail of the queue,
- * allowing elements to be safely added and removed at the same time.
*
* NULL is "end of list"
* -1 is "not linked"
@@ -29,7 +27,6 @@
#define ISC_QUEUE_H 1
#include <isc/assertions.h>
#include <isc/boolean.h>
-#include <isc/mutex.h>
#ifdef ISC_QUEUE_CHECKINIT
#define ISC_QLINK_INSIST(x) ISC_INSIST(x)
@@ -48,13 +45,10 @@
#define ISC_QUEUE(type) struct { \
type *head, *tail; \
- isc_mutex_t headlock, taillock; \
}
#define ISC_QUEUE_INIT(queue, link) \
do { \
- (void) isc_mutex_init(&(queue).taillock); \
- (void) isc_mutex_init(&(queue).headlock); \
(queue).tail = (queue).head = NULL; \
} while (0)
@@ -63,8 +57,6 @@
#define ISC_QUEUE_DESTROY(queue) \
do { \
ISC_QLINK_INSIST(ISC_QUEUE_EMPTY(queue)); \
- (void) isc_mutex_destroy(&(queue).taillock); \
- (void) isc_mutex_destroy(&(queue).headlock); \
} while (0)
/*
diff --git a/usr.sbin/bind/lib/isc/include/isc/refcount.h b/usr.sbin/bind/lib/isc/include/isc/refcount.h
index 0982d1afdff..68eecc63dd8 100644
--- a/usr.sbin/bind/lib/isc/include/isc/refcount.h
+++ b/usr.sbin/bind/lib/isc/include/isc/refcount.h
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: refcount.h,v 1.8 2020/01/09 18:14:48 florian Exp $ */
+/* $Id: refcount.h,v 1.9 2020/01/21 23:59:20 tedu Exp $ */
#ifndef ISC_REFCOUNT_H
#define ISC_REFCOUNT_H 1
@@ -23,7 +23,6 @@
#include <isc/error.h>
#include <isc/lang.h>
-#include <isc/mutex.h>
#include <isc/platform.h>
#include <isc/types.h>
diff --git a/usr.sbin/bind/lib/isc/include/isc/util.h b/usr.sbin/bind/lib/isc/include/isc/util.h
index f12b515118a..518c3a5f7d2 100644
--- a/usr.sbin/bind/lib/isc/include/isc/util.h
+++ b/usr.sbin/bind/lib/isc/include/isc/util.h
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: util.h,v 1.4 2020/01/20 18:46:57 florian Exp $ */
+/* $Id: util.h,v 1.5 2020/01/21 23:59:20 tedu Exp $ */
#ifndef ISC_UTIL_H
#define ISC_UTIL_H 1
@@ -87,17 +87,6 @@
#include <isc/result.h> /* Contractual promise. */
-#define LOCK(lp) do { \
- RUNTIME_CHECK(isc_mutex_lock((lp)) == ISC_R_SUCCESS); \
- } while (0)
-#define UNLOCK(lp) do { \
- RUNTIME_CHECK(isc_mutex_unlock((lp)) == ISC_R_SUCCESS); \
- } while (0)
-#define ISLOCKED(lp) (1)
-#define DESTROYLOCK(lp) \
- RUNTIME_CHECK(isc_mutex_destroy((lp)) == ISC_R_SUCCESS)
-
-
#define BROADCAST(cvp) do { \
RUNTIME_CHECK(isc_condition_broadcast((cvp)) == ISC_R_SUCCESS); \
} while (0)
@@ -125,9 +114,6 @@
RUNTIME_CHECK(isc_rwlock_unlock((lp), (t)) == ISC_R_SUCCESS); \
} while (0)
-#define DESTROYMUTEXBLOCK(bp, n) \
- RUNTIME_CHECK(isc_mutexblock_destroy((bp), (n)) == ISC_R_SUCCESS)
-
/*
* List Macros.
*/
diff --git a/usr.sbin/bind/lib/isc/log.c b/usr.sbin/bind/lib/isc/log.c
index 8ddd8b2dd51..bacf4d37d46 100644
--- a/usr.sbin/bind/lib/isc/log.c
+++ b/usr.sbin/bind/lib/isc/log.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: log.c,v 1.18 2020/01/20 18:51:53 florian Exp $ */
+/* $Id: log.c,v 1.19 2020/01/21 23:59:20 tedu Exp $ */
/*! \file
* \author Principal Authors: DCL */
@@ -32,7 +32,6 @@
#include <isc/file.h>
#include <isc/log.h>
#include <isc/magic.h>
-#include <isc/mutex.h>
#include <isc/msgs.h>
#include <isc/stat.h>
@@ -148,7 +147,6 @@ struct isc_log {
isc_logmodule_t * modules;
unsigned int module_count;
int debug_level;
- isc_mutex_t lock;
/* Locked by isc_log lock. */
isc_logconfig_t * logconfig;
char buffer[LOG_BUFFER_SIZE];
@@ -280,12 +278,6 @@ isc_log_create(isc_log_t **lctxp, isc_logconfig_t **lcfgp) {
ISC_LIST_INIT(lctx->messages);
- result = isc_mutex_init(&lctx->lock);
- if (result != ISC_R_SUCCESS) {
- free(lctx);
- return (result);
- }
-
/*
* Normally setting the magic number is the last step done
* in a creation function, but a valid log context is needed
@@ -441,13 +433,9 @@ isc_logconfig_use(isc_log_t *lctx, isc_logconfig_t *lcfg) {
if (result != ISC_R_SUCCESS)
return (result);
- LOCK(&lctx->lock);
-
old_cfg = lctx->logconfig;
lctx->logconfig = lcfg;
- UNLOCK(&lctx->lock);
-
isc_logconfig_destroy(&old_cfg);
return (ISC_R_SUCCESS);
@@ -468,8 +456,6 @@ isc_log_destroy(isc_log_t **lctxp) {
isc_logconfig_destroy(&lcfg);
}
- DESTROYLOCK(&lctx->lock);
-
while ((message = ISC_LIST_HEAD(lctx->messages)) != NULL) {
ISC_LIST_UNLINK(lctx->messages, message, link);
@@ -871,8 +857,6 @@ isc_log_setdebuglevel(isc_log_t *lctx, unsigned int level) {
REQUIRE(VALID_CONTEXT(lctx));
- LOCK(&lctx->lock);
-
lctx->debug_level = level;
/*
* Close ISC_LOG_DEBUGONLY channels if level is zero.
@@ -887,7 +871,6 @@ isc_log_setdebuglevel(isc_log_t *lctx, unsigned int level) {
(void)fclose(FILE_STREAM(channel));
FILE_STREAM(channel) = NULL;
}
- UNLOCK(&lctx->lock);
}
unsigned int
@@ -950,7 +933,6 @@ isc_log_closefilelogs(isc_log_t *lctx) {
REQUIRE(VALID_CONTEXT(lctx));
- LOCK(&lctx->lock);
for (channel = ISC_LIST_HEAD(lctx->logconfig->channels);
channel != NULL;
channel = ISC_LIST_NEXT(channel, link))
@@ -960,7 +942,6 @@ isc_log_closefilelogs(isc_log_t *lctx) {
(void)fclose(FILE_STREAM(channel));
FILE_STREAM(channel) = NULL;
}
- UNLOCK(&lctx->lock);
}
/****
@@ -1280,10 +1261,6 @@ isc_log_open(isc_logchannel_t *channel) {
isc_boolean_t
isc_log_wouldlog(isc_log_t *lctx, int level) {
/*
- * Try to avoid locking the mutex for messages which can't
- * possibly be logged to any channels -- primarily debugging
- * messages that the debug level is not high enough to print.
- *
* If the level is (mathematically) less than or equal to the
* highest_level, or if there is a dynamic channel and the level is
* less than or equal to the debug level, the main loop must be
@@ -1347,8 +1324,6 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
time_string[0] = '\0';
level_string[0] = '\0';
- LOCK(&lctx->lock);
-
lctx->buffer[0] = '\0';
lcfg = lctx->logconfig;
@@ -1500,10 +1475,7 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
== 0) {
/*
* ... and it is a duplicate.
- * Unlock the mutex and
- * get the hell out of Dodge.
*/
- UNLOCK(&lctx->lock);
return;
}
@@ -1661,6 +1633,4 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
}
} while (1);
-
- UNLOCK(&lctx->lock);
}
diff --git a/usr.sbin/bind/lib/isc/mutexblock.c b/usr.sbin/bind/lib/isc/mutexblock.c
deleted file mode 100644
index 781bdcf9a6a..00000000000
--- a/usr.sbin/bind/lib/isc/mutexblock.c
+++ /dev/null
@@ -1,57 +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: mutexblock.c,v 1.3 2019/12/17 01:46:34 sthen Exp $ */
-
-/*! \file */
-
-#include <config.h>
-
-#include <isc/mutexblock.h>
-#include <isc/util.h>
-
-isc_result_t
-isc_mutexblock_init(isc_mutex_t *block, unsigned int count) {
- isc_result_t result;
- unsigned int i;
-
- for (i = 0; i < count; i++) {
- result = isc_mutex_init(&block[i]);
- if (result != ISC_R_SUCCESS) {
- while (i > 0U) {
- i--;
- DESTROYLOCK(&block[i]);
- }
- return (result);
- }
- }
-
- return (ISC_R_SUCCESS);
-}
-
-isc_result_t
-isc_mutexblock_destroy(isc_mutex_t *block, unsigned int count) {
- isc_result_t result;
- unsigned int i;
-
- for (i = 0; i < count; i++) {
- result = isc_mutex_destroy(&block[i]);
- if (result != ISC_R_SUCCESS)
- return (result);
- }
-
- return (ISC_R_SUCCESS);
-}
diff --git a/usr.sbin/bind/lib/isc/nothreads/include/isc/Makefile.in b/usr.sbin/bind/lib/isc/nothreads/include/isc/Makefile.in
index 8900f7dcb04..ec56e0d6e02 100644
--- a/usr.sbin/bind/lib/isc/nothreads/include/isc/Makefile.in
+++ b/usr.sbin/bind/lib/isc/nothreads/include/isc/Makefile.in
@@ -12,7 +12,7 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
-# $Id: Makefile.in,v 1.3 2019/12/17 01:46:36 sthen Exp $
+# $Id: Makefile.in,v 1.4 2020/01/21 23:59:20 tedu Exp $
srcdir = @srcdir@
VPATH = @srcdir@
@@ -20,7 +20,7 @@ top_srcdir = @top_srcdir@
VERSION=@BIND9_VERSION@
-HEADERS = condition.h mutex.h once.h thread.h
+HEADERS = condition.h once.h thread.h
SUBDIRS =
TARGETS =
diff --git a/usr.sbin/bind/lib/isc/nothreads/include/isc/condition.h b/usr.sbin/bind/lib/isc/nothreads/include/isc/condition.h
index 86b0b880b8d..81da3f636c5 100644
--- a/usr.sbin/bind/lib/isc/nothreads/include/isc/condition.h
+++ b/usr.sbin/bind/lib/isc/nothreads/include/isc/condition.h
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: condition.h,v 1.3 2019/12/17 01:46:36 sthen Exp $ */
+/* $Id: condition.h,v 1.4 2020/01/21 23:59:20 tedu Exp $ */
/*
* This provides a limited subset of the isc_condition_t
@@ -30,18 +30,16 @@
#ifndef ISC_CONDITION_H
#define ISC_CONDITION_H 1
-#include <isc/mutex.h>
-
typedef int isc_condition_t;
-isc_result_t isc__nothread_wait_hack(isc_condition_t *cp, isc_mutex_t *mp);
+isc_result_t isc__nothread_wait_hack(isc_condition_t *cp);
isc_result_t isc__nothread_signal_hack(isc_condition_t *cp);
#define isc_condition_init(cp) \
(*(cp) = 0, ISC_R_SUCCESS)
#define isc_condition_wait(cp, mp) \
- isc__nothread_wait_hack(cp, mp)
+ isc__nothread_wait_hack(cp)
#define isc_condition_waituntil(cp, mp, tp) \
((void)(cp), (void)(mp), (void)(tp), ISC_R_NOTIMPLEMENTED)
diff --git a/usr.sbin/bind/lib/isc/nothreads/include/isc/mutex.h b/usr.sbin/bind/lib/isc/nothreads/include/isc/mutex.h
deleted file mode 100644
index 41ce1613424..00000000000
--- a/usr.sbin/bind/lib/isc/nothreads/include/isc/mutex.h
+++ /dev/null
@@ -1,36 +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.
- */
-
-#ifndef ISC_MUTEX_H
-#define ISC_MUTEX_H 1
-
-#include <isc/result.h> /* for ISC_R_ codes */
-
-typedef int isc_mutex_t;
-
-#define isc_mutex_init(mp) \
- (*(mp) = 0, ISC_R_SUCCESS)
-#define isc_mutex_lock(mp) \
- ((*(mp))++ == 0 ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)
-#define isc_mutex_unlock(mp) \
- (--(*(mp)) == 0 ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)
-#define isc_mutex_trylock(mp) \
- (*(mp) == 0 ? ((*(mp))++, ISC_R_SUCCESS) : ISC_R_LOCKBUSY)
-#define isc_mutex_destroy(mp) \
- (*(mp) == 0 ? (*(mp) = -1, ISC_R_SUCCESS) : ISC_R_UNEXPECTED)
-#define isc_mutex_stats(fp)
-
-#endif /* ISC_MUTEX_H */
diff --git a/usr.sbin/bind/lib/isc/nothreads/mutex.c b/usr.sbin/bind/lib/isc/nothreads/mutex.c
deleted file mode 100644
index 794ab0ce0af..00000000000
--- a/usr.sbin/bind/lib/isc/nothreads/mutex.c
+++ /dev/null
@@ -1,24 +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: mutex.c,v 1.3 2019/12/17 01:46:36 sthen Exp $ */
-
-#include <config.h>
-
-#include <isc/util.h>
-
-EMPTY_TRANSLATION_UNIT
-
diff --git a/usr.sbin/bind/lib/isc/refcount.c b/usr.sbin/bind/lib/isc/refcount.c
index b734b99e421..475b459adc6 100644
--- a/usr.sbin/bind/lib/isc/refcount.c
+++ b/usr.sbin/bind/lib/isc/refcount.c
@@ -14,13 +14,12 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: refcount.c,v 1.4 2020/01/07 19:08:09 florian Exp $ */
+/* $Id: refcount.c,v 1.5 2020/01/21 23:59:20 tedu Exp $ */
#include <config.h>
#include <stddef.h>
-#include <isc/mutex.h>
#include <isc/refcount.h>
#include <isc/result.h>
#include <isc/util.h>
diff --git a/usr.sbin/bind/lib/isc/result.c b/usr.sbin/bind/lib/isc/result.c
index 7207140caa4..a2764971905 100644
--- a/usr.sbin/bind/lib/isc/result.c
+++ b/usr.sbin/bind/lib/isc/result.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: result.c,v 1.4 2020/01/20 18:46:57 florian Exp $ */
+/* $Id: result.c,v 1.5 2020/01/21 23:59:20 tedu Exp $ */
/*! \file */
@@ -25,7 +25,6 @@
#include <isc/lib.h>
#include <isc/msgs.h>
-#include <isc/mutex.h>
#include <isc/once.h>
#include <isc/resultclass.h>
#include <isc/util.h>
@@ -110,7 +109,6 @@ static const char *description[ISC_R_NRESULTS] = {
static isc_once_t once = ISC_ONCE_INIT;
static ISC_LIST(resulttable) tables;
-static isc_mutex_t lock;
static isc_result_t
register_table(unsigned int base, unsigned int nresults, const char **text,
@@ -135,12 +133,8 @@ register_table(unsigned int base, unsigned int nresults, const char **text,
table->set = set;
ISC_LINK_INIT(table, link);
- LOCK(&lock);
-
ISC_LIST_APPEND(tables, table, link);
- UNLOCK(&lock);
-
return (ISC_R_SUCCESS);
}
@@ -148,7 +142,6 @@ static void
initialize_action(void) {
isc_result_t result;
- RUNTIME_CHECK(isc_mutex_init(&lock) == ISC_R_SUCCESS);
ISC_LIST_INIT(tables);
result = register_table(ISC_RESULTCLASS_ISC, ISC_R_NRESULTS,
@@ -172,8 +165,6 @@ isc_result_totext(isc_result_t result) {
initialize();
- LOCK(&lock);
-
text = NULL;
for (table = ISC_LIST_HEAD(tables);
table != NULL;
@@ -187,8 +178,6 @@ isc_result_totext(isc_result_t result) {
if (text == NULL)
text = "(result code text not available)";
- UNLOCK(&lock);
-
return (text);
}
diff --git a/usr.sbin/bind/lib/isc/socket_api.c b/usr.sbin/bind/lib/isc/socket_api.c
index 82c3ff81a2f..771d89e6e46 100644
--- a/usr.sbin/bind/lib/isc/socket_api.c
+++ b/usr.sbin/bind/lib/isc/socket_api.c
@@ -14,38 +14,25 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: socket_api.c,v 1.5 2020/01/21 10:11:09 deraadt Exp $ */
+/* $Id: socket_api.c,v 1.6 2020/01/21 23:59:20 tedu Exp $ */
#include <config.h>
#include <isc/app.h>
#include <isc/magic.h>
-#include <isc/mutex.h>
-#include <isc/once.h>
#include <isc/socket.h>
#include <isc/util.h>
-static isc_mutex_t createlock;
-static isc_once_t once = ISC_ONCE_INIT;
static isc_socketmgrcreatefunc_t socketmgr_createfunc = NULL;
-static void
-initialize(void) {
- RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
-}
-
isc_result_t
isc_socket_register(isc_socketmgrcreatefunc_t createfunc) {
isc_result_t result = ISC_R_SUCCESS;
- RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
-
- LOCK(&createlock);
if (socketmgr_createfunc == NULL)
socketmgr_createfunc = createfunc;
else
result = ISC_R_EXISTS;
- UNLOCK(&createlock);
return (result);
}
@@ -56,13 +43,9 @@ isc_socketmgr_createinctx(isc_appctx_t *actx,
{
isc_result_t result;
- LOCK(&createlock);
-
REQUIRE(socketmgr_createfunc != NULL);
result = (*socketmgr_createfunc)( managerp);
- UNLOCK(&createlock);
-
if (result == ISC_R_SUCCESS)
isc_appctx_setsocketmgr(actx, *managerp);
diff --git a/usr.sbin/bind/lib/isc/task.c b/usr.sbin/bind/lib/isc/task.c
index fc4b64bd9b5..3f8e2af2b36 100644
--- a/usr.sbin/bind/lib/isc/task.c
+++ b/usr.sbin/bind/lib/isc/task.c
@@ -74,7 +74,6 @@ struct isc__task {
/* Not locked. */
isc_task_t common;
isc__taskmgr_t * manager;
- isc_mutex_t lock;
/* Locked by task lock. */
task_state_t state;
unsigned int references;
@@ -106,7 +105,6 @@ typedef ISC_LIST(isc__task_t) isc__tasklist_t;
struct isc__taskmgr {
/* Not locked. */
isc_taskmgr_t common;
- isc_mutex_t lock;
/* Locked by task manager lock. */
unsigned int default_quantum;
LIST(isc__task_t) tasks;
@@ -124,7 +122,6 @@ struct isc__taskmgr {
* to protect the access. We can't use 'lock' since isc_task_detach()
* will try to acquire it.
*/
- isc_mutex_t excl_lock;
isc__task_t *excl;
unsigned int refs;
};
@@ -270,11 +267,8 @@ task_finished(isc__task_t *task) {
XTRACE("task_finished");
- LOCK(&manager->lock);
UNLINK(manager->tasks, task, link);
- UNLOCK(&manager->lock);
- DESTROYLOCK(&task->lock);
task->common.impmagic = 0;
task->common.magic = 0;
free(task);
@@ -287,7 +281,6 @@ isc__task_create(isc_taskmgr_t *manager0, unsigned int quantum,
isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
isc__task_t *task;
isc_boolean_t exiting;
- isc_result_t result;
REQUIRE(VALID_MANAGER(manager));
REQUIRE(taskp != NULL && *taskp == NULL);
@@ -297,11 +290,6 @@ isc__task_create(isc_taskmgr_t *manager0, unsigned int quantum,
return (ISC_R_NOMEMORY);
XTRACE("isc_task_create");
task->manager = manager;
- result = isc_mutex_init(&task->lock);
- if (result != ISC_R_SUCCESS) {
- free(task);
- return (result);
- }
task->state = task_state_idle;
task->references = 1;
INIT_LIST(task->events);
@@ -317,17 +305,14 @@ isc__task_create(isc_taskmgr_t *manager0, unsigned int quantum,
INIT_LINK(task, ready_priority_link);
exiting = ISC_FALSE;
- LOCK(&manager->lock);
if (!manager->exiting) {
if (task->quantum == 0)
task->quantum = manager->default_quantum;
APPEND(manager->tasks, task, link);
} else
exiting = ISC_TRUE;
- UNLOCK(&manager->lock);
if (exiting) {
- DESTROYLOCK(&task->lock);
free(task);
return (ISC_R_SHUTTINGDOWN);
}
@@ -353,9 +338,7 @@ isc__task_attach(isc_task_t *source0, isc_task_t **targetp) {
XTTRACE(source, "isc_task_attach");
- LOCK(&source->lock);
source->references++;
- UNLOCK(&source->lock);
*targetp = (isc_task_t *)source;
}
@@ -412,9 +395,7 @@ task_ready(isc__task_t *task) {
XTRACE("task_ready");
- LOCK(&manager->lock);
push_readyq(manager, task);
- UNLOCK(&manager->lock);
}
static inline isc_boolean_t
@@ -461,9 +442,7 @@ isc__task_detach(isc_task_t **taskp) {
XTRACE("isc_task_detach");
- LOCK(&task->lock);
was_idle = task_detach(task);
- UNLOCK(&task->lock);
if (was_idle)
task_ready(task);
@@ -521,9 +500,7 @@ isc__task_send(isc_task_t *task0, isc_event_t **eventp) {
* We're also trying to hold as few locks as possible. This is why
* some processing is deferred until after the lock is released.
*/
- LOCK(&task->lock);
was_idle = task_send(task, eventp);
- UNLOCK(&task->lock);
if (was_idle) {
/*
@@ -561,10 +538,8 @@ isc__task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp) {
XTRACE("isc_task_sendanddetach");
- LOCK(&task->lock);
idle1 = task_send(task, eventp);
idle2 = task_detach(task);
- UNLOCK(&task->lock);
/*
* If idle1, then idle2 shouldn't be true as well since we're holding
@@ -602,8 +577,6 @@ dequeue_events(isc__task_t *task, void *sender, isc_eventtype_t first,
* sender == NULL means "any sender", and tag == NULL means "any tag".
*/
- LOCK(&task->lock);
-
for (event = HEAD(task->events); event != NULL; event = next_event) {
next_event = NEXT(event, ev_link);
if (event->ev_type >= first && event->ev_type <= last &&
@@ -617,8 +590,6 @@ dequeue_events(isc__task_t *task, void *sender, isc_eventtype_t first,
}
}
- UNLOCK(&task->lock);
-
return (count);
}
@@ -691,7 +662,6 @@ isc_task_purgeevent(isc_task_t *task0, isc_event_t *event) {
* Purging never changes the state of the task.
*/
- LOCK(&task->lock);
for (curr_event = HEAD(task->events);
curr_event != NULL;
curr_event = next_event) {
@@ -702,7 +672,6 @@ isc_task_purgeevent(isc_task_t *task0, isc_event_t *event) {
break;
}
}
- UNLOCK(&task->lock);
if (curr_event == NULL)
return (ISC_FALSE);
@@ -766,13 +735,11 @@ isc__task_onshutdown(isc_task_t *task0, isc_taskaction_t action,
if (event == NULL)
return (ISC_R_NOMEMORY);
- LOCK(&task->lock);
if (TASK_SHUTTINGDOWN(task)) {
disallowed = ISC_TRUE;
result = ISC_R_SHUTTINGDOWN;
} else
ENQUEUE(task->on_shutdown, event, ev_link);
- UNLOCK(&task->lock);
if (disallowed)
free(event);
@@ -791,9 +758,7 @@ isc__task_shutdown(isc_task_t *task0) {
REQUIRE(VALID_TASK(task));
- LOCK(&task->lock);
was_idle = task_shutdown(task);
- UNLOCK(&task->lock);
if (was_idle)
task_ready(task);
@@ -822,10 +787,8 @@ isc__task_setname(isc_task_t *task0, const char *name, void *tag) {
REQUIRE(VALID_TASK(task));
- LOCK(&task->lock);
strlcpy(task->name, name, sizeof(task->name));
task->tag = tag;
- UNLOCK(&task->lock);
}
const char *
@@ -853,9 +816,7 @@ isc__task_getcurrenttime(isc_task_t *task0, isc_stdtime_t *t) {
REQUIRE(VALID_TASK(task));
REQUIRE(t != NULL);
- LOCK(&task->lock);
*t = task->now;
- UNLOCK(&task->lock);
}
/***
@@ -933,59 +894,8 @@ dispatch(isc__taskmgr_t *manager) {
REQUIRE(VALID_MANAGER(manager));
- /*
- * Again we're trying to hold the lock for as short a time as possible
- * and to do as little locking and unlocking as possible.
- *
- * In both while loops, the appropriate lock must be held before the
- * while body starts. Code which acquired the lock at the top of
- * the loop would be more readable, but would result in a lot of
- * extra locking. Compare:
- *
- * Straightforward:
- *
- * LOCK();
- * ...
- * UNLOCK();
- * while (expression) {
- * LOCK();
- * ...
- * UNLOCK();
- *
- * Unlocked part here...
- *
- * LOCK();
- * ...
- * UNLOCK();
- * }
- *
- * Note how if the loop continues we unlock and then immediately lock.
- * For N iterations of the loop, this code does 2N+1 locks and 2N+1
- * unlocks. Also note that the lock is not held when the while
- * condition is tested, which may or may not be important, depending
- * on the expression.
- *
- * As written:
- *
- * LOCK();
- * while (expression) {
- * ...
- * UNLOCK();
- *
- * Unlocked part here...
- *
- * LOCK();
- * ...
- * }
- * UNLOCK();
- *
- * For N iterations of the loop, this code does N+1 locks and N+1
- * unlocks. The while expression is always protected by the lock.
- */
-
ISC_LIST_INIT(new_ready_tasks);
ISC_LIST_INIT(new_priority_tasks);
- LOCK(&manager->lock);
while (!FINISHED(manager)) {
if (total_dispatch_count >= DEFAULT_TASKMGR_QUANTUM ||
@@ -1010,9 +920,7 @@ dispatch(isc__taskmgr_t *manager) {
*/
manager->tasks_ready--;
manager->tasks_running++;
- UNLOCK(&manager->lock);
- LOCK(&task->lock);
INSIST(task->state == task_state_ready);
task->state = task_state_running;
XTRACE("running");
@@ -1028,11 +936,9 @@ dispatch(isc__taskmgr_t *manager) {
*/
XTRACE("execute action");
if (event->ev_action != NULL) {
- UNLOCK(&task->lock);
(event->ev_action)(
(isc_task_t *)task,
event);
- LOCK(&task->lock);
}
dispatch_count++;
total_dispatch_count++;
@@ -1103,12 +1009,10 @@ dispatch(isc__taskmgr_t *manager) {
done = ISC_TRUE;
}
} while (!done);
- UNLOCK(&task->lock);
if (finished)
task_finished(task);
- LOCK(&manager->lock);
manager->tasks_running--;
if (requeue) {
/*
@@ -1147,14 +1051,11 @@ dispatch(isc__taskmgr_t *manager) {
if (empty_readyq(manager))
manager->mode = isc_taskmgrmode_normal;
- UNLOCK(&manager->lock);
}
static void
manager_free(isc__taskmgr_t *manager) {
- DESTROYLOCK(&manager->lock);
- DESTROYLOCK(&manager->excl_lock);
manager->common.impmagic = 0;
manager->common.magic = 0;
free(manager);
@@ -1195,14 +1096,6 @@ isc__taskmgr_create(unsigned int workers,
manager->common.impmagic = TASK_MANAGER_MAGIC;
manager->common.magic = ISCAPI_TASKMGR_MAGIC;
manager->mode = isc_taskmgrmode_normal;
- result = isc_mutex_init(&manager->lock);
- if (result != ISC_R_SUCCESS)
- goto cleanup_mgr;
- result = isc_mutex_init(&manager->excl_lock);
- if (result != ISC_R_SUCCESS) {
- DESTROYLOCK(&manager->lock);
- goto cleanup_mgr;
- }
if (default_quantum == 0)
default_quantum = DEFAULT_DEFAULT_QUANTUM;
@@ -1224,7 +1117,6 @@ isc__taskmgr_create(unsigned int workers,
return (ISC_R_SUCCESS);
- cleanup_mgr:
free(manager);
return (result);
}
@@ -1263,21 +1155,8 @@ isc__taskmgr_destroy(isc_taskmgr_t **managerp) {
/*
* Detach the exclusive task before acquiring the manager lock
*/
- LOCK(&manager->excl_lock);
if (manager->excl != NULL)
isc__task_detach((isc_task_t **) &manager->excl);
- UNLOCK(&manager->excl_lock);
-
- /*
- * Unlike elsewhere, we're going to hold this lock a long time.
- * We need to do so, because otherwise the list of tasks could
- * change while we were traversing it.
- *
- * This is also the only function where we will hold both the
- * task manager lock and a task lock at the same time.
- */
-
- LOCK(&manager->lock);
/*
* Make sure we only get called once.
@@ -1297,15 +1176,12 @@ isc__taskmgr_destroy(isc_taskmgr_t **managerp) {
for (task = HEAD(manager->tasks);
task != NULL;
task = NEXT(task, link)) {
- LOCK(&task->lock);
if (task_shutdown(task))
push_readyq(manager, task);
- UNLOCK(&task->lock);
}
/*
* Dispatch the shutdown events.
*/
- UNLOCK(&manager->lock);
while (isc__taskmgr_ready((isc_taskmgr_t *)manager))
(void)isc__taskmgr_dispatch((isc_taskmgr_t *)manager);
INSIST(ISC_LIST_EMPTY(manager->tasks));
@@ -1320,18 +1196,14 @@ void
isc__taskmgr_setmode(isc_taskmgr_t *manager0, isc_taskmgrmode_t mode) {
isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
- LOCK(&manager->lock);
manager->mode = mode;
- UNLOCK(&manager->lock);
}
isc_taskmgrmode_t
isc__taskmgr_mode(isc_taskmgr_t *manager0) {
isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
isc_taskmgrmode_t mode;
- LOCK(&manager->lock);
mode = manager->mode;
- UNLOCK(&manager->lock);
return (mode);
}
@@ -1345,9 +1217,7 @@ isc__taskmgr_ready(isc_taskmgr_t *manager0) {
if (manager == NULL)
return (ISC_FALSE);
- LOCK(&manager->lock);
is_ready = !empty_readyq(manager);
- UNLOCK(&manager->lock);
return (is_ready);
}
@@ -1373,11 +1243,9 @@ isc_taskmgr_setexcltask(isc_taskmgr_t *mgr0, isc_task_t *task0) {
REQUIRE(VALID_MANAGER(mgr));
REQUIRE(VALID_TASK(task));
- LOCK(&mgr->excl_lock);
if (mgr->excl != NULL)
isc__task_detach((isc_task_t **) &mgr->excl);
isc__task_attach(task0, (isc_task_t **) &mgr->excl);
- UNLOCK(&mgr->excl_lock);
}
isc_result_t
@@ -1388,12 +1256,10 @@ isc_taskmgr_excltask(isc_taskmgr_t *mgr0, isc_task_t **taskp) {
REQUIRE(VALID_MANAGER(mgr));
REQUIRE(taskp != NULL && *taskp == NULL);
- LOCK(&mgr->excl_lock);
if (mgr->excl != NULL)
isc__task_attach((isc_task_t *) mgr->excl, taskp);
else
result = ISC_R_NOTFOUND;
- UNLOCK(&mgr->excl_lock);
return (result);
}
@@ -1415,25 +1281,21 @@ isc__task_setprivilege(isc_task_t *task0, isc_boolean_t priv) {
isc__taskmgr_t *manager = task->manager;
isc_boolean_t oldpriv;
- LOCK(&task->lock);
oldpriv = ISC_TF((task->flags & TASK_F_PRIVILEGED) != 0);
if (priv)
task->flags |= TASK_F_PRIVILEGED;
else
task->flags &= ~TASK_F_PRIVILEGED;
- UNLOCK(&task->lock);
if (priv == oldpriv)
return;
- LOCK(&manager->lock);
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);
- UNLOCK(&manager->lock);
}
isc_boolean_t
@@ -1441,9 +1303,7 @@ isc__task_privilege(isc_task_t *task0) {
isc__task_t *task = (isc__task_t *)task0;
isc_boolean_t priv;
- LOCK(&task->lock);
priv = ISC_TF((task->flags & TASK_F_PRIVILEGED) != 0);
- UNLOCK(&task->lock);
return (priv);
}
@@ -1461,27 +1321,16 @@ isc_task_exiting(isc_task_t *t) {
}
-static isc_mutex_t createlock;
-static isc_once_t once = ISC_ONCE_INIT;
static isc_taskmgrcreatefunc_t taskmgr_createfunc = NULL;
-static void
-initialize(void) {
- RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
-}
-
isc_result_t
isc_task_register(isc_taskmgrcreatefunc_t createfunc) {
isc_result_t result = ISC_R_SUCCESS;
- RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
-
- LOCK(&createlock);
if (taskmgr_createfunc == NULL)
taskmgr_createfunc = createfunc;
else
result = ISC_R_EXISTS;
- UNLOCK(&createlock);
return (result);
}
@@ -1493,14 +1342,10 @@ isc_taskmgr_createinctx(isc_appctx_t *actx,
{
isc_result_t result;
- LOCK(&createlock);
-
REQUIRE(taskmgr_createfunc != NULL);
result = (*taskmgr_createfunc)(workers, default_quantum,
managerp);
- UNLOCK(&createlock);
-
if (result == ISC_R_SUCCESS)
isc_appctx_settaskmgr(actx, *managerp);
diff --git a/usr.sbin/bind/lib/isc/timer.c b/usr.sbin/bind/lib/isc/timer.c
index 19fc60e2b10..9df569ed814 100644
--- a/usr.sbin/bind/lib/isc/timer.c
+++ b/usr.sbin/bind/lib/isc/timer.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: timer.c,v 1.13 2020/01/21 10:11:09 deraadt Exp $ */
+/* $Id: timer.c,v 1.14 2020/01/21 23:59:20 tedu Exp $ */
/*! \file */
@@ -65,7 +65,6 @@ struct isc__timer {
/*! Not locked. */
isc_timer_t common;
isc__timermgr_t * manager;
- isc_mutex_t lock;
/*! Locked by timer lock. */
unsigned int references;
isc_time_t idle;
@@ -87,7 +86,6 @@ struct isc__timer {
struct isc__timermgr {
/* Not locked. */
isc_timermgr_t common;
- isc_mutex_t lock;
/* Locked by manager lock. */
isc_boolean_t done;
LIST(isc__timer_t) timers;
@@ -269,8 +267,6 @@ destroy(isc__timer_t *timer) {
* The caller must ensure it is safe to destroy the timer.
*/
- LOCK(&manager->lock);
-
(void)isc_task_purgerange(timer->task,
timer,
ISC_TIMEREVENT_FIRSTEVENT,
@@ -279,10 +275,7 @@ destroy(isc__timer_t *timer) {
deschedule(timer);
UNLINK(manager->timers, timer, link);
- UNLOCK(&manager->lock);
-
isc_task_detach(&timer->task);
- DESTROYLOCK(&timer->lock);
timer->common.impmagic = 0;
timer->common.magic = 0;
free(timer);
@@ -369,24 +362,11 @@ isc__timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
*/
DE_CONST(arg, timer->arg);
timer->index = 0;
- result = isc_mutex_init(&timer->lock);
- if (result != ISC_R_SUCCESS) {
- isc_task_detach(&timer->task);
- free(timer);
- return (result);
- }
ISC_LINK_INIT(timer, link);
timer->common.impmagic = TIMER_MAGIC;
timer->common.magic = ISCAPI_TIMER_MAGIC;
timer->common.methods = (isc_timermethods_t *)&timermethods;
- LOCK(&manager->lock);
-
- /*
- * Note we don't have to lock the timer like we normally would because
- * there are no external references to it yet.
- */
-
if (type != isc_timertype_inactive)
result = schedule(timer, &now, ISC_TRUE);
else
@@ -394,12 +374,9 @@ isc__timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
if (result == ISC_R_SUCCESS)
APPEND(manager->timers, timer, link);
- UNLOCK(&manager->lock);
-
if (result != ISC_R_SUCCESS) {
timer->common.impmagic = 0;
timer->common.magic = 0;
- DESTROYLOCK(&timer->lock);
isc_task_detach(&timer->task);
free(timer);
return (result);
@@ -453,9 +430,6 @@ isc__timer_reset(isc_timer_t *timer0, isc_timertype_t type,
isc_time_settoepoch(&now);
}
- LOCK(&manager->lock);
- LOCK(&timer->lock);
-
if (purge)
(void)isc_task_purgerange(timer->task,
timer,
@@ -480,9 +454,6 @@ isc__timer_reset(isc_timer_t *timer0, isc_timertype_t type,
result = schedule(timer, &now, ISC_TRUE);
}
- UNLOCK(&timer->lock);
- UNLOCK(&manager->lock);
-
return (result);
}
@@ -493,9 +464,7 @@ isc_timer_gettype(isc_timer_t *timer0) {
REQUIRE(VALID_TIMER(timer));
- LOCK(&timer->lock);
t = timer->type;
- UNLOCK(&timer->lock);
return (t);
}
@@ -512,22 +481,9 @@ isc__timer_touch(isc_timer_t *timer0) {
REQUIRE(VALID_TIMER(timer));
- LOCK(&timer->lock);
-
- /*
- * We'd like to
- *
- * REQUIRE(timer->type == isc_timertype_once);
- *
- * but we cannot without locking the manager lock too, which we
- * don't want to do.
- */
-
TIME_NOW(&now);
result = isc_time_add(&now, &timer->interval, &timer->idle);
- UNLOCK(&timer->lock);
-
return (result);
}
@@ -542,9 +498,7 @@ isc__timer_attach(isc_timer_t *timer0, isc_timer_t **timerp) {
REQUIRE(VALID_TIMER(timer));
REQUIRE(timerp != NULL && *timerp == NULL);
- LOCK(&timer->lock);
timer->references++;
- UNLOCK(&timer->lock);
*timerp = (isc_timer_t *)timer;
}
@@ -562,12 +516,10 @@ isc__timer_detach(isc_timer_t **timerp) {
timer = (isc__timer_t *)*timerp;
REQUIRE(VALID_TIMER(timer));
- LOCK(&timer->lock);
REQUIRE(timer->references > 0);
timer->references--;
if (timer->references == 0)
free_timer = ISC_TRUE;
- UNLOCK(&timer->lock);
if (free_timer)
destroy(timer);
@@ -617,13 +569,11 @@ dispatch(isc__timermgr_t *manager, isc_time_t *now) {
} else {
idle = ISC_FALSE;
- LOCK(&timer->lock);
if (!isc_time_isepoch(&timer->idle) &&
isc_time_compare(now,
&timer->idle) >= 0) {
idle = ISC_TRUE;
}
- UNLOCK(&timer->lock);
if (idle) {
type = ISC_TIMEREVENT_IDLE;
post_event = ISC_TRUE;
@@ -738,12 +688,6 @@ isc__timermgr_create(isc_timermgr_t **managerp) {
free(manager);
return (ISC_R_NOMEMORY);
}
- result = isc_mutex_init(&manager->lock);
- if (result != ISC_R_SUCCESS) {
- isc_heap_destroy(&manager->heap);
- free(manager);
- return (result);
- }
manager->refs = 1;
timermgr = manager;
@@ -769,11 +713,8 @@ isc__timermgr_destroy(isc_timermgr_t **managerp) {
manager = (isc__timermgr_t *)*managerp;
REQUIRE(VALID_MANAGER(manager));
- LOCK(&manager->lock);
-
manager->refs--;
if (manager->refs > 0) {
- UNLOCK(&manager->lock);
*managerp = NULL;
return;
}
@@ -784,12 +725,9 @@ isc__timermgr_destroy(isc_timermgr_t **managerp) {
REQUIRE(EMPTY(manager->timers));
manager->done = ISC_TRUE;
- UNLOCK(&manager->lock);
-
/*
* Clean up.
*/
- DESTROYLOCK(&manager->lock);
isc_heap_destroy(&manager->heap);
manager->common.impmagic = 0;
manager->common.magic = 0;
@@ -830,27 +768,16 @@ isc__timer_register(void) {
return (isc_timer_register(isc__timermgr_create));
}
-static isc_mutex_t createlock;
-static isc_once_t once = ISC_ONCE_INIT;
static isc_timermgrcreatefunc_t timermgr_createfunc = NULL;
-static void
-initialize(void) {
- RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
-}
-
isc_result_t
isc_timer_register(isc_timermgrcreatefunc_t createfunc) {
isc_result_t result = ISC_R_SUCCESS;
- RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
-
- LOCK(&createlock);
if (timermgr_createfunc == NULL)
timermgr_createfunc = createfunc;
else
result = ISC_R_EXISTS;
- UNLOCK(&createlock);
return (result);
}
@@ -861,13 +788,9 @@ isc_timermgr_createinctx(isc_appctx_t *actx,
{
isc_result_t result;
- LOCK(&createlock);
-
REQUIRE(timermgr_createfunc != NULL);
result = (*timermgr_createfunc)(managerp);
- UNLOCK(&createlock);
-
if (result == ISC_R_SUCCESS)
isc_appctx_settimermgr(actx, *managerp);
diff --git a/usr.sbin/bind/lib/isc/unix/app.c b/usr.sbin/bind/lib/isc/unix/app.c
index 96e6553e1b9..982f946c589 100644
--- a/usr.sbin/bind/lib/isc/unix/app.c
+++ b/usr.sbin/bind/lib/isc/unix/app.c
@@ -36,7 +36,6 @@
#include <isc/condition.h>
#include <isc/msgs.h>
-#include <isc/mutex.h>
#include <isc/event.h>
#include <isc/platform.h>
#include <isc/strerror.h>
@@ -92,7 +91,6 @@ isc_result_t isc__app_ctxonrun(isc_appctx_t *ctx,
typedef struct isc__appctx {
isc_appctx_t common;
- isc_mutex_t lock;
isc_eventlist_t on_run;
isc_boolean_t shutdown_requested;
isc_boolean_t running;
@@ -204,10 +202,6 @@ isc__app_ctxstart(isc_appctx_t *ctx0) {
}
#endif
- result = isc_mutex_init(&ctx->lock);
- if (result != ISC_R_SUCCESS)
- goto cleanup;
-
ISC_LIST_INIT(ctx->on_run);
ctx->shutdown_requested = ISC_FALSE;
@@ -320,8 +314,6 @@ isc__app_ctxonrun(isc_appctx_t *ctx0, isc_task_t *task,
isc_task_t *cloned_task = NULL;
isc_result_t result;
- LOCK(&ctx->lock);
-
if (ctx->running) {
result = ISC_R_ALREADYRUNNING;
goto unlock;
@@ -345,8 +337,6 @@ isc__app_ctxonrun(isc_appctx_t *ctx0, isc_task_t *task,
result = ISC_R_SUCCESS;
unlock:
- UNLOCK(&ctx->lock);
-
return (result);
}
@@ -451,18 +441,14 @@ static isc_boolean_t in_recursive_evloop = ISC_FALSE;
static isc_boolean_t signalled = ISC_FALSE;
isc_result_t
-isc__nothread_wait_hack(isc_condition_t *cp, isc_mutex_t *mp) {
+isc__nothread_wait_hack(isc_condition_t *cp) {
isc_result_t result;
UNUSED(cp);
- UNUSED(mp);
INSIST(!in_recursive_evloop);
in_recursive_evloop = ISC_TRUE;
- INSIST(*mp == 1); /* Mutex must be locked on entry. */
- --*mp;
-
result = evloop(&isc_g_appctx);
if (result == ISC_R_RELOAD)
isc_g_appctx.want_reload = ISC_TRUE;
@@ -471,7 +457,6 @@ isc__nothread_wait_hack(isc_condition_t *cp, isc_mutex_t *mp) {
signalled = ISC_FALSE;
}
- ++*mp;
in_recursive_evloop = ISC_FALSE;
return (ISC_R_SUCCESS);
}
@@ -496,7 +481,6 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
isc_task_t *task;
REQUIRE(VALID_APPCTX(ctx));
- LOCK(&ctx->lock);
if (!ctx->running) {
ctx->running = ISC_TRUE;
@@ -516,8 +500,6 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
}
- UNLOCK(&ctx->lock);
-
if (ctx == &isc_g_appctx) {
result = handle_signal(SIGHUP, reload_action);
if (result != ISC_R_SUCCESS)
@@ -541,8 +523,6 @@ isc__app_ctxshutdown(isc_appctx_t *ctx0) {
REQUIRE(VALID_APPCTX(ctx));
- LOCK(&ctx->lock);
-
REQUIRE(ctx->running);
if (ctx->shutdown_requested)
@@ -550,8 +530,6 @@ isc__app_ctxshutdown(isc_appctx_t *ctx0) {
else
ctx->shutdown_requested = ISC_TRUE;
- UNLOCK(&ctx->lock);
-
if (want_kill) {
if (ctx != &isc_g_appctx)
/* BIND9 internal, but using multiple contexts */
@@ -576,8 +554,6 @@ isc__app_ctxsuspend(isc_appctx_t *ctx0) {
REQUIRE(VALID_APPCTX(ctx));
- LOCK(&ctx->lock);
-
REQUIRE(ctx->running);
/*
@@ -586,8 +562,6 @@ isc__app_ctxsuspend(isc_appctx_t *ctx0) {
if (ctx->shutdown_requested)
want_kill = ISC_FALSE;
- UNLOCK(&ctx->lock);
-
if (want_kill) {
if (ctx != &isc_g_appctx)
/* BIND9 internal, but using multiple contexts */
@@ -610,8 +584,6 @@ isc__app_ctxfinish(isc_appctx_t *ctx0) {
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
REQUIRE(VALID_APPCTX(ctx));
-
- DESTROYLOCK(&ctx->lock);
}
void
diff --git a/usr.sbin/bind/lib/isc/unix/socket.c b/usr.sbin/bind/lib/isc/unix/socket.c
index 4a02426ef42..e8cca975580 100644
--- a/usr.sbin/bind/lib/isc/unix/socket.c
+++ b/usr.sbin/bind/lib/isc/unix/socket.c
@@ -49,7 +49,6 @@
#include <isc/log.h>
#include <isc/msgs.h>
-#include <isc/mutex.h>
#include <isc/net.h>
#include <isc/once.h>
#include <isc/platform.h>
@@ -296,7 +295,6 @@ struct isc__socket {
/* Not locked. */
isc_socket_t common;
isc__socketmgr_t *manager;
- isc_mutex_t lock;
isc_sockettype_t type;
/* Locked by socket lock. */
@@ -350,8 +348,6 @@ struct isc__socket {
struct isc__socketmgr {
/* Not locked. */
isc_socketmgr_t common;
- isc_mutex_t lock;
- isc_mutex_t *fdlock;
#ifdef USE_KQUEUE
int kqueue_fd;
int nevents;
@@ -367,7 +363,6 @@ struct isc__socketmgr {
#endif /* USE_SELECT */
unsigned int maxsocks;
- /* Locked by fdlock. */
isc__socket_t **fds;
int *fdstate;
#if defined(USE_EPOLL)
@@ -715,12 +710,10 @@ watch_fd(isc__socketmgr_t *manager, int fd, int msg) {
return (result);
#elif defined(USE_SELECT)
- LOCK(&manager->lock);
if (msg == SELECT_POKE_READ)
FD_SET(fd, manager->read_fds);
if (msg == SELECT_POKE_WRITE)
FD_SET(fd, manager->write_fds);
- UNLOCK(&manager->lock);
return (result);
#endif
@@ -769,12 +762,10 @@ unwatch_fd(isc__socketmgr_t *manager, int fd, int msg) {
}
return (result);
#elif defined(USE_SELECT)
- LOCK(&manager->lock);
if (msg == SELECT_POKE_READ)
FD_CLR(fd, manager->read_fds);
else if (msg == SELECT_POKE_WRITE)
FD_CLR(fd, manager->write_fds);
- UNLOCK(&manager->lock);
return (result);
#endif
@@ -783,7 +774,6 @@ unwatch_fd(isc__socketmgr_t *manager, int fd, int msg) {
static void
wakeup_socket(isc__socketmgr_t *manager, int fd, int msg) {
isc_result_t result;
- int lockid = FDLOCK_ID(fd);
/*
* This is a wakeup on a socket. If the socket is not in the
@@ -803,27 +793,20 @@ wakeup_socket(isc__socketmgr_t *manager, int fd, int msg) {
return;
}
- LOCK(&manager->fdlock[lockid]);
if (manager->fdstate[fd] == CLOSE_PENDING) {
- UNLOCK(&manager->fdlock[lockid]);
/*
* We accept (and ignore) any error from unwatch_fd() as we are
* closing the socket, hoping it doesn't leave dangling state in
* the kernel.
- * Note that unwatch_fd() must be called after releasing the
- * fdlock; otherwise it could cause deadlock due to a lock order
- * reversal.
*/
(void)unwatch_fd(manager, fd, SELECT_POKE_READ);
(void)unwatch_fd(manager, fd, SELECT_POKE_WRITE);
return;
}
if (manager->fdstate[fd] != MANAGED) {
- UNLOCK(&manager->fdlock[lockid]);
return;
}
- UNLOCK(&manager->fdlock[lockid]);
/*
* Set requested bit.
@@ -1728,19 +1711,16 @@ doio_send(isc__socket_t *sock, isc_socketevent_t *dev) {
static void
socketclose(isc__socketmgr_t *manager, isc__socket_t *sock, int fd) {
isc_sockettype_t type = sock->type;
- int lockid = FDLOCK_ID(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.
*/
- LOCK(&manager->fdlock[lockid]);
manager->fds[fd] = NULL;
if (type == isc_sockettype_fdwatch)
manager->fdstate[fd] = CLOSED;
else
manager->fdstate[fd] = CLOSE_PENDING;
- UNLOCK(&manager->fdlock[lockid]);
if (type == isc_sockettype_fdwatch) {
/*
* The caller may close the socket once this function returns,
@@ -1765,7 +1745,6 @@ socketclose(isc__socketmgr_t *manager, isc__socket_t *sock, int fd) {
* efficiently)
*/
#ifdef USE_SELECT
- LOCK(&manager->lock);
if (manager->maxfd == fd) {
int i;
@@ -1773,17 +1752,13 @@ socketclose(isc__socketmgr_t *manager, isc__socket_t *sock, int fd) {
for (i = fd - 1; i >= 0; i--) {
lockid = FDLOCK_ID(i);
- LOCK(&manager->fdlock[lockid]);
if (manager->fdstate[i] == MANAGED) {
manager->maxfd = i;
- UNLOCK(&manager->fdlock[lockid]);
break;
}
- UNLOCK(&manager->fdlock[lockid]);
}
}
- UNLOCK(&manager->lock);
#endif /* USE_SELECT */
}
@@ -1807,14 +1782,10 @@ destroy(isc__socket_t **sockp) {
socketclose(manager, sock, fd);
}
- LOCK(&manager->lock);
-
ISC_LIST_UNLINK(manager->socklist, sock, link);
/* can't unlock manager as its memory context is still used */
free_socket(sockp);
-
- UNLOCK(&manager->lock);
}
static isc_result_t
@@ -1822,7 +1793,6 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
isc__socket_t **socketp)
{
isc__socket_t *sock;
- isc_result_t result;
sock = malloc(sizeof(*sock));
@@ -1863,16 +1833,6 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
sock->pktdscp = 0;
/*
- * Initialize the lock.
- */
- result = isc_mutex_init(&sock->lock);
- if (result != ISC_R_SUCCESS) {
- sock->common.magic = 0;
- sock->common.impmagic = 0;
- goto error;
- }
-
- /*
* Initialize readable and writable events.
*/
ISC_EVENT_INIT(&sock->readable_ev, sizeof(intev_t),
@@ -1887,11 +1847,6 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
*socketp = sock;
return (ISC_R_SUCCESS);
-
- error:
- free(sock);
-
- return (result);
}
/*
@@ -1919,8 +1874,6 @@ free_socket(isc__socket_t **socketp) {
sock->common.magic = 0;
sock->common.impmagic = 0;
- DESTROYLOCK(&sock->lock);
-
free(sock);
*socketp = NULL;
@@ -2399,21 +2352,17 @@ socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
*/
lockid = FDLOCK_ID(sock->fd);
- LOCK(&manager->fdlock[lockid]);
manager->fds[sock->fd] = sock;
manager->fdstate[sock->fd] = MANAGED;
#if defined(USE_EPOLL)
manager->epoll_events[sock->fd] = 0;
#endif
- UNLOCK(&manager->fdlock[lockid]);
- LOCK(&manager->lock);
ISC_LIST_APPEND(manager->socklist, sock, link);
#ifdef USE_SELECT
if (manager->maxfd < sock->fd)
manager->maxfd = sock->fd;
#endif
- UNLOCK(&manager->lock);
socket_log(sock, NULL, CREATION, dup_socket != NULL ? "dupped" : "created");
@@ -2456,10 +2405,8 @@ isc__socket_open(isc_socket_t *sock0) {
REQUIRE(VALID_SOCKET(sock));
- LOCK(&sock->lock);
REQUIRE(sock->references == 1);
REQUIRE(sock->type != isc_sockettype_fdwatch);
- UNLOCK(&sock->lock);
/*
* We don't need to retain the lock hereafter, since no one else has
* this socket.
@@ -2471,21 +2418,16 @@ isc__socket_open(isc_socket_t *sock0) {
sock->fd = -1;
if (result == ISC_R_SUCCESS) {
- int lockid = FDLOCK_ID(sock->fd);
- LOCK(&sock->manager->fdlock[lockid]);
sock->manager->fds[sock->fd] = sock;
sock->manager->fdstate[sock->fd] = MANAGED;
#if defined(USE_EPOLL)
sock->manager->epoll_events[sock->fd] = 0;
#endif
- UNLOCK(&sock->manager->fdlock[lockid]);
#ifdef USE_SELECT
- LOCK(&sock->manager->lock);
if (sock->manager->maxfd < sock->fd)
sock->manager->maxfd = sock->fd;
- UNLOCK(&sock->manager->lock);
#endif
}
@@ -2534,21 +2476,17 @@ isc__socket_fdwatchcreate(isc_socketmgr_t *manager0, int fd, int flags,
*/
lockid = FDLOCK_ID(sock->fd);
- LOCK(&manager->fdlock[lockid]);
manager->fds[sock->fd] = sock;
manager->fdstate[sock->fd] = MANAGED;
#if defined(USE_EPOLL)
manager->epoll_events[sock->fd] = 0;
#endif
- UNLOCK(&manager->fdlock[lockid]);
- LOCK(&manager->lock);
ISC_LIST_APPEND(manager->socklist, sock, link);
#ifdef USE_SELECT
if (manager->maxfd < sock->fd)
manager->maxfd = sock->fd;
#endif
- UNLOCK(&manager->lock);
if (flags & ISC_SOCKFDWATCH_READ)
select_poke(sock->manager, sock->fd, SELECT_POKE_READ);
@@ -2580,7 +2518,6 @@ isc__socket_fdwatchpoke(isc_socket_t *sock0, int flags)
*/
if ((flags & (ISC_SOCKFDWATCH_READ | ISC_SOCKFDWATCH_WRITE)) != 0) {
- LOCK(&sock->lock);
if (((flags & ISC_SOCKFDWATCH_READ) != 0) &&
!sock->pending_recv)
select_poke(sock->manager, sock->fd,
@@ -2589,7 +2526,6 @@ isc__socket_fdwatchpoke(isc_socket_t *sock0, int flags)
!sock->pending_send)
select_poke(sock->manager, sock->fd,
SELECT_POKE_WRITE);
- UNLOCK(&sock->lock);
}
socket_log(sock, NULL, TRACE, "fdwatch-poked flags: %d", flags);
@@ -2607,9 +2543,7 @@ isc__socket_attach(isc_socket_t *sock0, isc_socket_t **socketp) {
REQUIRE(VALID_SOCKET(sock));
REQUIRE(socketp != NULL && *socketp == NULL);
- LOCK(&sock->lock);
sock->references++;
- UNLOCK(&sock->lock);
*socketp = (isc_socket_t *)sock;
}
@@ -2627,12 +2561,10 @@ isc__socket_detach(isc_socket_t **socketp) {
sock = (isc__socket_t *)*socketp;
REQUIRE(VALID_SOCKET(sock));
- LOCK(&sock->lock);
REQUIRE(sock->references > 0);
sock->references--;
if (sock->references == 0)
kill_socket = ISC_TRUE;
- UNLOCK(&sock->lock);
if (kill_socket)
destroy(&sock);
@@ -2649,7 +2581,6 @@ isc__socket_close(isc_socket_t *sock0) {
fflush(stdout);
REQUIRE(VALID_SOCKET(sock));
- LOCK(&sock->lock);
REQUIRE(sock->references == 1);
REQUIRE(sock->type != isc_sockettype_fdwatch);
@@ -2676,7 +2607,6 @@ isc__socket_close(isc_socket_t *sock0) {
sock->bound = 0;
isc_sockaddr_any(&sock->peer_address);
- UNLOCK(&sock->lock);
socketclose(manager, sock, fd);
@@ -2888,7 +2818,6 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
sock = ev->ev_sender;
INSIST(VALID_SOCKET(sock));
- LOCK(&sock->lock);
socket_log(sock, NULL, TRACE,
"internal_accept called, locked socket");
@@ -2902,7 +2831,6 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
INSIST(sock->references > 0);
sock->references--; /* the internal event is done with this socket */
if (sock->references == 0) {
- UNLOCK(&sock->lock);
destroy(&sock);
return;
}
@@ -2913,7 +2841,6 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
*/
dev = ISC_LIST_HEAD(sock->accept_list);
if (dev == NULL) {
- UNLOCK(&sock->lock);
return;
}
@@ -3033,8 +2960,6 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
if (!ISC_LIST_EMPTY(sock->accept_list))
select_poke(sock->manager, sock->fd, SELECT_POKE_ACCEPT);
- UNLOCK(&sock->lock);
-
if (fd != -1) {
result = make_nonblock(fd);
if (result != ISC_R_SUCCESS) {
@@ -3047,8 +2972,6 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
* -1 means the new socket didn't happen.
*/
if (fd != -1) {
- int lockid = FDLOCK_ID(fd);
-
NEWCONNSOCK(dev)->fd = fd;
NEWCONNSOCK(dev)->bound = 1;
NEWCONNSOCK(dev)->connected = 1;
@@ -3073,15 +2996,11 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
NEWCONNSOCK(dev)->active = 1;
}
- LOCK(&manager->fdlock[lockid]);
manager->fds[fd] = NEWCONNSOCK(dev);
manager->fdstate[fd] = MANAGED;
#if defined(USE_EPOLL)
manager->epoll_events[fd] = 0;
#endif
- UNLOCK(&manager->fdlock[lockid]);
-
- LOCK(&manager->lock);
#ifdef USE_SELECT
if (manager->maxfd < fd)
@@ -3093,9 +3012,6 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
dev->newsocket);
ISC_LIST_APPEND(manager->socklist, NEWCONNSOCK(dev), link);
-
- UNLOCK(&manager->lock);
-
} else {
NEWCONNSOCK(dev)->references--;
free_socket((isc__socket_t **)&dev->newsocket);
@@ -3113,7 +3029,6 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
soft_error:
select_poke(sock->manager, sock->fd, SELECT_POKE_ACCEPT);
- UNLOCK(&sock->lock);
return;
}
@@ -3128,7 +3043,6 @@ internal_recv(isc_task_t *me, isc_event_t *ev) {
sock = ev->ev_sender;
INSIST(VALID_SOCKET(sock));
- LOCK(&sock->lock);
socket_log(sock, NULL, IOEVENT,
"internal_recv: task %p got event %p", me, ev);
@@ -3138,7 +3052,6 @@ internal_recv(isc_task_t *me, isc_event_t *ev) {
INSIST(sock->references > 0);
sock->references--; /* the internal event is done with this socket */
if (sock->references == 0) {
- UNLOCK(&sock->lock);
destroy(&sock);
return;
}
@@ -3178,8 +3091,6 @@ internal_recv(isc_task_t *me, isc_event_t *ev) {
poke:
if (!ISC_LIST_EMPTY(sock->recv_list))
select_poke(sock->manager, sock->fd, SELECT_POKE_READ);
-
- UNLOCK(&sock->lock);
}
static void
@@ -3194,8 +3105,6 @@ internal_send(isc_task_t *me, isc_event_t *ev) {
*/
sock = (isc__socket_t *)ev->ev_sender;
INSIST(VALID_SOCKET(sock));
-
- LOCK(&sock->lock);
socket_log(sock, NULL, IOEVENT,
"internal_send: task %p got event %p", me, ev);
@@ -3205,7 +3114,6 @@ internal_send(isc_task_t *me, isc_event_t *ev) {
INSIST(sock->references > 0);
sock->references--; /* the internal event is done with this socket */
if (sock->references == 0) {
- UNLOCK(&sock->lock);
destroy(&sock);
return;
}
@@ -3232,8 +3140,6 @@ internal_send(isc_task_t *me, isc_event_t *ev) {
poke:
if (!ISC_LIST_EMPTY(sock->send_list))
select_poke(sock->manager, sock->fd, SELECT_POKE_WRITE);
-
- UNLOCK(&sock->lock);
}
static void
@@ -3249,31 +3155,24 @@ internal_fdwatch_write(isc_task_t *me, isc_event_t *ev) {
sock = (isc__socket_t *)ev->ev_sender;
INSIST(VALID_SOCKET(sock));
- LOCK(&sock->lock);
socket_log(sock, NULL, IOEVENT,
"internal_fdwatch_write: task %p got event %p", me, ev);
INSIST(sock->pending_send == 1);
- UNLOCK(&sock->lock);
more_data = (sock->fdwatchcb)(me, (isc_socket_t *)sock,
sock->fdwatcharg, ISC_SOCKFDWATCH_WRITE);
- LOCK(&sock->lock);
-
sock->pending_send = 0;
INSIST(sock->references > 0);
sock->references--; /* the internal event is done with this socket */
if (sock->references == 0) {
- UNLOCK(&sock->lock);
destroy(&sock);
return;
}
if (more_data)
select_poke(sock->manager, sock->fd, SELECT_POKE_WRITE);
-
- UNLOCK(&sock->lock);
}
static void
@@ -3289,31 +3188,24 @@ internal_fdwatch_read(isc_task_t *me, isc_event_t *ev) {
sock = (isc__socket_t *)ev->ev_sender;
INSIST(VALID_SOCKET(sock));
- LOCK(&sock->lock);
socket_log(sock, NULL, IOEVENT,
"internal_fdwatch_read: task %p got event %p", me, ev);
INSIST(sock->pending_recv == 1);
- UNLOCK(&sock->lock);
more_data = (sock->fdwatchcb)(me, (isc_socket_t *)sock,
sock->fdwatcharg, ISC_SOCKFDWATCH_READ);
- LOCK(&sock->lock);
-
sock->pending_recv = 0;
INSIST(sock->references > 0);
sock->references--; /* the internal event is done with this socket */
if (sock->references == 0) {
- UNLOCK(&sock->lock);
destroy(&sock);
return;
}
if (more_data)
select_poke(sock->manager, sock->fd, SELECT_POKE_READ);
-
- UNLOCK(&sock->lock);
}
/*
@@ -3325,31 +3217,23 @@ process_fd(isc__socketmgr_t *manager, int fd, isc_boolean_t readable,
isc_boolean_t writeable)
{
isc__socket_t *sock;
- isc_boolean_t unlock_sock;
isc_boolean_t unwatch_read = ISC_FALSE, unwatch_write = ISC_FALSE;
- int lockid = FDLOCK_ID(fd);
/*
* If the socket is going to be closed, don't do more I/O.
*/
- LOCK(&manager->fdlock[lockid]);
if (manager->fdstate[fd] == CLOSE_PENDING) {
- UNLOCK(&manager->fdlock[lockid]);
-
(void)unwatch_fd(manager, fd, SELECT_POKE_READ);
(void)unwatch_fd(manager, fd, SELECT_POKE_WRITE);
return;
}
sock = manager->fds[fd];
- unlock_sock = ISC_FALSE;
if (readable) {
if (sock == NULL) {
unwatch_read = ISC_TRUE;
goto check_write;
}
- unlock_sock = ISC_TRUE;
- LOCK(&sock->lock);
if (!SOCK_DEAD(sock)) {
if (sock->listener)
dispatch_accept(sock);
@@ -3364,10 +3248,6 @@ check_write:
unwatch_write = ISC_TRUE;
goto unlock_fd;
}
- if (!unlock_sock) {
- unlock_sock = ISC_TRUE;
- LOCK(&sock->lock);
- }
if (!SOCK_DEAD(sock)) {
if (sock->connecting)
dispatch_connect(sock);
@@ -3376,11 +3256,8 @@ check_write:
}
unwatch_write = ISC_TRUE;
}
- if (unlock_sock)
- UNLOCK(&sock->lock);
unlock_fd:
- UNLOCK(&manager->fdlock[lockid]);
if (unwatch_read)
(void)unwatch_fd(manager, fd, SELECT_POKE_READ);
if (unwatch_write)
@@ -3606,7 +3483,6 @@ isc_result_t
isc__socketmgr_create2(isc_socketmgr_t **managerp,
unsigned int maxsocks)
{
- int i;
isc__socketmgr_t *manager;
isc_result_t result;
@@ -3659,24 +3535,6 @@ isc__socketmgr_create2(isc_socketmgr_t **managerp,
manager->common.impmagic = SOCKET_MANAGER_MAGIC;
memset(manager->fds, 0, manager->maxsocks * sizeof(isc_socket_t *));
ISC_LIST_INIT(manager->socklist);
- result = isc_mutex_init(&manager->lock);
- if (result != ISC_R_SUCCESS)
- goto free_manager;
- manager->fdlock = malloc(FDLOCK_COUNT * sizeof(isc_mutex_t));
- if (manager->fdlock == NULL) {
- result = ISC_R_NOMEMORY;
- goto cleanup_lock;
- }
- for (i = 0; i < FDLOCK_COUNT; i++) {
- result = isc_mutex_init(&manager->fdlock[i]);
- if (result != ISC_R_SUCCESS) {
- while (--i >= 0)
- DESTROYLOCK(&manager->fdlock[i]);
- free(manager->fdlock);
- manager->fdlock = NULL;
- goto cleanup_lock;
- }
- }
manager->refs = 1;
@@ -3696,18 +3554,7 @@ isc__socketmgr_create2(isc_socketmgr_t **managerp,
cleanup:
-
-cleanup_lock:
- if (manager->fdlock != NULL) {
- for (i = 0; i < FDLOCK_COUNT; i++)
- DESTROYLOCK(&manager->fdlock[i]);
- }
- DESTROYLOCK(&manager->lock);
-
free_manager:
- if (manager->fdlock != NULL) {
- free(manager->fdlock);
- }
#if defined(USE_EPOLL)
if (manager->epoll_events != NULL) {
free(manager->epoll_events);
@@ -3755,19 +3602,13 @@ isc__socketmgr_destroy(isc_socketmgr_t **managerp) {
}
socketmgr = NULL;
- LOCK(&manager->lock);
-
/*
* Wait for all sockets to be destroyed.
*/
while (!ISC_LIST_EMPTY(manager->socklist)) {
- UNLOCK(&manager->lock);
isc__taskmgr_dispatch(NULL);
- LOCK(&manager->lock);
}
- UNLOCK(&manager->lock);
-
/*
* Here, poke our select/poll thread. Do this by closing the write
* half of the pipe, which will send EOF to the read half.
@@ -3790,12 +3631,6 @@ isc__socketmgr_destroy(isc_socketmgr_t **managerp) {
free(manager->fds);
free(manager->fdstate);
- if (manager->fdlock != NULL) {
- for (i = 0; i < FDLOCK_COUNT; i++)
- DESTROYLOCK(&manager->fdlock[i]);
- free(manager->fdlock);
- }
- DESTROYLOCK(&manager->lock);
manager->common.magic = 0;
manager->common.impmagic = 0;
free(manager);
@@ -3810,7 +3645,6 @@ socket_recv(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
unsigned int flags)
{
int io_state;
- isc_boolean_t have_lock = ISC_FALSE;
isc_task_t *ntask = NULL;
isc_result_t result = ISC_R_SUCCESS;
@@ -3819,9 +3653,6 @@ socket_recv(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
if (sock->type == isc_sockettype_udp) {
io_state = doio_recv(sock, dev);
} else {
- LOCK(&sock->lock);
- have_lock = ISC_TRUE;
-
if (ISC_LIST_EMPTY(sock->recv_list))
io_state = doio_recv(sock, dev);
else
@@ -3839,11 +3670,6 @@ socket_recv(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
isc_task_attach(task, &ntask);
dev->attributes |= ISC_SOCKEVENTATTR_ATTACHED;
- if (!have_lock) {
- LOCK(&sock->lock);
- have_lock = ISC_TRUE;
- }
-
/*
* Enqueue the request. If the socket was previously not being
* watched, poke the watcher to start paying attention to it.
@@ -3871,9 +3697,6 @@ socket_recv(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
break;
}
- if (have_lock)
- UNLOCK(&sock->lock);
-
return (result);
}
@@ -3993,7 +3816,6 @@ socket_send(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
unsigned int flags)
{
int io_state;
- isc_boolean_t have_lock = ISC_FALSE;
isc_task_t *ntask = NULL;
isc_result_t result = ISC_R_SUCCESS;
@@ -4021,9 +3843,6 @@ socket_send(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
if (sock->type == isc_sockettype_udp)
io_state = doio_send(sock, dev);
else {
- LOCK(&sock->lock);
- have_lock = ISC_TRUE;
-
if (ISC_LIST_EMPTY(sock->send_list))
io_state = doio_send(sock, dev);
else
@@ -4040,11 +3859,6 @@ socket_send(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
isc_task_attach(task, &ntask);
dev->attributes |= ISC_SOCKEVENTATTR_ATTACHED;
- if (!have_lock) {
- LOCK(&sock->lock);
- have_lock = ISC_TRUE;
- }
-
/*
* Enqueue the request. If the socket was previously
* not being watched, poke the watcher to start
@@ -4074,9 +3888,6 @@ socket_send(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
break;
}
- if (have_lock)
- UNLOCK(&sock->lock);
-
return (result);
}
@@ -4384,13 +4195,10 @@ isc__socket_bind(isc_socket_t *sock0, isc_sockaddr_t *sockaddr,
REQUIRE(VALID_SOCKET(sock));
- LOCK(&sock->lock);
-
INSIST(!sock->bound);
INSIST(!sock->dupped);
if (sock->pf != sockaddr->type.sa.sa_family) {
- UNLOCK(&sock->lock);
return (ISC_R_FAMILYMISMATCH);
}
@@ -4413,8 +4221,6 @@ isc__socket_bind(isc_socket_t *sock0, isc_sockaddr_t *sockaddr,
bind_socket:
#endif
if (bind(sock->fd, &sockaddr->type.sa, sockaddr->length) < 0) {
-
- UNLOCK(&sock->lock);
switch (errno) {
case EACCES:
return (ISC_R_NOPERM);
@@ -4435,7 +4241,6 @@ isc__socket_bind(isc_socket_t *sock0, isc_sockaddr_t *sockaddr,
socket_log(sock, sockaddr, TRACE, "bound");
sock->bound = 1;
- UNLOCK(&sock->lock);
return (ISC_R_SUCCESS);
}
@@ -4492,8 +4297,6 @@ isc__socket_listen(isc_socket_t *sock0, unsigned int backlog) {
REQUIRE(VALID_SOCKET(sock));
- LOCK(&sock->lock);
-
REQUIRE(!sock->listener);
REQUIRE(sock->bound);
REQUIRE(sock->type == isc_sockettype_tcp ||
@@ -4503,7 +4306,6 @@ isc__socket_listen(isc_socket_t *sock0, unsigned int backlog) {
backlog = SOMAXCONN;
if (listen(sock->fd, (int)backlog) < 0) {
- UNLOCK(&sock->lock);
isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__, "listen: %s", strbuf);
@@ -4513,7 +4315,6 @@ isc__socket_listen(isc_socket_t *sock0, unsigned int backlog) {
sock->listener = 1;
- UNLOCK(&sock->lock);
return (ISC_R_SUCCESS);
}
@@ -4536,8 +4337,6 @@ isc__socket_accept(isc_socket_t *sock0,
manager = sock->manager;
REQUIRE(VALID_MANAGER(manager));
- LOCK(&sock->lock);
-
REQUIRE(sock->listener);
/*
@@ -4549,7 +4348,6 @@ isc__socket_accept(isc_socket_t *sock0,
isc_event_allocate(task, ISC_SOCKEVENT_NEWCONN,
action, arg, sizeof(*dev));
if (dev == NULL) {
- UNLOCK(&sock->lock);
return (ISC_R_NOMEMORY);
}
ISC_LINK_INIT(dev, ev_link);
@@ -4557,7 +4355,6 @@ isc__socket_accept(isc_socket_t *sock0,
result = allocate_socket(manager, sock->type, &nsock);
if (result != ISC_R_SUCCESS) {
isc_event_free(ISC_EVENT_PTR(&dev));
- UNLOCK(&sock->lock);
return (result);
}
@@ -4569,7 +4366,6 @@ isc__socket_accept(isc_socket_t *sock0,
free_socket(&nsock);
isc_task_detach(&ntask);
isc_event_free(ISC_EVENT_PTR(&dev));
- UNLOCK(&sock->lock);
return (ISC_R_SHUTTINGDOWN);
}
nsock->references++;
@@ -4590,7 +4386,6 @@ isc__socket_accept(isc_socket_t *sock0,
if (do_poke)
select_poke(manager, sock->fd, SELECT_POKE_ACCEPT);
- UNLOCK(&sock->lock);
return (ISC_R_SUCCESS);
}
@@ -4618,8 +4413,6 @@ isc__socket_connect(isc_socket_t *sock0, isc_sockaddr_t *addr,
if (isc_sockaddr_ismulticast(addr))
return (ISC_R_MULTICAST);
- LOCK(&sock->lock);
-
REQUIRE(!sock->connecting);
dev = (isc_socket_connev_t *)isc_event_allocate(sock,
@@ -4627,7 +4420,6 @@ isc__socket_connect(isc_socket_t *sock0, isc_sockaddr_t *addr,
action, arg,
sizeof(*dev));
if (dev == NULL) {
- UNLOCK(&sock->lock);
return (ISC_R_NOMEMORY);
}
ISC_LINK_INIT(dev, ev_link);
@@ -4677,7 +4469,6 @@ isc__socket_connect(isc_socket_t *sock0, isc_sockaddr_t *addr,
UNEXPECTED_ERROR(__FILE__, __LINE__, "connect(%s) %d/%s",
addrbuf, errno, strbuf);
- UNLOCK(&sock->lock);
isc_event_free(ISC_EVENT_PTR(&dev));
return (ISC_R_UNEXPECTED);
@@ -4685,7 +4476,6 @@ isc__socket_connect(isc_socket_t *sock0, isc_sockaddr_t *addr,
sock->connected = 0;
isc_task_send(task, ISC_EVENT_PTR(&dev));
- UNLOCK(&sock->lock);
return (ISC_R_SUCCESS);
}
@@ -4699,9 +4489,6 @@ isc__socket_connect(isc_socket_t *sock0, isc_sockaddr_t *addr,
dev->result = ISC_R_SUCCESS;
isc_task_send(task, ISC_EVENT_PTR(&dev));
- UNLOCK(&sock->lock);
-
-
return (ISC_R_SUCCESS);
}
@@ -4726,7 +4513,6 @@ isc__socket_connect(isc_socket_t *sock0, isc_sockaddr_t *addr,
sock->connect_ev = dev;
- UNLOCK(&sock->lock);
return (ISC_R_SUCCESS);
}
@@ -4749,8 +4535,6 @@ internal_connect(isc_task_t *me, isc_event_t *ev) {
sock = ev->ev_sender;
INSIST(VALID_SOCKET(sock));
- LOCK(&sock->lock);
-
/*
* When the internal event was sent the reference count was bumped
* to keep the socket around for us. Decrement the count here.
@@ -4758,7 +4542,6 @@ internal_connect(isc_task_t *me, isc_event_t *ev) {
INSIST(sock->references > 0);
sock->references--;
if (sock->references == 0) {
- UNLOCK(&sock->lock);
destroy(&sock);
return;
}
@@ -4769,7 +4552,6 @@ internal_connect(isc_task_t *me, isc_event_t *ev) {
dev = sock->connect_ev;
if (dev == NULL) {
INSIST(!sock->connecting);
- UNLOCK(&sock->lock);
return;
}
@@ -4795,8 +4577,6 @@ internal_connect(isc_task_t *me, isc_event_t *ev) {
sock->connecting = 1;
select_poke(sock->manager, sock->fd,
SELECT_POKE_CONNECT);
- UNLOCK(&sock->lock);
-
return;
}
@@ -4838,8 +4618,6 @@ internal_connect(isc_task_t *me, isc_event_t *ev) {
sock->connect_ev = NULL;
- UNLOCK(&sock->lock);
-
task = dev->ev_sender;
dev->ev_sender = sock;
isc_task_sendanddetach(&task, ISC_EVENT_PTR(&dev));
@@ -4853,8 +4631,6 @@ isc__socket_getpeername(isc_socket_t *sock0, isc_sockaddr_t *addressp) {
REQUIRE(VALID_SOCKET(sock));
REQUIRE(addressp != NULL);
- LOCK(&sock->lock);
-
if (sock->connected) {
*addressp = sock->peer_address;
result = ISC_R_SUCCESS;
@@ -4862,8 +4638,6 @@ isc__socket_getpeername(isc_socket_t *sock0, isc_sockaddr_t *addressp) {
result = ISC_R_NOTCONNECTED;
}
- UNLOCK(&sock->lock);
-
return (result);
}
@@ -4877,8 +4651,6 @@ isc__socket_getsockname(isc_socket_t *sock0, isc_sockaddr_t *addressp) {
REQUIRE(VALID_SOCKET(sock));
REQUIRE(addressp != NULL);
- LOCK(&sock->lock);
-
if (!sock->bound) {
result = ISC_R_NOTBOUND;
goto out;
@@ -4897,8 +4669,6 @@ isc__socket_getsockname(isc_socket_t *sock0, isc_sockaddr_t *addressp) {
addressp->length = (unsigned int)len;
out:
- UNLOCK(&sock->lock);
-
return (result);
}
@@ -4919,8 +4689,6 @@ isc__socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) {
if (how == 0)
return;
- LOCK(&sock->lock);
-
/*
* All of these do the same thing, more or less.
* Each will:
@@ -5024,7 +4792,6 @@ isc__socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) {
}
}
- UNLOCK(&sock->lock);
}
isc_sockettype_t
@@ -5043,10 +4810,7 @@ isc__socket_isbound(isc_socket_t *sock0) {
REQUIRE(VALID_SOCKET(sock));
- LOCK(&sock->lock);
val = ((sock->bound) ? ISC_TRUE : ISC_FALSE);
- UNLOCK(&sock->lock);
-
return (val);
}
@@ -5232,10 +4996,8 @@ isc__socket_setname(isc_socket_t *socket0, const char *name, void *tag) {
REQUIRE(VALID_SOCKET(sock));
- LOCK(&sock->lock);
strlcpy(sock->name, name, sizeof(sock->name));
sock->tag = tag;
- UNLOCK(&sock->lock);
}
const char *
diff --git a/usr.sbin/bind/lib/isc/unix/strerror.c b/usr.sbin/bind/lib/isc/unix/strerror.c
index 809a4f751b6..16a7fdb0e14 100644
--- a/usr.sbin/bind/lib/isc/unix/strerror.c
+++ b/usr.sbin/bind/lib/isc/unix/strerror.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: strerror.c,v 1.5 2020/01/20 18:51:53 florian Exp $ */
+/* $Id: strerror.c,v 1.6 2020/01/21 23:59:20 tedu Exp $ */
/*! \file */
@@ -23,35 +23,19 @@
#include <stdio.h>
#include <string.h>
-#include <isc/mutex.h>
-#include <isc/once.h>
-
#include <isc/strerror.h>
#include <isc/util.h>
-/*%
- * We need to do this this way for profiled locks.
- */
-static isc_mutex_t isc_strerror_lock;
-static void init_lock(void) {
- RUNTIME_CHECK(isc_mutex_init(&isc_strerror_lock) == ISC_R_SUCCESS);
-}
-
void
isc__strerror(int num, char *buf, size_t size) {
char *msg;
unsigned int unum = (unsigned int)num;
- static isc_once_t once = ISC_ONCE_INIT;
REQUIRE(buf != NULL);
- RUNTIME_CHECK(isc_once_do(&once, init_lock) == ISC_R_SUCCESS);
-
- LOCK(&isc_strerror_lock);
msg = strerror(num);
if (msg != NULL)
snprintf(buf, size, "%s", msg);
else
snprintf(buf, size, "Unknown error: %u", unum);
- UNLOCK(&isc_strerror_lock);
}