示例#1
0
isc_result_t dhcp_control_set_value  (omapi_object_t *h,
				      omapi_object_t *id,
				      omapi_data_string_t *name,
				      omapi_typed_data_t *value)
{
	dhcp_control_object_t *control;
	isc_result_t status;
	int foo;
	unsigned long newstate;

	if (h -> type != dhcp_type_control)
		return ISC_R_INVALIDARG;
	control = (dhcp_control_object_t *)h;

	if (!omapi_ds_strcmp (name, "state")) {
		status = omapi_get_int_value (&newstate, value);
		if (status != ISC_R_SUCCESS)
			return status;
		status = dhcp_set_control_state (control -> state, newstate);
		if (status == ISC_R_SUCCESS)
			control -> state = value -> u.integer;
		return status;
	}

	/* Try to find some inner object that can take the value. */
	if (h -> inner && h -> inner -> type -> set_value) {
		status = ((*(h -> inner -> type -> set_value))
			  (h -> inner, id, name, value));
		if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED)
			return status;
	}
			  
	return ISC_R_NOTFOUND;
}
void
dispatch(void)
{
	isc_result_t status;

	do {
		status = isc_app_ctxrun(dhcp_gbl_ctx.actx);

		/*
		 * isc_app_ctxrun can be stopped by receiving a
		 * signal. It will return ISC_R_RELOAD in that
		 * case. That is a normal behavior.
		 */

		if (status == ISC_R_RELOAD) {
			/*
			 * dhcp_set_control_state() will do the job.
			 * Note its first argument is ignored.
			 */
			status = dhcp_set_control_state(server_shutdown,
							server_shutdown);
			if (status == ISC_R_SUCCESS)
				status = ISC_R_RELOAD;
		}
	} while (status == ISC_R_RELOAD);

	log_fatal ("Dispatch routine failed: %s -- exiting",
		   isc_result_totext (status));
}