rem: fd,  h->signo, pid);
add: fd,  h->signo, my_pid());
context: inline static int io_watch_add(	io_wait_h* h,								int fd,								fd_type type,								void* data){	/* helper macros */#define fd_array_setup \	do{ \		h->fd_array[h->fd_no].fd=fd; \		h->fd_array[h->fd_no].events=POLLIN; /* useless for select */ \		h->fd_array[h->fd_no].revents=0;     /* useless for select */ \	}while(0)	#define set_fd_flags(f) \	do{ \			flags=fcntl(fd, F_GETFL); \			if (flags==-1){ \				LOG(L_ERR, "ERROR: io_watch_add: fnctl: GETFL failed:" \						" %s [%d]\n", strerror(errno), errno); \				goto error; \			} \			if (fcntl(fd, F_SETFL, flags|(f))==-1){ \				LOG(L_ERR, "ERROR: io_watch_add: fnctl: SETFL" \							" failed: %s [%d]\n", strerror(errno), errno); \				goto error; \			} \	}while(0)			struct fd_map* e;	int flags;#ifdef HAVE_EPOLL	int n;	struct epoll_event ep_event;#endif#ifdef HAVE_SIGIO_RT	static char buf[65536];#endif		if (fd==-1){		LOG(L_CRIT, "BUG: io_watch_add: fd is -1!\n");		goto error;	}	/* add it to the poll fd array */	if (h->fd_no>=h->max_fd_no){		LOG(L_CRIT, "ERROR: io_watch_add: maximum fd number exceeded:"				" %d/%d\n", h->fd_no, h->max_fd_no);		goto error;	}	DBG("DBG: io_watch_add(%p, %d, %d, %p), fd_no=%d\n",			h, fd, type, data, h->fd_no);	/*  hash sanity check */	e=get_fd_map(h, fd);	if (e && (e->type!=0 /*F_NONE*/)){		LOG(L_ERR, "ERROR: io_watch_add: trying to overwrite entry %d"				" in the hash(%d, %d, %p) with (%d, %d, %p)\n",				fd, e->fd, e->type, e->data, fd, type, data);		goto error;	}		if ((e=hash_fd_map(h, fd, type, data))==0){		LOG(L_ERR, "ERROR: io_watch_add: failed to hash the fd %d\n", fd);		goto error;	}	switch(h->poll_method){ /* faster then pointer to functions */		case POLL_POLL:			fd_array_setup;			set_fd_flags(O_NONBLOCK);			break;#ifdef HAVE_SELECT		case POLL_SELECT:			fd_array_setup;			FD_SET(fd, &h->master_set);			if (h->max_fd_select<fd) h->max_fd_select=fd;			break;#endif#ifdef HAVE_SIGIO_RT		case POLL_SIGIO_RT:			fd_array_setup;			/* set async & signal */			if (fcntl(fd, F_SETOWN, my_pid())==-1){				LOG(L_ERR, "ERROR: io_watch_add: fnctl: SETOWN"				" failed: %s [%d]\n", strerror(errno), errno);				goto error;			}			if (fcntl(fd, F_SETSIG, h->signo)==-1){				LOG(L_ERR, "ERROR: io_watch_add: fnctl: SETSIG"					" failed: %s [%d]\n", strerror(errno), errno);				goto error;			}			/* set both non-blocking and async */			set_fd_flags(O_ASYNC| O_NONBLOCK);#ifdef EXTRA_DEBUG			DBG("io_watch_add: sigio_rt on f %d, signal %d to pid %d\n",					fd,  h->signo, pid);#endif			/* empty socket receive buffer, if buffer is already full			 * (e.g. early media), no more space to put packets			 * => no more signals are ever generated -- andrei */			while(recv(fd, buf, sizeof(buf), 0)>=0);			break;#endif#ifdef HAVE_EPOLL		case POLL_EPOLL_LT:			ep_event.events=EPOLLIN;			ep_event.data.ptr=e;again1:			n=epoll_ctl(h->epfd, EPOLL_CTL_ADD, fd, &ep_event);			if (n==-1){				if (errno==EAGAIN) goto again1;				LOG(L_ERR, "ERROR: io_watch_add: epoll_ctl failed: %s [%d]\n",					strerror(errno), errno);				goto error;			}			break;		case POLL_EPOLL_ET:			set_fd_flags(O_NONBLOCK);			ep_event.events=EPOLLIN|EPOLLET;			ep_event.data.ptr=e;again2:			n=epoll_ctl(h->epfd, EPOLL_CTL_ADD, fd, &ep_event);			if (n==-1){				if (errno==EAGAIN) goto again2;				LOG(L_ERR, "ERROR: io_watch_add: epoll_ctl failed: %s [%d]\n",					strerror(errno), errno);				goto error;			}			break;#endif		default:			LOG(L_CRIT, "BUG: io_watch_add: no support for poll method "					" %s (%d)\n", poll_method_str[h->poll_method],					h->poll_method);			goto error;	}		h->fd_no++; /* "activate" changes, for epoll it				   has only informative value */	return 0;error:	return -1;#undef fd_array_setup#undef set_fd_flags }