Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
ISC Open Source Projects
BIND
Commits
f47bb8d1
Commit
f47bb8d1
authored
Oct 21, 1998
by
Bob Halley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
many name conversions
parent
8b935d4a
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
184 additions
and
194 deletions
+184
-194
bin/tests/task_test.c
bin/tests/task_test.c
+6
-6
bin/tests/timer_test.c
bin/tests/timer_test.c
+8
-8
lib/isc/heap.c
lib/isc/heap.c
+26
-27
lib/isc/include/isc/boolean.h
lib/isc/include/isc/boolean.h
+6
-20
lib/isc/include/isc/event.h
lib/isc/include/isc/event.h
+1
-1
lib/isc/include/isc/heap.h
lib/isc/include/isc/heap.h
+26
-21
lib/isc/include/isc/task.h
lib/isc/include/isc/task.h
+3
-3
lib/isc/include/isc/timer.h
lib/isc/include/isc/timer.h
+1
-1
lib/isc/pthreads/condition.c
lib/isc/pthreads/condition.c
+7
-7
lib/isc/pthreads/include/isc/condition.h
lib/isc/pthreads/include/isc/condition.h
+2
-2
lib/isc/task.c
lib/isc/task.c
+48
-48
lib/isc/timer.c
lib/isc/timer.c
+49
-49
lib/isc/unix/time.c
lib/isc/unix/time.c
+1
-1
No files found.
bin/tests/task_test.c
View file @
f47bb8d1
...
...
@@ -13,7 +13,7 @@
mem_context_t
mctx
=
NULL
;
static
boolean_t
static
isc_
boolean_t
my_callback
(
task_t
task
,
task_event_t
event
)
{
int
i
,
j
;
...
...
@@ -24,24 +24,24 @@ my_callback(task_t task, task_event_t event)
j
+=
100
;
printf
(
"task %s: %d
\n
"
,
name
,
j
);
return
(
FALSE
);
return
(
ISC_
FALSE
);
}
static
boolean_t
static
isc_
boolean_t
my_shutdown
(
task_t
task
,
task_event_t
event
)
{
char
*
name
=
event
->
arg
;
printf
(
"shutdown %s
\n
"
,
name
);
return
(
TRUE
);
return
(
ISC_
TRUE
);
}
static
boolean_t
static
isc_
boolean_t
my_tick
(
task_t
task
,
task_event_t
event
)
{
char
*
name
=
event
->
arg
;
printf
(
"task %p tick %s
\n
"
,
task
,
name
);
return
(
FALSE
);
return
(
ISC_
FALSE
);
}
void
...
...
bin/tests/timer_test.c
View file @
f47bb8d1
...
...
@@ -16,15 +16,15 @@ task_t t1, t2, t3;
timer_t
ti1
,
ti2
,
ti3
;
int
tick_count
=
0
;
static
boolean_t
static
isc_
boolean_t
shutdown_task
(
task_t
task
,
task_event_t
event
)
{
char
*
name
=
event
->
arg
;
printf
(
"shutdown %s
\n
"
,
name
);
return
(
TRUE
);
return
(
ISC_
TRUE
);
}
static
boolean_t
static
isc_
boolean_t
tick
(
task_t
task
,
task_event_t
event
)
{
char
*
name
=
event
->
arg
;
...
...
@@ -48,14 +48,14 @@ tick(task_t task, task_event_t event)
interval
.
nanoseconds
=
0
;
printf
(
"*** resetting ti3 ***
\n
"
);
INSIST
(
timer_reset
(
ti3
,
timer_type_once
,
expires
,
interval
,
TRUE
)
ISC_
TRUE
)
==
ISC_R_SUCCESS
);
}
return
(
FALSE
);
return
(
ISC_
FALSE
);
}
static
boolean_t
static
isc_
boolean_t
timeout
(
task_t
task
,
task_event_t
event
)
{
char
*
name
=
event
->
arg
;
...
...
@@ -72,9 +72,9 @@ timeout(task_t task, task_event_t event)
if
(
strcmp
(
name
,
"3"
)
==
0
)
{
printf
(
"*** saving task 3 ***
\n
"
);
return
(
FALSE
);
return
(
ISC_
FALSE
);
}
return
(
TRUE
);
return
(
ISC_
TRUE
);
}
void
...
...
lib/isc/heap.c
View file @
f47bb8d1
...
...
@@ -28,7 +28,6 @@
#include <stdlib.h>
#include <isc/assertions.h>
#include <isc/boolean.h>
#include <isc/heap.h>
/*
...
...
@@ -45,26 +44,26 @@
#define VALID_HEAP(h) ((h) != NULL && \
(h)->magic == HEAP_MAGIC)
struct
heap
_context
{
struct
isc_
heap
{
unsigned
int
magic
;
mem_context_t
mctx
;
unsigned
int
size
;
unsigned
int
size_increment
;
unsigned
int
last
;
void
**
array
;
heap_higher_priority_func
higher_priority
;
heap
_
index_
func
index
;
isc_heapcompare_t
compare
;
isc_
heapindex_
t
index
;
};
isc_result
heap_create
(
mem_context_t
mctx
,
heap_higher_priority_func
higher_priority
,
heap
_
index_
func
index
,
unsigned
int
size_increment
,
heap_t
*
heapp
)
isc_
heap_create
(
mem_context_t
mctx
,
isc_heapcompare_t
compare
,
isc_
heapindex_
t
index
,
unsigned
int
size_increment
,
isc_
heap_t
*
heapp
)
{
heap_t
heap
;
isc_
heap_t
heap
;
REQUIRE
(
heapp
!=
NULL
&&
*
heapp
==
NULL
);
REQUIRE
(
higher_priority
!=
NULL
);
REQUIRE
(
compare
!=
NULL
);
heap
=
mem_get
(
mctx
,
sizeof
*
heap
);
if
(
heap
==
NULL
)
...
...
@@ -78,7 +77,7 @@ heap_create(mem_context_t mctx, heap_higher_priority_func higher_priority,
heap
->
size_increment
=
size_increment
;
heap
->
last
=
0
;
heap
->
array
=
NULL
;
heap
->
higher_priority
=
higher_priority
;
heap
->
compare
=
compare
;
heap
->
index
=
index
;
*
heapp
=
heap
;
...
...
@@ -87,8 +86,8 @@ heap_create(mem_context_t mctx, heap_higher_priority_func higher_priority,
}
void
heap_destroy
(
heap_t
*
heapp
)
{
heap_t
heap
;
isc_
heap_destroy
(
isc_
heap_t
*
heapp
)
{
isc_
heap_t
heap
;
REQUIRE
(
heapp
!=
NULL
);
heap
=
*
heapp
;
...
...
@@ -103,8 +102,8 @@ heap_destroy(heap_t *heapp) {
*
heapp
=
NULL
;
}
static
boolean_t
resize
(
heap_t
heap
)
{
static
isc_
boolean_t
resize
(
isc_
heap_t
heap
)
{
void
**
new_array
;
size_t
new_size
;
...
...
@@ -113,7 +112,7 @@ resize(heap_t heap) {
new_size
=
heap
->
size
+
heap
->
size_increment
;
new_array
=
mem_get
(
heap
->
mctx
,
new_size
*
sizeof
(
void
*
));
if
(
new_array
==
NULL
)
return
(
FALSE
);
return
(
ISC_
FALSE
);
if
(
heap
->
array
!=
NULL
)
{
memcpy
(
new_array
,
heap
->
array
,
heap
->
size
);
mem_put
(
heap
->
mctx
,
heap
->
array
,
...
...
@@ -122,15 +121,15 @@ resize(heap_t heap) {
heap
->
size
=
new_size
;
heap
->
array
=
new_array
;
return
(
TRUE
);
return
(
ISC_
TRUE
);
}
static
void
float_up
(
heap_t
heap
,
unsigned
int
i
,
void
*
elt
)
{
float_up
(
isc_
heap_t
heap
,
unsigned
int
i
,
void
*
elt
)
{
unsigned
int
p
;
for
(
p
=
heap_parent
(
i
);
i
>
1
&&
heap
->
higher_priority
(
elt
,
heap
->
array
[
p
]);
i
>
1
&&
heap
->
compare
(
elt
,
heap
->
array
[
p
]);
i
=
p
,
p
=
heap_parent
(
i
)
)
{
heap
->
array
[
i
]
=
heap
->
array
[
p
];
if
(
heap
->
index
!=
NULL
)
...
...
@@ -142,7 +141,7 @@ float_up(heap_t heap, unsigned int i, void *elt) {
}
static
void
sink_down
(
heap_t
heap
,
unsigned
int
i
,
void
*
elt
)
{
sink_down
(
isc_
heap_t
heap
,
unsigned
int
i
,
void
*
elt
)
{
unsigned
int
j
,
size
,
half_size
;
size
=
heap
->
last
;
...
...
@@ -150,10 +149,10 @@ sink_down(heap_t heap, unsigned int i, void *elt) {
while
(
i
<=
half_size
)
{
/* find smallest of the (at most) two children */
j
=
heap_left
(
i
);
if
(
j
<
size
&&
heap
->
higher_priority
(
heap
->
array
[
j
+
1
],
if
(
j
<
size
&&
heap
->
compare
(
heap
->
array
[
j
+
1
],
heap
->
array
[
j
]))
j
++
;
if
(
heap
->
higher_priority
(
elt
,
heap
->
array
[
j
]))
if
(
heap
->
compare
(
elt
,
heap
->
array
[
j
]))
break
;
heap
->
array
[
i
]
=
heap
->
array
[
j
];
if
(
heap
->
index
!=
NULL
)
...
...
@@ -166,7 +165,7 @@ sink_down(heap_t heap, unsigned int i, void *elt) {
}
isc_result
heap_insert
(
heap_t
heap
,
void
*
elt
)
{
isc_
heap_insert
(
isc_
heap_t
heap
,
void
*
elt
)
{
unsigned
int
i
;
REQUIRE
(
VALID_HEAP
(
heap
));
...
...
@@ -181,7 +180,7 @@ heap_insert(heap_t heap, void *elt) {
}
void
heap_delete
(
heap_t
heap
,
unsigned
int
i
)
{
isc_
heap_delete
(
isc_
heap_t
heap
,
unsigned
int
i
)
{
void
*
elt
;
REQUIRE
(
VALID_HEAP
(
heap
));
...
...
@@ -193,7 +192,7 @@ heap_delete(heap_t heap, unsigned int i) {
}
void
heap_increased
(
heap_t
heap
,
unsigned
int
i
)
{
isc_
heap_increased
(
isc_
heap_t
heap
,
unsigned
int
i
)
{
REQUIRE
(
VALID_HEAP
(
heap
));
REQUIRE
(
i
>=
1
&&
i
<=
heap
->
last
);
...
...
@@ -201,7 +200,7 @@ heap_increased(heap_t heap, unsigned int i) {
}
void
heap_decreased
(
heap_t
heap
,
unsigned
int
i
)
{
isc_
heap_decreased
(
isc_
heap_t
heap
,
unsigned
int
i
)
{
REQUIRE
(
VALID_HEAP
(
heap
));
REQUIRE
(
i
>=
1
&&
i
<=
heap
->
last
);
...
...
@@ -209,7 +208,7 @@ heap_decreased(heap_t heap, unsigned int i) {
}
void
*
heap_element
(
heap_t
heap
,
unsigned
int
i
)
{
isc_
heap_element
(
isc_
heap_t
heap
,
unsigned
int
i
)
{
REQUIRE
(
VALID_HEAP
(
heap
));
REQUIRE
(
i
>=
1
&&
i
<=
heap
->
last
);
...
...
@@ -217,7 +216,7 @@ heap_element(heap_t heap, unsigned int i) {
}
void
heap_for
_
each
(
heap_t
heap
,
heap_for_each_func
action
,
void
*
uap
)
{
isc_
heap_foreach
(
isc_
heap_t
heap
,
isc_heapaction_t
action
,
void
*
uap
)
{
unsigned
int
i
;
REQUIRE
(
VALID_HEAP
(
heap
));
...
...
lib/isc/include/isc/boolean.h
View file @
f47bb8d1
#ifndef BOOLEAN_H
#define BOOLEAN_H 1
#ifndef
ISC_
BOOLEAN_H
#define
ISC_
BOOLEAN_H 1
#ifndef SOLARIS
typedef
enum
{
isc_boolean_false
=
0
,
isc_boolean_true
=
1
}
isc_boolean_t
;
#ifndef TRUE
#define TRUE 1
#endif
#define ISC_FALSE isc_boolean_false
#define ISC_TRUE isc_boolean_true
#ifndef FALSE
#define FALSE 0
#endif
typedef
enum
{
false
=
FALSE
,
true
=
TRUE
}
boolean_t
;
#else
#define true B_TRUE
#define false B_FALSE
#endif
#endif
/* BOOLEAN_H */
#endif
/* ISC_BOOLEAN_H */
lib/isc/include/isc/event.h
View file @
f47bb8d1
...
...
@@ -19,7 +19,7 @@
#define EVENT_CLASS_TASK EVENT_CLASS(0)
#define EVENT_CLASS_TIMER EVENT_CLASS(1)
#define EVENT_CLASS_
N
ET
EVENT_CLASS(2)
#define EVENT_CLASS_
SOCK
ET EVENT_CLASS(2)
#define EVENT_CLASS_FILE EVENT_CLASS(3)
/*
...
...
lib/isc/include/isc/heap.h
View file @
f47bb8d1
...
...
@@ -19,27 +19,32 @@
#include <isc/boolean.h>
#include <isc/memcluster.h>
typedef
boolean_t
(
*
heap_higher_priority_func
)(
void
*
,
void
*
);
typedef
void
(
*
heap_index_func
)(
void
*
,
unsigned
int
);
typedef
void
(
*
heap_for_each_func
)(
void
*
,
void
*
);
/*
* The comparision function returns ISC_TRUE if the first argument has
* higher priority than the second argument, and ISC_FALSE otherwise.
*/
typedef
isc_boolean_t
(
*
isc_heapcompare_t
)(
void
*
,
void
*
);
typedef
void
(
*
isc_heapindex_t
)(
void
*
,
unsigned
int
);
typedef
void
(
*
isc_heapaction_t
)(
void
*
,
void
*
);
typedef
struct
heap_context
*
heap_t
;
typedef
struct
isc_heap
*
isc_
heap_t
;
#define heap_create
_
_heap_create
#define heap_destroy __heap_destroy
#define heap_insert
_
_heap_insert
#define heap_delete
_
_heap_delete
#define heap_increased __heap_increased
#define heap_decreased __heap_decreased
#define heap_element __heap_element
#define heap_for
_
each __heap_for
_
each
#define
isc_
heap_create
__isc
_heap_create
#define
isc_
heap_destroy __
isc_
heap_destroy
#define
isc_
heap_insert
__isc
_heap_insert
#define
isc_
heap_delete
__isc
_heap_delete
#define
isc_
heap_increased __
isc_
heap_increased
#define
isc_
heap_decreased __
isc_
heap_decreased
#define
isc_
heap_element __
isc_
heap_element
#define
isc_
heap_foreach __
isc_
heap_foreach
isc_result
heap_create
(
mem_context_t
,
heap_higher_priority_func
,
heap
_
index_
func
,
unsigned
int
,
heap_t
*
);
void
heap_destroy
(
heap_t
*
);
isc_result
heap_insert
(
heap_t
,
void
*
);
void
heap_delete
(
heap_t
,
unsigned
int
);
void
heap_increased
(
heap_t
,
unsigned
int
);
void
heap_decreased
(
heap_t
,
unsigned
int
);
void
*
heap_element
(
heap_t
,
unsigned
int
);
void
heap_for
_
each
(
heap_t
,
heap_for_each_func
,
void
*
);
isc_result
isc_
heap_create
(
mem_context_t
,
isc_heapcompare_t
,
isc_
heapindex_
t
,
unsigned
int
,
isc_
heap_t
*
);
void
isc_
heap_destroy
(
isc_
heap_t
*
);
isc_result
isc_
heap_insert
(
isc_
heap_t
,
void
*
);
void
isc_
heap_delete
(
isc_
heap_t
,
unsigned
int
);
void
isc_
heap_increased
(
isc_
heap_t
,
unsigned
int
);
void
isc_
heap_decreased
(
isc_
heap_t
,
unsigned
int
);
void
*
isc_
heap_element
(
isc_
heap_t
,
unsigned
int
);
void
isc_
heap_foreach
(
isc_
heap_t
,
isc_heapaction_t
,
void
*
);
lib/isc/include/isc/task.h
View file @
f47bb8d1
...
...
@@ -30,7 +30,7 @@ typedef struct task_manager * task_manager_t;
*/
typedef
int
task_eventtype_t
;
typedef
boolean_t
(
*
task_action_t
)(
task_t
,
task_event_t
);
typedef
isc_
boolean_t
(
*
task_action_t
)(
task_t
,
task_event_t
);
/*
* This structure is public because "subclassing" it may be useful when
...
...
@@ -64,14 +64,14 @@ void task_event_free(task_event_t *);
*** Tasks.
***/
boolean_t
task_create
(
task_manager_t
,
isc_
boolean_t
task_create
(
task_manager_t
,
task_action_t
,
void
*
,
unsigned
int
,
task_t
*
);
void
task_attach
(
task_t
,
task_t
*
);
void
task_detach
(
task_t
*
);
boolean_t
task_send_event
(
task_t
,
isc_
boolean_t
task_send_event
(
task_t
,
task_event_t
*
);
void
task_purge_events
(
task_t
,
void
*
,
task_eventtype_t
);
...
...
lib/isc/include/isc/timer.h
View file @
f47bb8d1
...
...
@@ -148,7 +148,7 @@ timer_reset(timer_t timer,
timer_type_t
type
,
os_time_t
expires
,
os_time_t
interval
,
boolean_t
purge
);
isc_
boolean_t
purge
);
/*
* Change the timer's type, expires, and interval values to the given
* values. If 'purge' is TRUE, any pending events from this timer
...
...
lib/isc/pthreads/condition.c
View file @
f47bb8d1
...
...
@@ -2,9 +2,9 @@
#include <isc/condition.h>
#include <errno.h>
boolean_t
isc_
boolean_t
os_condition_waituntil
(
os_condition_t
*
c
,
os_mutex_t
*
m
,
os_time_t
*
t
,
boolean_t
*
timeout
)
isc_
boolean_t
*
timeout
)
{
int
result
;
struct
timespec
ts
;
...
...
@@ -13,11 +13,11 @@ os_condition_waituntil(os_condition_t *c, os_mutex_t *m, os_time_t *t,
ts
.
tv_nsec
=
t
->
nanoseconds
;
result
=
pthread_cond_timedwait
(
c
,
m
,
&
ts
);
if
(
result
==
0
)
{
*
timeout
=
FALSE
;
return
(
TRUE
);
*
timeout
=
ISC_
FALSE
;
return
(
ISC_
TRUE
);
}
else
if
(
result
==
ETIMEDOUT
)
{
*
timeout
=
TRUE
;
return
(
TRUE
);
*
timeout
=
ISC_
TRUE
;
return
(
ISC_
TRUE
);
}
return
(
FALSE
);
return
(
ISC_
FALSE
);
}
lib/isc/pthreads/include/isc/condition.h
View file @
f47bb8d1
...
...
@@ -17,9 +17,9 @@ typedef pthread_cond_t os_condition_t;
#define os_condition_broadcast(cp) (pthread_cond_broadcast((cp)) == 0)
#define os_condition_destroy(cp) (pthread_cond_destroy((cp)) == 0)
boolean_t
os_condition_waituntil
(
os_condition_t
*
,
isc_
boolean_t
os_condition_waituntil
(
os_condition_t
*
,
os_mutex_t
*
,
os_time_t
*
,
boolean_t
*
);
isc_
boolean_t
*
);
#endif
/* CONDITION_H */
lib/isc/task.c
View file @
f47bb8d1
...
...
@@ -57,7 +57,7 @@ struct task {
unsigned
int
references
;
task_eventlist_t
events
;
unsigned
int
quantum
;
boolean_t
enqueue_allowed
;
isc_
boolean_t
enqueue_allowed
;
task_event_t
shutdown_event
;
/* Locked by task manager lock. */
LINK
(
struct
task
)
link
;
...
...
@@ -78,7 +78,7 @@ struct task_manager {
LIST
(
struct
task
)
tasks
;
LIST
(
struct
task
)
ready_tasks
;
os_condition_t
work_available
;
boolean_t
exiting
;
isc_
boolean_t
exiting
;
unsigned
int
workers
;
os_condition_t
no_workers
;
};
...
...
@@ -167,7 +167,7 @@ task_free(task_t task) {
mem_put
(
manager
->
mctx
,
task
,
sizeof
*
task
);
}
boolean_t
isc_
boolean_t
task_create
(
task_manager_t
manager
,
task_action_t
shutdown_action
,
void
*
shutdown_arg
,
unsigned
int
quantum
,
task_t
*
taskp
)
{
...
...
@@ -178,19 +178,19 @@ task_create(task_manager_t manager, task_action_t shutdown_action,
task
=
mem_get
(
manager
->
mctx
,
sizeof
*
task
);
if
(
task
==
NULL
)
return
(
FALSE
);
return
(
ISC_
FALSE
);
task
->
magic
=
TASK_MAGIC
;
task
->
manager
=
manager
;
if
(
!
os_mutex_init
(
&
task
->
lock
))
{
mem_put
(
manager
->
mctx
,
task
,
sizeof
*
task
);
return
(
FALSE
);
return
(
ISC_
FALSE
);
}
task
->
state
=
task_state_idle
;
task
->
references
=
1
;
INIT_LIST
(
task
->
events
);
task
->
quantum
=
quantum
;
task
->
enqueue_allowed
=
TRUE
;
task
->
enqueue_allowed
=
ISC_
TRUE
;
task
->
shutdown_event
=
event_allocate
(
manager
->
mctx
,
NULL
,
TASK_EVENT_SHUTDOWN
,
...
...
@@ -200,7 +200,7 @@ task_create(task_manager_t manager, task_action_t shutdown_action,
if
(
task
->
shutdown_event
==
NULL
)
{
(
void
)
os_mutex_destroy
(
&
task
->
lock
);
mem_put
(
manager
->
mctx
,
task
,
sizeof
*
task
);
return
(
FALSE
);
return
(
ISC_
FALSE
);
}
INIT_LINK
(
task
,
link
);
INIT_LINK
(
task
,
ready_link
);
...
...
@@ -213,7 +213,7 @@ task_create(task_manager_t manager, task_action_t shutdown_action,
*
taskp
=
task
;
return
(
TRUE
);
return
(
ISC_
TRUE
);
}
void
...
...
@@ -231,7 +231,7 @@ task_attach(task_t task, task_t *taskp) {
void
task_detach
(
task_t
*
taskp
)
{
boolean_t
free_task
=
FALSE
;
isc_
boolean_t
free_task
=
ISC_
FALSE
;
task_t
task
;
XTRACE
(
"task_detach"
);
...
...
@@ -244,7 +244,7 @@ task_detach(task_t *taskp) {
REQUIRE
(
task
->
references
>
0
);
task
->
references
--
;
if
(
task
->
state
==
task_state_shutdown
&&
task
->
references
==
0
)
free_task
=
TRUE
;
free_task
=
ISC_
TRUE
;
UNLOCK
(
&
task
->
lock
);
if
(
free_task
)
...
...
@@ -253,10 +253,10 @@ task_detach(task_t *taskp) {
*
taskp
=
NULL
;
}
boolean_t
isc_
boolean_t
task_send_event
(
task_t
task
,
task_event_t
*
eventp
)
{
boolean_t
was_idle
=
FALSE
;
boolean_t
discard
=
FALSE
;
isc_
boolean_t
was_idle
=
ISC_
FALSE
;
isc_
boolean_t
discard
=
ISC_
FALSE
;
task_event_t
event
;
REQUIRE
(
VALID_TASK
(
task
));
...
...
@@ -275,7 +275,7 @@ task_send_event(task_t task, task_event_t *eventp) {
LOCK
(
&
task
->
lock
);
if
(
task
->
enqueue_allowed
)
{
if
(
task
->
state
==
task_state_idle
)
{
was_idle
=
TRUE
;
was_idle
=
ISC_
TRUE
;
INSIST
(
EMPTY
(
task
->
events
));
task
->
state
=
task_state_ready
;
}
...
...
@@ -283,17 +283,17 @@ task_send_event(task_t task, task_event_t *eventp) {
task
->
state
==
task_state_running
);
ENQUEUE
(
task
->
events
,
event
,
link
);
}
else
discard
=
TRUE
;
discard
=
ISC_
TRUE
;
UNLOCK
(
&
task
->
lock
);
if
(
discard
)
{
task_event_free
(
&
event
);
*
eventp
=
NULL
;
return
(
TRUE
);
return
(
ISC_
TRUE
);
}
if
(
was_idle
)
{
boolean_t
need_wakeup
=
FALSE
;
isc_
boolean_t
need_wakeup
=
ISC_
FALSE
;
task_manager_t
manager
;
/*
...
...
@@ -319,7 +319,7 @@ task_send_event(task_t task, task_event_t *eventp) {
INSIST
(
VALID_MANAGER
(
manager
));
LOCK
(
&
manager
->
lock
);
if
(
EMPTY
(
manager
->
ready_tasks
))
need_wakeup
=
TRUE
;
need_wakeup
=
ISC_
TRUE
;
ENQUEUE
(
manager
->
ready_tasks
,
task
,
ready_link
);
UNLOCK
(
&
manager
->
lock
);
...
...
@@ -335,7 +335,7 @@ task_send_event(task_t task, task_event_t *eventp) {
*
eventp
=
NULL
;
XTRACE
(
"sent"
);
return
(
TRUE
);
return
(
ISC_
TRUE
);
}
void
...
...
@@ -377,8 +377,8 @@ task_purge_events(task_t task, void *sender, task_eventtype_t type) {
void
task_shutdown
(
task_t
task
)
{
boolean_t
was_idle
=
FALSE
;
boolean_t
discard
=
FALSE
;
isc_
boolean_t
was_idle
=
ISC_
FALSE
;
isc_
boolean_t
discard
=
ISC_
FALSE
;
REQUIRE
(
VALID_TASK
(
task
));
...
...
@@ -389,7 +389,7 @@ task_shutdown(task_t task) {
LOCK
(
&
task
->
lock
);
if
(
task
->
enqueue_allowed
)
{
if
(
task
->
state
==
task_state_idle
)
{
was_idle
=
TRUE
;
was_idle
=
ISC_
TRUE
;
INSIST
(
EMPTY
(
task
->
events
));
task
->
state
=
task_state_ready
;
}
...
...
@@ -398,23 +398,23 @@ task_shutdown(task_t task) {
INSIST
(
task
->
shutdown_event
!=
NULL
);
ENQUEUE
(
task
->
events
,
task
->
shutdown_event
,
link
);
task
->
shutdown_event
=
NULL
;
task
->
enqueue_allowed
=
FALSE
;
task
->
enqueue_allowed
=
ISC_
FALSE
;
}
else
discard
=
TRUE
;
discard
=
ISC_
TRUE
;
UNLOCK
(
&
task
->
lock
);
if
(
discard
)
return
;
if
(
was_idle
)
{
boolean_t
need_wakeup
=
FALSE
;
isc_
boolean_t
need_wakeup
=
ISC_
FALSE
;
task_manager_t
manager
;
manager
=
task
->
manager
;
INSIST
(
VALID_MANAGER
(
manager
));
LOCK
(
&
manager
->
lock
);
if
(
EMPTY
(
manager
->
ready_tasks
))
need_wakeup
=
TRUE
;
need_wakeup
=
ISC_
TRUE
;
ENQUEUE
(
manager
->
ready_tasks
,
task
,
ready_link
);
UNLOCK
(
&
manager
->
lock
);
...
...
@@ -442,7 +442,7 @@ static
void
*
task_manager_run
(
void
*
uap
)
{
task_manager_t
manager
=
uap
;
task_t
task
;
boolean_t
no_workers
=
FALSE
;
isc_
boolean_t
no_workers
=
ISC_
FALSE
;
XTRACE
(
"start"
);
...
...
@@ -517,14 +517,14 @@ void *task_manager_run(void *uap) {
task
=
HEAD
(
manager
->
ready_tasks
);
if
(
task
!=
NULL
)
{
unsigned
int
dispatch_count
=
0
;
boolean_t
done
=
FALSE
;