Commit 1d9b3491 authored by Bob Halley's avatar Bob Halley
Browse files

convert to RUNTIME_CHECK

parent 6095901f
......@@ -23,6 +23,7 @@
#include <unistd.h>
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/lex.h>
isc_mem_t *mctx;
......@@ -64,7 +65,8 @@ print_token(isc_token_t *tokenp, FILE *stream) {
fprintf(stream, "SPECIAL %c", tokenp->value.as_char);
break;
default:
INSIST(0);
FATAL_ERROR(__FILE__, __LINE__, "Unexpected type %d",
tokenp->type);
}
}
......@@ -96,9 +98,8 @@ main(int argc, char *argv[]) {
}
}
INSIST(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
INSIST(isc_lex_create(mctx, 256, &lex) ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_lex_create(mctx, 256, &lex) == ISC_R_SUCCESS);
if (masterfile) {
/* Set up to lex DNS master file. */
......@@ -131,7 +132,7 @@ main(int argc, char *argv[]) {
ISC_LEXCOMMENT_SHELL));
}
INSIST(isc_lex_openstream(lex, stdin) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_lex_openstream(lex, stdin) == ISC_R_SUCCESS);
while ((result = isc_lex_gettoken(lex, options, &token)) ==
ISC_R_SUCCESS) {
......
......@@ -23,6 +23,7 @@
#include <unistd.h>
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/thread.h>
#include <isc/result.h>
#include <isc/rwlock.h>
......@@ -33,23 +34,26 @@ static void *
run1(void *arg) {
char *message = arg;
INSIST(isc_rwlock_lock(&lock, isc_rwlocktype_read) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_rwlock_lock(&lock, isc_rwlocktype_read) ==
ISC_R_SUCCESS);
printf("%s got READ lock\n", message);
sleep(1);
printf("%s giving up READ lock\n", message);
INSIST(isc_rwlock_unlock(&lock, isc_rwlocktype_read) ==
RUNTIME_CHECK(isc_rwlock_unlock(&lock, isc_rwlocktype_read) ==
ISC_R_SUCCESS);
INSIST(isc_rwlock_lock(&lock, isc_rwlocktype_read) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_rwlock_lock(&lock, isc_rwlocktype_read) ==
ISC_R_SUCCESS);
printf("%s got READ lock\n", message);
sleep(1);
printf("%s giving up READ lock\n", message);
INSIST(isc_rwlock_unlock(&lock, isc_rwlocktype_read) ==
RUNTIME_CHECK(isc_rwlock_unlock(&lock, isc_rwlocktype_read) ==
ISC_R_SUCCESS);
INSIST(isc_rwlock_lock(&lock, isc_rwlocktype_write) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_rwlock_lock(&lock, isc_rwlocktype_write) ==
ISC_R_SUCCESS);
printf("%s got WRITE lock\n", message);
sleep(1);
printf("%s giving up WRITE lock\n", message);
INSIST(isc_rwlock_unlock(&lock, isc_rwlocktype_write) ==
RUNTIME_CHECK(isc_rwlock_unlock(&lock, isc_rwlocktype_write) ==
ISC_R_SUCCESS);
return (NULL);
}
......@@ -58,23 +62,26 @@ static void *
run2(void *arg) {
char *message = arg;
INSIST(isc_rwlock_lock(&lock, isc_rwlocktype_write) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_rwlock_lock(&lock, isc_rwlocktype_write) ==
ISC_R_SUCCESS);
printf("%s got WRITE lock\n", message);
sleep(1);
printf("%s giving up WRITE lock\n", message);
INSIST(isc_rwlock_unlock(&lock, isc_rwlocktype_write) ==
RUNTIME_CHECK(isc_rwlock_unlock(&lock, isc_rwlocktype_write) ==
ISC_R_SUCCESS);
INSIST(isc_rwlock_lock(&lock, isc_rwlocktype_write) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_rwlock_lock(&lock, isc_rwlocktype_write) ==
ISC_R_SUCCESS);
printf("%s got WRITE lock\n", message);
sleep(1);
printf("%s giving up WRITE lock\n", message);
INSIST(isc_rwlock_unlock(&lock, isc_rwlocktype_write) ==
RUNTIME_CHECK(isc_rwlock_unlock(&lock, isc_rwlocktype_write) ==
ISC_R_SUCCESS);
INSIST(isc_rwlock_lock(&lock, isc_rwlocktype_read) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_rwlock_lock(&lock, isc_rwlocktype_read) ==
ISC_R_SUCCESS);
printf("%s got READ lock\n", message);
sleep(1);
printf("%s giving up READ lock\n", message);
INSIST(isc_rwlock_unlock(&lock, isc_rwlocktype_read) ==
RUNTIME_CHECK(isc_rwlock_unlock(&lock, isc_rwlocktype_read) ==
ISC_R_SUCCESS);
return (NULL);
}
......@@ -95,17 +102,19 @@ main(int argc, char *argv[]) {
nworkers = 100;
printf("%d workers\n", nworkers);
INSIST(isc_rwlock_init(&lock, 5, 10) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_rwlock_init(&lock, 5, 10) == ISC_R_SUCCESS);
for (i = 0; i < nworkers; i++) {
sprintf(name, "%02u", i);
dupname = strdup(name);
INSIST(dupname != NULL);
RUNTIME_CHECK(dupname != NULL);
if (i != 0 && i % 3 == 0)
INSIST(isc_thread_create(run1, dupname, &workers[i]) ==
RUNTIME_CHECK(isc_thread_create(run1, dupname,
&workers[i]) ==
ISC_R_SUCCESS);
else
INSIST(isc_thread_create(run2, dupname, &workers[i]) ==
RUNTIME_CHECK(isc_thread_create(run2, dupname,
&workers[i]) ==
ISC_R_SUCCESS);
}
......
......@@ -23,6 +23,7 @@
#include <string.h>
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/mem.h>
#include <isc/task.h>
#include <isc/thread.h>
......@@ -275,15 +276,17 @@ main(int argc, char *argv[])
workers = 2;
printf("%d workers\n", workers);
INSIST(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
INSIST(isc_taskmgr_create(mctx, workers, 0, &manager) ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &manager) ==
ISC_R_SUCCESS);
INSIST(isc_task_create(manager, 0, &t1) == ISC_R_SUCCESS);
INSIST(isc_task_create(manager, 0, &t2) == ISC_R_SUCCESS);
INSIST(isc_task_onshutdown(t1, my_shutdown, "1") == ISC_R_SUCCESS);
INSIST(isc_task_onshutdown(t2, my_shutdown, "2") == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_create(manager, 0, &t1) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_create(manager, 0, &t2) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_onshutdown(t1, my_shutdown, "1") ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_onshutdown(t2, my_shutdown, "2") ==
ISC_R_SUCCESS);
printf("task 1 = %p\n", t1);
printf("task 2 = %p\n", t2);
......@@ -291,12 +294,12 @@ main(int argc, char *argv[])
/*
* create the timer we'll need
*/
INSIST(isc_timermgr_create(mctx, &timgr) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_timermgr_create(mctx, &timgr) == ISC_R_SUCCESS);
(void)isc_time_get(&now);
socketmgr = NULL;
INSIST(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS);
/*
* open up a listener socket
......@@ -307,21 +310,22 @@ main(int argc, char *argv[])
sockaddr.type.sin.sin_family = AF_INET;
sockaddr.type.sin.sin_port = htons(5544);
addrlen = sizeof(struct sockaddr_in);
INSIST(isc_socket_create(socketmgr, isc_socket_tcp,
&so1) == ISC_R_SUCCESS);
INSIST(isc_socket_bind(so1, &sockaddr,
(int)addrlen) == ISC_R_SUCCESS);
INSIST(isc_socket_listen(so1, 0) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_socket_create(socketmgr, isc_socket_tcp, &so1) ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_socket_bind(so1, &sockaddr,
(int)addrlen) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_socket_listen(so1, 0) == ISC_R_SUCCESS);
/*
* queue up the first accept event
*/
INSIST(isc_socket_accept(so1, t1, my_listen,
"so1") == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_socket_accept(so1, t1, my_listen,
"so1") == ISC_R_SUCCESS);
isc_time_settoepoch(&expires);
isc_interval_set(&interval, 10, 0);
INSIST(isc_timer_create(timgr, isc_timertype_once, &expires, &interval,
t1, timeout, so1, &ti1) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_timer_create(timgr, isc_timertype_once, &expires,
&interval, t1, timeout, so1, &ti1) ==
ISC_R_SUCCESS);
/*
* open up a socket that will connect to www.flame.org, port 80.
......@@ -334,10 +338,10 @@ main(int argc, char *argv[])
sockaddr.type.sin.sin_family = AF_INET;
sockaddr.type.sin.sin_addr.s_addr = inet_addr("204.152.184.97");
addrlen = sizeof(struct sockaddr_in);
INSIST(isc_socket_create(socketmgr, isc_socket_tcp,
&so2) == ISC_R_SUCCESS);
INSIST(isc_socket_connect(so2, &sockaddr, (int)addrlen, t1, my_connect,
"so2") == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_socket_create(socketmgr, isc_socket_tcp,
&so2) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_socket_connect(so2, &sockaddr, (int)addrlen, t1,
my_connect, "so2") == ISC_R_SUCCESS);
sleep(1);
......
......@@ -23,6 +23,7 @@
#include <unistd.h>
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/result.h>
#include <isc/symtab.h>
......@@ -64,9 +65,9 @@ main(int argc, char *argv[]) {
}
}
INSIST(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
INSIST(isc_symtab_create(mctx, 691, undefine_action, case_sensitive,
&st) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_symtab_create(mctx, 691, undefine_action,
case_sensitive, &st) == ISC_R_SUCCESS);
while (gets(s) != NULL) {
len = strlen(s);
......
......@@ -22,6 +22,7 @@
#include <unistd.h>
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/mem.h>
#include <isc/task.h>
#include <isc/thread.h>
......@@ -78,35 +79,40 @@ main(int argc, char *argv[]) {
workers = 2;
printf("%d workers\n", workers);
INSIST(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
INSIST(isc_taskmgr_create(mctx, workers, 0, &manager) ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &manager) ==
ISC_R_SUCCESS);
INSIST(isc_task_create(manager, 0, &t1) == ISC_R_SUCCESS);
INSIST(isc_task_create(manager, 0, &t2) == ISC_R_SUCCESS);
INSIST(isc_task_create(manager, 0, &t3) == ISC_R_SUCCESS);
INSIST(isc_task_create(manager, 0, &t4) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_create(manager, 0, &t1) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_create(manager, 0, &t2) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_create(manager, 0, &t3) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_create(manager, 0, &t4) == ISC_R_SUCCESS);
INSIST(isc_task_onshutdown(t1, my_shutdown, "1") == ISC_R_SUCCESS);
INSIST(isc_task_onshutdown(t2, my_shutdown, "2") == ISC_R_SUCCESS);
INSIST(isc_task_onshutdown(t3, my_shutdown, "3") == ISC_R_SUCCESS);
INSIST(isc_task_onshutdown(t4, my_shutdown, "4") == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_onshutdown(t1, my_shutdown, "1") ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_onshutdown(t2, my_shutdown, "2") ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_onshutdown(t3, my_shutdown, "3") ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_onshutdown(t4, my_shutdown, "4") ==
ISC_R_SUCCESS);
timgr = NULL;
INSIST(isc_timermgr_create(mctx, &timgr) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_timermgr_create(mctx, &timgr) == ISC_R_SUCCESS);
ti1 = NULL;
isc_time_settoepoch(&absolute);
isc_interval_set(&interval, 1, 0);
INSIST(isc_timer_create(timgr, isc_timertype_ticker,
RUNTIME_CHECK(isc_timer_create(timgr, isc_timertype_ticker,
&absolute, &interval,
t1, my_tick, "foo", &ti1) == ISC_R_SUCCESS);
ti2 = NULL;
isc_time_settoepoch(&absolute);
isc_interval_set(&interval, 1, 0);
INSIST(isc_timer_create(timgr, isc_timertype_ticker,
&absolute, &interval,
t2, my_tick, "bar", &ti2) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_timer_create(timgr, isc_timertype_ticker,
&absolute, &interval,
t2, my_tick, "bar", &ti2) ==
ISC_R_SUCCESS);
printf("task 1 = %p\n", t1);
printf("task 2 = %p\n", t2);
......
......@@ -22,6 +22,7 @@
#include <unistd.h>
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/mem.h>
#include <isc/task.h>
#include <isc/thread.h>
......@@ -63,9 +64,9 @@ tick(isc_task_t *task, isc_event_t *event)
isc_time_add(&now, &interval, &expires);
isc_interval_set(&interval, 4, 0);
printf("*** resetting ti3 ***\n");
INSIST(isc_timer_reset(ti3, isc_timertype_once, &expires,
&interval, ISC_TRUE)
== ISC_R_SUCCESS);
RUNTIME_CHECK(isc_timer_reset(ti3, isc_timertype_once,
&expires, &interval, ISC_TRUE) ==
ISC_R_SUCCESS);
}
isc_event_free(&event);
......@@ -110,17 +111,20 @@ main(int argc, char *argv[]) {
workers = 2;
printf("%d workers\n", workers);
INSIST(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
INSIST(isc_taskmgr_create(mctx, workers, 0, &manager) ==
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &manager) ==
ISC_R_SUCCESS);
INSIST(isc_timermgr_create(mctx, &timgr) == ISC_R_SUCCESS);
INSIST(isc_task_create(manager, 0, &t1) == ISC_R_SUCCESS);
INSIST(isc_task_create(manager, 0, &t2) == ISC_R_SUCCESS);
INSIST(isc_task_create(manager, 0, &t3) == ISC_R_SUCCESS);
INSIST(isc_task_onshutdown(t1, shutdown_task, "1") == ISC_R_SUCCESS);
INSIST(isc_task_onshutdown(t2, shutdown_task, "2") == ISC_R_SUCCESS);
INSIST(isc_task_onshutdown(t3, shutdown_task, "3") == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_timermgr_create(mctx, &timgr) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_create(manager, 0, &t1) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_create(manager, 0, &t2) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_create(manager, 0, &t3) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_onshutdown(t1, shutdown_task, "1") ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_onshutdown(t2, shutdown_task, "2") ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_task_onshutdown(t3, shutdown_task, "3") ==
ISC_R_SUCCESS);
printf("task 1: %p\n", t1);
printf("task 2: %p\n", t2);
......@@ -130,18 +134,20 @@ main(int argc, char *argv[]) {
isc_time_settoepoch(&expires);
isc_interval_set(&interval, 2, 0);
INSIST(isc_timer_create(timgr, isc_timertype_once, &expires, &interval,
t2, timeout, "2", &ti2) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_timer_create(timgr, isc_timertype_once, &expires,
&interval, t2, timeout, "2", &ti2) ==
ISC_R_SUCCESS);
isc_time_settoepoch(&expires);
isc_interval_set(&interval, 1, 0);
INSIST(isc_timer_create(timgr, isc_timertype_ticker,
RUNTIME_CHECK(isc_timer_create(timgr, isc_timertype_ticker,
&expires, &interval,
t1, tick, "1", &ti1) == ISC_R_SUCCESS);
isc_interval_set(&interval, 10, 0);
isc_time_add(&now, &interval, &expires);
isc_interval_set(&interval, 2, 0);
INSIST(isc_timer_create(timgr, isc_timertype_once, &expires, &interval,
t3, timeout, "3", &ti3) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_timer_create(timgr, isc_timertype_once, &expires,
&interval, t3, timeout, "3", &ti3) ==
ISC_R_SUCCESS);
isc_task_detach(&t1);
isc_task_detach(&t2);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment