mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
isc_condition_init returns 'void'
This commit is contained in:
committed by
Witold Kręcicki
parent
0bed9bfc28
commit
73a8999d1c
@@ -9,22 +9,30 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
#ifndef ISC_CONDITION_H
|
|
||||||
#define ISC_CONDITION_H 1
|
|
||||||
|
|
||||||
/*! \file */
|
/*! \file */
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <isc/error.h>
|
||||||
#include <isc/lang.h>
|
#include <isc/lang.h>
|
||||||
#include <isc/mutex.h>
|
#include <isc/mutex.h>
|
||||||
#include <isc/result.h>
|
#include <isc/result.h>
|
||||||
|
#include <isc/strerr.h>
|
||||||
#include <isc/types.h>
|
#include <isc/types.h>
|
||||||
|
|
||||||
typedef pthread_cond_t isc_condition_t;
|
typedef pthread_cond_t isc_condition_t;
|
||||||
|
|
||||||
#define isc_condition_init(cp) \
|
#define isc_condition_init(cond) \
|
||||||
(RUNTIME_CHECK(pthread_cond_init((cp), NULL) == 0), \
|
if (pthread_cond_init(cond, NULL) != 0) { \
|
||||||
ISC_R_SUCCESS)
|
char isc_condition_strbuf[ISC_STRERRORSIZE]; \
|
||||||
|
strerror_r(errno, isc_condition_strbuf, \
|
||||||
|
sizeof(isc_condition_strbuf)); \
|
||||||
|
isc_error_fatal(__FILE__, __LINE__, \
|
||||||
|
"pthread_cond_init failed: %s", \
|
||||||
|
isc_condition_strbuf); \
|
||||||
|
}
|
||||||
|
|
||||||
#if ISC_MUTEX_PROFILE
|
#if ISC_MUTEX_PROFILE
|
||||||
#define isc_condition_wait(cp, mp) \
|
#define isc_condition_wait(cp, mp) \
|
||||||
@@ -54,5 +62,3 @@ isc_result_t
|
|||||||
isc_condition_waituntil(isc_condition_t *, isc_mutex_t *, isc_time_t *);
|
isc_condition_waituntil(isc_condition_t *, isc_mutex_t *, isc_time_t *);
|
||||||
|
|
||||||
ISC_LANG_ENDDECLS
|
ISC_LANG_ENDDECLS
|
||||||
|
|
||||||
#endif /* ISC_CONDITION_H */
|
|
||||||
|
@@ -122,37 +122,12 @@ isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
|
|||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
return (result);
|
return (result);
|
||||||
|
|
||||||
result = isc_condition_init(&rwl->readable);
|
isc_condition_init(&rwl->readable);
|
||||||
if (result != ISC_R_SUCCESS) {
|
isc_condition_init(&rwl->writeable);
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
|
||||||
"isc_condition_init(readable) %s: %s",
|
|
||||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
|
|
||||||
ISC_MSG_FAILED, "failed"),
|
|
||||||
isc_result_totext(result));
|
|
||||||
result = ISC_R_UNEXPECTED;
|
|
||||||
goto destroy_lock;
|
|
||||||
}
|
|
||||||
result = isc_condition_init(&rwl->writeable);
|
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
|
||||||
"isc_condition_init(writeable) %s: %s",
|
|
||||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
|
|
||||||
ISC_MSG_FAILED, "failed"),
|
|
||||||
isc_result_totext(result));
|
|
||||||
result = ISC_R_UNEXPECTED;
|
|
||||||
goto destroy_rcond;
|
|
||||||
}
|
|
||||||
|
|
||||||
rwl->magic = RWLOCK_MAGIC;
|
rwl->magic = RWLOCK_MAGIC;
|
||||||
|
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
|
|
||||||
destroy_rcond:
|
|
||||||
(void)isc_condition_destroy(&rwl->readable);
|
|
||||||
destroy_lock:
|
|
||||||
DESTROYLOCK(&rwl->lock);
|
|
||||||
|
|
||||||
return (result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -1340,7 +1340,7 @@ isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
|||||||
RUNTIME_CHECK(isc_mutex_init(&manager->excl_lock) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_mutex_init(&manager->excl_lock) == ISC_R_SUCCESS);
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_mutex_init(&manager->halt_lock) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_mutex_init(&manager->halt_lock) == ISC_R_SUCCESS);
|
||||||
RUNTIME_CHECK(isc_condition_init(&manager->halt_cond) == ISC_R_SUCCESS);
|
isc_condition_init(&manager->halt_cond);
|
||||||
|
|
||||||
manager->workers = workers;
|
manager->workers = workers;
|
||||||
|
|
||||||
@@ -1372,9 +1372,8 @@ isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
|||||||
INIT_LIST(manager->queues[i].ready_priority_tasks);
|
INIT_LIST(manager->queues[i].ready_priority_tasks);
|
||||||
RUNTIME_CHECK(isc_mutex_init(&manager->queues[i].lock)
|
RUNTIME_CHECK(isc_mutex_init(&manager->queues[i].lock)
|
||||||
== ISC_R_SUCCESS);
|
== ISC_R_SUCCESS);
|
||||||
RUNTIME_CHECK(isc_condition_init(
|
isc_condition_init(&manager->queues[i].work_available);
|
||||||
&manager->queues[i].work_available)
|
|
||||||
== ISC_R_SUCCESS);
|
|
||||||
manager->queues[i].manager = manager;
|
manager->queues[i].manager = manager;
|
||||||
manager->queues[i].threadid = i;
|
manager->queues[i].threadid = i;
|
||||||
RUNTIME_CHECK(isc_thread_create(run, &manager->queues[i],
|
RUNTIME_CHECK(isc_thread_create(run, &manager->queues[i],
|
||||||
@@ -1875,4 +1874,3 @@ isc_taskmgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
|
|||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -59,8 +59,7 @@ _setup(void **state) {
|
|||||||
result = isc_mutex_init(&lock);
|
result = isc_mutex_init(&lock);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = isc_condition_init(&cv);
|
isc_condition_init(&cv);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
result = isc_test_begin(NULL, true, 0);
|
result = isc_test_begin(NULL, true, 0);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
@@ -77,8 +76,7 @@ _setup2(void **state) {
|
|||||||
result = isc_mutex_init(&lock);
|
result = isc_mutex_init(&lock);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = isc_condition_init(&cv);
|
isc_condition_init(&cv);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
/* Two worker threads */
|
/* Two worker threads */
|
||||||
result = isc_test_begin(NULL, true, 2);
|
result = isc_test_begin(NULL, true, 2);
|
||||||
@@ -96,8 +94,7 @@ _setup4(void **state) {
|
|||||||
result = isc_mutex_init(&lock);
|
result = isc_mutex_init(&lock);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = isc_condition_init(&cv);
|
isc_condition_init(&cv);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
/* Four worker threads */
|
/* Four worker threads */
|
||||||
result = isc_test_begin(NULL, true, 4);
|
result = isc_test_begin(NULL, true, 4);
|
||||||
@@ -712,8 +709,7 @@ manytasks(void **state) {
|
|||||||
(unsigned long)ntasks);
|
(unsigned long)ntasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = isc_condition_init(&cv);
|
isc_condition_init(&cv);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||||
result = isc_mem_create(0, 0, &mctx);
|
result = isc_mem_create(0, 0, &mctx);
|
||||||
@@ -914,8 +910,7 @@ post_shutdown(void **state) {
|
|||||||
done = false;
|
done = false;
|
||||||
event_type = 4;
|
event_type = 4;
|
||||||
|
|
||||||
result = isc_condition_init(&cv);
|
isc_condition_init(&cv);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
LOCK(&lock);
|
LOCK(&lock);
|
||||||
|
|
||||||
@@ -1056,8 +1051,7 @@ test_purge(int sender, int type, int tag, int exp_purged) {
|
|||||||
done = false;
|
done = false;
|
||||||
eventcnt = 0;
|
eventcnt = 0;
|
||||||
|
|
||||||
result = isc_condition_init(&cv);
|
isc_condition_init(&cv);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
result = isc_task_create(taskmgr, 0, &task);
|
result = isc_task_create(taskmgr, 0, &task);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
@@ -1356,8 +1350,7 @@ try_purgeevent(bool purgeable) {
|
|||||||
done = false;
|
done = false;
|
||||||
eventcnt = 0;
|
eventcnt = 0;
|
||||||
|
|
||||||
result = isc_condition_init(&cv);
|
isc_condition_init(&cv);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
result = isc_task_create(taskmgr, 0, &task);
|
result = isc_task_create(taskmgr, 0, &task);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
@@ -108,8 +108,7 @@ setup_test(isc_timertype_t timertype, isc_time_t *expires,
|
|||||||
result = isc_mutex_init(&mx);
|
result = isc_mutex_init(&mx);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = isc_condition_init(&cv);
|
isc_condition_init(&cv);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
LOCK(&mx);
|
LOCK(&mx);
|
||||||
|
|
||||||
@@ -506,8 +505,7 @@ purge(void **state) {
|
|||||||
result = isc_mutex_init(&mx);
|
result = isc_mutex_init(&mx);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = isc_condition_init(&cv);
|
isc_condition_init(&cv);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
result = isc_task_create(taskmgr, 0, &task1);
|
result = isc_task_create(taskmgr, 0, &task1);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
@@ -750,17 +750,7 @@ isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
|
|||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
isc_mem_attach(mctx, &manager->mctx);
|
isc_mem_attach(mctx, &manager->mctx);
|
||||||
if (isc_condition_init(&manager->wakeup) != ISC_R_SUCCESS) {
|
isc_condition_init(&manager->wakeup);
|
||||||
isc_mem_detach(&manager->mctx);
|
|
||||||
DESTROYLOCK(&manager->lock);
|
|
||||||
isc_heap_destroy(&manager->heap);
|
|
||||||
isc_mem_put(mctx, manager, sizeof(*manager));
|
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
|
||||||
"isc_condition_init() %s",
|
|
||||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
|
|
||||||
ISC_MSG_FAILED, "failed"));
|
|
||||||
return (ISC_R_UNEXPECTED);
|
|
||||||
}
|
|
||||||
if (isc_thread_create(run, manager, &manager->thread) !=
|
if (isc_thread_create(run, manager, &manager->thread) !=
|
||||||
ISC_R_SUCCESS) {
|
ISC_R_SUCCESS) {
|
||||||
isc_mem_detach(&manager->mctx);
|
isc_mem_detach(&manager->mctx);
|
||||||
|
@@ -142,9 +142,7 @@ isc_app_ctxstart(isc_appctx_t *ctx0) {
|
|||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
return (result);
|
return (result);
|
||||||
|
|
||||||
result = isc_condition_init(&ctx->ready);
|
isc_condition_init(&ctx->ready);
|
||||||
if (result != ISC_R_SUCCESS)
|
|
||||||
goto cleanup_rlock;
|
|
||||||
|
|
||||||
result = isc_mutex_init(&ctx->lock);
|
result = isc_mutex_init(&ctx->lock);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
@@ -236,8 +234,6 @@ isc_app_ctxstart(isc_appctx_t *ctx0) {
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
(void)isc_condition_destroy(&ctx->ready);
|
(void)isc_condition_destroy(&ctx->ready);
|
||||||
|
|
||||||
cleanup_rlock:
|
|
||||||
(void)isc_mutex_destroy(&ctx->readylock);
|
(void)isc_mutex_destroy(&ctx->readylock);
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
@@ -3934,8 +3934,7 @@ isc_socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
|
|||||||
ISC_LIST_INIT(manager->socklist);
|
ISC_LIST_INIT(manager->socklist);
|
||||||
RUNTIME_CHECK(isc_mutex_init(&manager->lock) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_mutex_init(&manager->lock) == ISC_R_SUCCESS);
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_condition_init(&manager->shutdown_ok)
|
isc_condition_init(&manager->shutdown_ok);
|
||||||
== ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start up the select/poll thread.
|
* Start up the select/poll thread.
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
@@ -17,14 +16,16 @@
|
|||||||
|
|
||||||
#include <isc/condition.h>
|
#include <isc/condition.h>
|
||||||
#include <isc/assertions.h>
|
#include <isc/assertions.h>
|
||||||
|
#include <isc/error.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
#include <isc/strerr.h>
|
||||||
#include <isc/thread.h>
|
#include <isc/thread.h>
|
||||||
#include <isc/time.h>
|
#include <isc/time.h>
|
||||||
|
|
||||||
#define LSIGNAL 0
|
#define LSIGNAL 0
|
||||||
#define LBROADCAST 1
|
#define LBROADCAST 1
|
||||||
|
|
||||||
isc_result_t
|
void
|
||||||
isc_condition_init(isc_condition_t *cond) {
|
isc_condition_init(isc_condition_t *cond) {
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
|
|
||||||
@@ -36,8 +37,11 @@ isc_condition_init(isc_condition_t *cond) {
|
|||||||
*/
|
*/
|
||||||
h = CreateEvent(NULL, FALSE, FALSE, NULL);
|
h = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
if (h == NULL) {
|
if (h == NULL) {
|
||||||
/* XXX */
|
char strbuf[ISC_STRERRORSIZE];
|
||||||
return (ISC_R_UNEXPECTED);
|
DWORD err = GetLastError();
|
||||||
|
strerror_r(err, strbuf, sizeof(strbuf));
|
||||||
|
isc_error_fatal(__FILE__, __LINE,
|
||||||
|
"CreateEvent failed: %s", strbuf);
|
||||||
}
|
}
|
||||||
cond->events[LSIGNAL] = h;
|
cond->events[LSIGNAL] = h;
|
||||||
|
|
||||||
@@ -46,8 +50,6 @@ isc_condition_init(isc_condition_t *cond) {
|
|||||||
* for the wait condition
|
* for the wait condition
|
||||||
*/
|
*/
|
||||||
ISC_LIST_INIT(cond->threadlist);
|
ISC_LIST_INIT(cond->threadlist);
|
||||||
|
|
||||||
return (ISC_R_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -131,7 +133,6 @@ isc_condition_signal(isc_condition_t *cond) {
|
|||||||
/* XXX */
|
/* XXX */
|
||||||
return (ISC_R_UNEXPECTED);
|
return (ISC_R_UNEXPECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -37,7 +37,7 @@ typedef struct isc_condition {
|
|||||||
|
|
||||||
ISC_LANG_BEGINDECLS
|
ISC_LANG_BEGINDECLS
|
||||||
|
|
||||||
isc_result_t
|
void
|
||||||
isc_condition_init(isc_condition_t *);
|
isc_condition_init(isc_condition_t *);
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
|
@@ -2561,15 +2561,7 @@ isc_socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
|
|||||||
isc_mem_put(mctx, manager, sizeof(*manager));
|
isc_mem_put(mctx, manager, sizeof(*manager));
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
if (isc_condition_init(&manager->shutdown_ok) != ISC_R_SUCCESS) {
|
isc_condition_init(&manager->shutdown_ok);
|
||||||
DESTROYLOCK(&manager->lock);
|
|
||||||
isc_mem_put(mctx, manager, sizeof(*manager));
|
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
|
||||||
"isc_condition_init() %s",
|
|
||||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
|
|
||||||
ISC_MSG_FAILED, "failed"));
|
|
||||||
return (ISC_R_UNEXPECTED);
|
|
||||||
}
|
|
||||||
|
|
||||||
isc_mem_attach(mctx, &manager->mctx);
|
isc_mem_attach(mctx, &manager->mctx);
|
||||||
if (nthreads == 0) {
|
if (nthreads == 0) {
|
||||||
|
Reference in New Issue
Block a user