⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dispatch.c

📁 DHCP服务器源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	/* We probably have a bad file descriptor.   Figure out which one.	   When we find it, call the reaper function on it, which will	   maybe make it go away, and then try again. */	if (count < 0) {		struct timeval t0;		omapi_io_object_t *prev = (omapi_io_object_t *)0;		io = (omapi_io_object_t *)0;		if (omapi_io_states.next)			omapi_io_reference (&io, omapi_io_states.next, MDL);		while (io) {			omapi_object_t *obj;			FD_ZERO (&r);			FD_ZERO (&w);			t0.tv_sec = t0.tv_usec = 0;			if (io -> readfd && io -> inner &&			    (desc = (*(io -> readfd)) (io -> inner)) >= 0) {			    FD_SET (desc, &r);#if 0			    log_error ("read check: %d %lx %lx", max,				       (unsigned long)r.fds_bits [0],				       (unsigned long)w.fds_bits [0]);#endif			    count = select (desc + 1, &r, &w, &x, &t0);			   bogon:			    if (count < 0) {				log_error ("Bad descriptor %d.", desc);				for (obj = (omapi_object_t *)io;				     obj -> outer;				     obj = obj -> outer)					;				for (; obj; obj = obj -> inner) {				    omapi_value_t *ov;				    int len;				    const char *s;				    ov = (omapi_value_t *)0;				    omapi_get_value_str (obj,							 (omapi_object_t *)0,							 "name", &ov);				    if (ov && ov -> value &&					(ov -> value -> type ==					 omapi_datatype_string)) {					s = (char *)						ov -> value -> u.buffer.value;					len = ov -> value -> u.buffer.len;				    } else {					s = "";					len = 0;				    }				    log_error ("Object %lx %s%s%.*s",					       (unsigned long)obj,					       obj -> type -> name,					       len ? " " : "",					       len, s);				    if (len)					omapi_value_dereference (&ov, MDL);				}				status = (*(io -> reaper)) (io -> inner);				if (prev) {				    omapi_io_dereference (&prev -> next, MDL);				    if (io -> next)					omapi_io_reference (&prev -> next,							    io -> next, MDL);				} else {				    omapi_io_dereference					    (&omapi_io_states.next, MDL);				    if (io -> next)					omapi_io_reference						(&omapi_io_states.next,						 io -> next, MDL);				}				omapi_io_dereference (&io, MDL);				goto again;			    }			}						FD_ZERO (&r);			FD_ZERO (&w);			t0.tv_sec = t0.tv_usec = 0;			/* Same deal for write fdets. */			if (io -> writefd && io -> inner &&			    (desc = (*(io -> writefd)) (io -> inner)) >= 0) {				FD_SET (desc, &w);				count = select (desc + 1, &r, &w, &x, &t0);				if (count < 0)					goto bogon;			}			if (prev)				omapi_io_dereference (&prev, MDL);			omapi_io_reference (&prev, io, MDL);			omapi_io_dereference (&io, MDL);			if (prev -> next)			    omapi_io_reference (&io, prev -> next, MDL);		}		if (prev)			omapi_io_dereference (&prev, MDL);			}	for (io = omapi_io_states.next; io; io = io -> next) {		if (!io -> inner)			continue;		omapi_object_reference (&tmp, io -> inner, MDL);		/* Check for a read descriptor, and if there is one,		   see if we got input on that socket. */		if (io -> readfd &&		    (desc = (*(io -> readfd)) (tmp)) >= 0) {			if (FD_ISSET (desc, &r))				status = ((*(io -> reader)) (tmp));				/* XXX what to do with status? */		}				/* Same deal for write descriptors. */		if (io -> writefd &&		    (desc = (*(io -> writefd)) (tmp)) >= 0)		{			if (FD_ISSET (desc, &w))				status = ((*(io -> writer)) (tmp));				/* XXX what to do with status? */		}		omapi_object_dereference (&tmp, MDL);	}	/* Now check for I/O handles that are no longer valid,	   and remove them from the list. */	prev = (omapi_io_object_t *)0;	for (io = omapi_io_states.next; io; io = io -> next) {		if (io -> reaper) {			if (io -> inner)				status = (*(io -> reaper)) (io -> inner);			if (!io -> inner || status != ISC_R_SUCCESS) {				omapi_io_object_t *tmp =					(omapi_io_object_t *)0;				/* Save a reference to the next				   pointer, if there is one. */				if (io -> next)					omapi_io_reference (&tmp,							    io -> next, MDL);				if (prev) {					omapi_io_dereference (&prev -> next,							      MDL);					if (tmp)						omapi_io_reference							(&prev -> next,							 tmp, MDL);				} else {					omapi_io_dereference						(&omapi_io_states.next, MDL);					if (tmp)						omapi_io_reference						    (&omapi_io_states.next,						     tmp, MDL);					else						omapi_signal_in							((omapi_object_t *)							 &omapi_io_states,							 "ready");				}				if (tmp)					omapi_io_dereference (&tmp, MDL);			}		}		prev = io;	}	return ISC_R_SUCCESS;}isc_result_t omapi_io_set_value (omapi_object_t *h,				 omapi_object_t *id,				 omapi_data_string_t *name,				 omapi_typed_data_t *value){	if (h -> type != omapi_type_io_object)		return ISC_R_INVALIDARG;		if (h -> inner && h -> inner -> type -> set_value)		return (*(h -> inner -> type -> set_value))			(h -> inner, id, name, value);	return ISC_R_NOTFOUND;}isc_result_t omapi_io_get_value (omapi_object_t *h,				 omapi_object_t *id,				 omapi_data_string_t *name,				 omapi_value_t **value){	if (h -> type != omapi_type_io_object)		return ISC_R_INVALIDARG;		if (h -> inner && h -> inner -> type -> get_value)		return (*(h -> inner -> type -> get_value))			(h -> inner, id, name, value);	return ISC_R_NOTFOUND;}isc_result_t omapi_io_destroy (omapi_object_t *h, const char *file, int line){	omapi_io_object_t *obj, *p, *last;	if (h -> type != omapi_type_io_object)		return ISC_R_INVALIDARG;		obj = (omapi_io_object_t *)h;	/* remove from the list of I/O states */	for (p = omapi_io_states.next; p; p = p -> next) {		if (p == obj) {			omapi_io_dereference (&last -> next, MDL);			omapi_io_reference (&last -> next, p -> next, MDL);			omapi_io_dereference (&p, MDL);			break;		}		last = p;	}			return ISC_R_SUCCESS;}isc_result_t omapi_io_signal_handler (omapi_object_t *h,				      const char *name, va_list ap){	if (h -> type != omapi_type_io_object)		return ISC_R_INVALIDARG;		if (h -> inner && h -> inner -> type -> signal_handler)		return (*(h -> inner -> type -> signal_handler)) (h -> inner,								  name, ap);	return ISC_R_NOTFOUND;}isc_result_t omapi_io_stuff_values (omapi_object_t *c,				    omapi_object_t *id,				    omapi_object_t *i){	if (i -> type != omapi_type_io_object)		return ISC_R_INVALIDARG;	if (i -> inner && i -> inner -> type -> stuff_values)		return (*(i -> inner -> type -> stuff_values)) (c, id,								i -> inner);	return ISC_R_SUCCESS;}isc_result_t omapi_waiter_signal_handler (omapi_object_t *h,					  const char *name, va_list ap){	omapi_waiter_object_t *waiter;	if (h -> type != omapi_type_waiter)		return ISC_R_INVALIDARG;		if (!strcmp (name, "ready")) {		waiter = (omapi_waiter_object_t *)h;		waiter -> ready = 1;		waiter -> waitstatus = ISC_R_SUCCESS;		return ISC_R_SUCCESS;	}	if (!strcmp (name, "status")) {		waiter = (omapi_waiter_object_t *)h;		waiter -> ready = 1;		waiter -> waitstatus = va_arg (ap, isc_result_t);		return ISC_R_SUCCESS;	}	if (!strcmp (name, "disconnect")) {		waiter = (omapi_waiter_object_t *)h;		waiter -> ready = 1;		waiter -> waitstatus = ISC_R_CONNRESET;		return ISC_R_SUCCESS;	}	if (h -> inner && h -> inner -> type -> signal_handler)		return (*(h -> inner -> type -> signal_handler)) (h -> inner,								  name, ap);	return ISC_R_NOTFOUND;}isc_result_t omapi_io_state_foreach (isc_result_t (*func) (omapi_object_t *,							   void *),				     void *p){	omapi_io_object_t *io;	isc_result_t status;	for (io = omapi_io_states.next; io; io = io -> next) {		if (io -> inner) {			status = (*func) (io -> inner, p);			if (status != ISC_R_SUCCESS)				return status;		}	}	return ISC_R_SUCCESS;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -