mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-09-02 07:15:44 +00:00
- Fix up reference counting of io object chain.
- Add omapi_unregister_io_object.
This commit is contained in:
@@ -97,9 +97,12 @@ isc_result_t omapi_register_io_object (omapi_object_t *h,
|
|||||||
p && p -> next; p = p -> next)
|
p && p -> next; p = p -> next)
|
||||||
;
|
;
|
||||||
if (p)
|
if (p)
|
||||||
p -> next = obj;
|
omapi_object_reference ((omapi_object_t **)&p -> next,
|
||||||
|
(omapi_object_t *)obj, MDL);
|
||||||
else
|
else
|
||||||
omapi_io_states.next = obj;
|
omapi_object_reference
|
||||||
|
((omapi_object_t **)&omapi_io_states.next,
|
||||||
|
(omapi_object_t *)obj, MDL);
|
||||||
|
|
||||||
obj -> readfd = readfd;
|
obj -> readfd = readfd;
|
||||||
obj -> writefd = writefd;
|
obj -> writefd = writefd;
|
||||||
@@ -109,6 +112,43 @@ isc_result_t omapi_register_io_object (omapi_object_t *h,
|
|||||||
return ISC_R_SUCCESS;
|
return ISC_R_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isc_result_t omapi_unregister_io_object (omapi_object_t *h)
|
||||||
|
{
|
||||||
|
omapi_io_object_t *p, *obj, *last;
|
||||||
|
omapi_object_t *ph;
|
||||||
|
|
||||||
|
obj = (omapi_io_object_t *)h -> outer;
|
||||||
|
ph = (omapi_object_t *)0;
|
||||||
|
omapi_object_reference (&ph, h -> outer, MDL);
|
||||||
|
|
||||||
|
/* remove from the list of I/O states */
|
||||||
|
for (p = omapi_io_states.next; p; p = p -> next) {
|
||||||
|
if ((omapi_object_t *)p == h -> outer) {
|
||||||
|
omapi_object_dereference ((omapi_object_t **)
|
||||||
|
&last -> next, MDL);
|
||||||
|
omapi_object_reference ((omapi_object_t **)
|
||||||
|
&last -> next,
|
||||||
|
(omapi_object_t *)p -> next,
|
||||||
|
MDL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
last = p;
|
||||||
|
}
|
||||||
|
if (obj -> next)
|
||||||
|
omapi_object_dereference ((omapi_object_t **)&obj -> next,
|
||||||
|
MDL);
|
||||||
|
if (obj -> outer) {
|
||||||
|
if (obj -> outer -> inner == (omapi_object_t *)obj)
|
||||||
|
omapi_object_dereference (&obj -> outer -> inner,
|
||||||
|
MDL);
|
||||||
|
omapi_object_dereference (&obj -> outer, MDL);
|
||||||
|
}
|
||||||
|
omapi_object_dereference (&obj -> inner, MDL);
|
||||||
|
omapi_object_dereference (&h -> outer, MDL);
|
||||||
|
omapi_object_dereference (&ph, MDL);
|
||||||
|
return ISC_R_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
isc_result_t omapi_dispatch (struct timeval *t)
|
isc_result_t omapi_dispatch (struct timeval *t)
|
||||||
{
|
{
|
||||||
return omapi_wait_for_completion ((omapi_object_t *)&omapi_io_states,
|
return omapi_wait_for_completion ((omapi_object_t *)&omapi_io_states,
|
||||||
@@ -189,6 +229,7 @@ isc_result_t omapi_one_dispatch (omapi_object_t *wo,
|
|||||||
omapi_io_object_t *io, *prev;
|
omapi_io_object_t *io, *prev;
|
||||||
isc_result_t status;
|
isc_result_t status;
|
||||||
omapi_waiter_object_t *waiter;
|
omapi_waiter_object_t *waiter;
|
||||||
|
omapi_object_t *tmp = (omapi_object_t *)0;
|
||||||
|
|
||||||
if (!wo || wo -> type != omapi_type_waiter)
|
if (!wo || wo -> type != omapi_type_waiter)
|
||||||
waiter = (omapi_waiter_object_t *)0;
|
waiter = (omapi_waiter_object_t *)0;
|
||||||
@@ -260,23 +301,25 @@ isc_result_t omapi_one_dispatch (omapi_object_t *wo,
|
|||||||
return ISC_R_UNEXPECTED;
|
return ISC_R_UNEXPECTED;
|
||||||
|
|
||||||
for (io = omapi_io_states.next; io; io = io -> next) {
|
for (io = omapi_io_states.next; io; io = io -> next) {
|
||||||
|
omapi_object_reference (&tmp, io -> inner, MDL);
|
||||||
/* Check for a read descriptor, and if there is one,
|
/* Check for a read descriptor, and if there is one,
|
||||||
see if we got input on that socket. */
|
see if we got input on that socket. */
|
||||||
if (io -> readfd &&
|
if (io -> readfd &&
|
||||||
(desc = (*(io -> readfd)) (io -> inner)) >= 0) {
|
(desc = (*(io -> readfd)) (tmp)) >= 0) {
|
||||||
if (FD_ISSET (desc, &r))
|
if (FD_ISSET (desc, &r))
|
||||||
status = ((*(io -> reader)) (io -> inner));
|
status = ((*(io -> reader)) (tmp));
|
||||||
/* XXX what to do with status? */
|
/* XXX what to do with status? */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Same deal for write descriptors. */
|
/* Same deal for write descriptors. */
|
||||||
if (io -> writefd &&
|
if (io -> writefd &&
|
||||||
(desc = (*(io -> writefd)) (io -> inner)) >= 0)
|
(desc = (*(io -> writefd)) (tmp)) >= 0)
|
||||||
{
|
{
|
||||||
if (FD_ISSET (desc, &w))
|
if (FD_ISSET (desc, &w))
|
||||||
status = ((*(io -> writer)) (io -> inner));
|
status = ((*(io -> writer)) (tmp));
|
||||||
/* XXX what to do with status? */
|
/* XXX what to do with status? */
|
||||||
}
|
}
|
||||||
|
omapi_object_dereference (&tmp, MDL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now check for I/O handles that are no longer valid,
|
/* Now check for I/O handles that are no longer valid,
|
||||||
@@ -370,22 +413,21 @@ isc_result_t omapi_io_destroy (omapi_object_t *h, const char *file, int line)
|
|||||||
|
|
||||||
obj = (omapi_io_object_t *)h;
|
obj = (omapi_io_object_t *)h;
|
||||||
|
|
||||||
/* only ios for interface objects? */
|
|
||||||
if (strcmp (obj -> inner -> type ->name, "interface") == 0) {
|
|
||||||
/* remove from the list of I/O states */
|
/* remove from the list of I/O states */
|
||||||
for (p = omapi_io_states.next; p; p = p -> next) {
|
for (p = omapi_io_states.next; p; p = p -> next) {
|
||||||
if (p == obj) {
|
if (p == obj) {
|
||||||
last -> next = p -> next;
|
omapi_object_dereference ((omapi_object_t **)
|
||||||
|
&last -> next, MDL);
|
||||||
|
omapi_object_reference ((omapi_object_t **)
|
||||||
|
&last -> next,
|
||||||
|
(omapi_object_t *)p -> next,
|
||||||
|
MDL);
|
||||||
|
omapi_object_dereference ((omapi_object_t **)&p, MDL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
last = p;
|
last = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* omapi_object_dereference ((omapi_object_t **)&obj, MDL);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
return ISC_R_SUCCESS;
|
return ISC_R_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user