log_error("realloc");
event_warn("realloc");
poll_dispatch(void *arg, struct timeval *tv){	int res, i, count, sec, nfds;	struct event *ev;	struct pollop *pop = arg;	count = pop->event_count;	nfds = 0;	TAILQ_FOREACH(ev, &eventqueue, ev_next) {		if (nfds + 1 >= count) {			if (count < 32)				count = 32;			else				count *= 2;			/* We need more file descriptors */			pop->event_set = realloc(pop->event_set,			    count * sizeof(struct pollfd));			if (pop->event_set == NULL) {				log_error("realloc");				return (-1);			}			pop->event_back = realloc(pop->event_back,			    count * sizeof(struct event *));			if (pop->event_back == NULL) {				log_error("realloc");				return (-1);			}			pop->event_count = count;		}		if (ev->ev_events & EV_WRITE) {			struct pollfd *pfd = &pop->event_set[nfds];			pfd->fd = ev->ev_fd;			pfd->events = POLLOUT;			pfd->revents = 0;			pop->event_back[nfds] = ev;			nfds++;		}		if (ev->ev_events & EV_READ) {			struct pollfd *pfd = &pop->event_set[nfds];			pfd->fd = ev->ev_fd;			pfd->events = POLLIN;			pfd->revents = 0;			pop->event_back[nfds] = ev;			nfds++;		}	}	if (evsignal_deliver(&pop->evsigmask) == -1)		return (-1);	sec = tv->tv_sec * 1000 + tv->tv_usec / 1000;	res = poll(pop->event_set, nfds, sec);	if (evsignal_recalc(&pop->evsigmask) == -1)		return (-1);	if (res == -1) {		if (errno != EINTR) {			log_error("poll");			return (-1);		}		evsignal_process();		return (0);	} else if (evsignal_caught)		evsignal_process();	LOG_DBG((LOG_MISC, 80, "%s: poll reports %d", __func__, res));	if (res == 0)		return (0);	for (i = 0; i < nfds; i++) {                int what = pop->event_set[i].revents;				res = 0;		/* If the file gets closed notify */		if (what & POLLHUP)			what |= POLLIN|POLLOUT;                if (what & POLLERR)                         what |= POLLIN|POLLOUT;		if (what & POLLIN)			res |= EV_READ;		if (what & POLLOUT)			res |= EV_WRITE;		if (res == 0)			continue;		ev = pop->event_back[i];		res &= ev->ev_events;		if (res) {			if (!(ev->ev_events & EV_PERSIST))				event_del(ev);			event_active(ev, res, 1);		}		}	return (0);}