dhcpctl timeout feature
Mark Dominus
mjd at isc.upenn.edu
Fri Feb 6 18:48:58 UTC 2004
The 'timeout' (asynchronous operation) feature of dhcpctl appears not
to work at all. The enclosed patch makes it work at least somewhat.
There are two essential changes here.
First, in the dhcpctl_set_callback function, we need to allocate a
properly-initialized dhcpctl_callback object, and not just a buffer of
the right size.
Second, in the distributed versions of the software, the presence of a
dhcpctl callback would intercept the signal from the OMAPI library,
preventing this signal from reaching other handlers in the same
object. The patch makes the dhcpctl_callback_signal_handler propagate
the signal to the subobject, whether or not there is a dhcpctl
callback installed.
Comments and questions are welcome.
--- /tmp/T0fCaOKS Fri Feb 6 13:41:28 2004
+++ dhcpctl/callback.c Fri Feb 6 13:03:11 2004
@@ -65,8 +65,10 @@
omapi_object_t *inner;
isc_result_t status;
- callback = dmalloc (sizeof *callback, MDL);
- if (!callback)
+ /* MJD 20040205 */
+ status = omapi_object_allocate((omapi_object_t **)&callback,
+ dhcpctl_callback_type, 0, MDL);
+ if (status != ISC_R_SUCCESS || !callback)
return ISC_R_NOMEMORY;
/* Tie the callback object to the innermost object in the chain. */
@@ -119,7 +121,7 @@
const char *name, va_list ap)
{
dhcpctl_callback_object_t *p;
- isc_result_t waitstatus;
+ isc_result_t waitstatus, result = ISC_R_NOTFOUND;
if (o -> type != dhcpctl_callback_type)
return ISC_R_INVALIDARG;
@@ -126,24 +128,25 @@
p = (dhcpctl_callback_object_t *)o;
/* Not a signal we recognize? */
- if (strcmp (name, "ready")) {
- if (p -> inner && p -> inner -> type -> signal_handler)
- return (*(p -> inner -> type -> signal_handler))
- (p -> inner, name, ap);
- return ISC_R_NOTFOUND;
+ if (strcmp (name, "ready") == 0) {
+ if (p -> object -> type == dhcpctl_remote_type) {
+ waitstatus = (((dhcpctl_remote_object_t *)
+ (p -> object)) -> waitstatus);
+ } else
+ waitstatus = ISC_R_SUCCESS;
+
+ /* Do the callback. */
+ if (p -> callback)
+ (*(p -> callback)) (p -> object, waitstatus, p -> data);
+ result = ISC_R_SUCCESS;
}
- if (p -> object -> type == dhcpctl_remote_type) {
- waitstatus = (((dhcpctl_remote_object_t *)
- (p -> object)) -> waitstatus);
- } else
- waitstatus = ISC_R_SUCCESS;
+ /* Now invoke the callback for the sub-object, if there is one. */
+ if (p -> inner && p -> inner -> type -> signal_handler)
+ return (*(p -> inner -> type -> signal_handler))
+ (p -> inner, name, ap);
- /* Do the callback. */
- if (p -> callback)
- (*(p -> callback)) (p -> object, waitstatus, p -> data);
-
- return ISC_R_SUCCESS;
+ return result;
}
isc_result_t dhcpctl_callback_destroy (omapi_object_t *h,
More information about the dhcp-hackers
mailing list