[MEDIUM] updated all files to use EV_FD_*

Removed the temporary dirty hack.
diff --git a/include/proto/fd.h b/include/proto/fd.h
index 03a7add..be52612 100644
--- a/include/proto/fd.h
+++ b/include/proto/fd.h
@@ -51,22 +51,11 @@
  */
 void run_poller();
 
-
-/* FIXME: dirty hack during code transition */
-#define dir_StaticWriteEvent DIR_WR
-#define dir_StaticReadEvent DIR_RD
-#define dir_DIR_RD DIR_RD
-#define dir_DIR_WR DIR_WR
-
-#define MY_FD_SET(fd, ev) (cur_poller.set((fd), dir_##ev))
-#define MY_FD_CLR(fd, ev) (cur_poller.clr((fd), dir_##ev))
-#define MY_FD_ISSET(fd, ev) (cur_poller.isset((fd), dir_##ev))
-
-#define EV_FD_SET(fd, ev)    (cur_poller.set((fd), dir_##ev))
-#define EV_FD_CLR(fd, ev)    (cur_poller.clr((fd), dir_##ev))
-#define EV_FD_ISSET(fd, ev)  (cur_poller.isset((fd), dir_##ev))
-#define EV_FD_COND_S(fd, ev) (cur_poller.cond_s((fd), dir_##ev))
-#define EV_FD_COND_C(fd, ev) (cur_poller.cond_c((fd), dir_##ev))
+#define EV_FD_SET(fd, ev)    (cur_poller.set((fd), (ev)))
+#define EV_FD_CLR(fd, ev)    (cur_poller.clr((fd), (ev)))
+#define EV_FD_ISSET(fd, ev)  (cur_poller.isset((fd), (ev)))
+#define EV_FD_COND_S(fd, ev) (cur_poller.cond_s((fd), (ev)))
+#define EV_FD_COND_C(fd, ev) (cur_poller.cond_c((fd), (ev)))
 #define EV_FD_REM(fd)        (cur_poller.rem(fd))
 #define EV_FD_CLO(fd)        (cur_poller.clo(fd))
 
diff --git a/src/backend.c b/src/backend.c
index ff02443..0eb97ed 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -532,13 +532,7 @@
 	fdtab[fd].cb[DIR_WR].f = &stream_sock_write;
 	fdtab[fd].cb[DIR_WR].b = s->req;
     
-	MY_FD_SET(fd, StaticWriteEvent);  /* for connect status */
-#if defined(DEBUG_FULL) && defined(ENABLE_EPOLL)
-	if (PrevReadEvent) {
-		assert(!(MY_FD_ISSET(fd, PrevReadEvent)));
-		assert(!(MY_FD_ISSET(fd, PrevWriteEvent)));
-	}
-#endif
+	EV_FD_SET(fd, DIR_WR);  /* for connect status */
     
 	fd_insert(fd);
 	if (s->srv) {
diff --git a/src/checks.c b/src/checks.c
index 456d7a3..0a27201 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -118,7 +118,7 @@
 		/* in case of TCP only, this tells us if the connection failed */
 		s->result = -1;
 		fdtab[fd].state = FD_STERROR;
-		MY_FD_CLR(fd, StaticWriteEvent);
+		EV_FD_CLR(fd, DIR_WR);
 	}
 	else if (s->result != -1) {
 		/* we don't want to mark 'UP' a server on which we detected an error earlier */
@@ -141,13 +141,13 @@
 			ret = send(fd, s->proxy->check_req, s->proxy->check_len, MSG_DONTWAIT | MSG_NOSIGNAL);
 #endif
 			if (ret == s->proxy->check_len) {
-				MY_FD_SET(fd, StaticReadEvent);   /* prepare for reading reply */
-				MY_FD_CLR(fd, StaticWriteEvent);  /* nothing more to write */
+				EV_FD_SET(fd, DIR_RD);   /* prepare for reading reply */
+				EV_FD_CLR(fd, DIR_WR);   /* nothing more to write */
 				return 0;
 			}
 			else {
 				s->result = -1;
-				MY_FD_CLR(fd, StaticWriteEvent);
+				EV_FD_CLR(fd, DIR_WR);
 			}
 		}
 		else {
@@ -204,7 +204,7 @@
 	if (s->result != -1)
 		s->result = result;
 
-	MY_FD_CLR(fd, StaticReadEvent);
+	EV_FD_CLR(fd, DIR_RD);
 	task_wakeup(&rq, t);
 	return 0;
 }
@@ -335,9 +335,9 @@
 						fdtab[fd].cb[DIR_WR].f = &event_srv_chk_w;
 						fdtab[fd].cb[DIR_WR].b = NULL;
 						fdtab[fd].state = FD_STCONN; /* connection in progress */
-						MY_FD_SET(fd, StaticWriteEvent);  /* for connect status */
+						EV_FD_SET(fd, DIR_WR);  /* for connect status */
 #ifdef DEBUG_FULL
-						assert (!MY_FD_ISSET(fd, StaticReadEvent));
+						assert (!EV_FD_ISSET(fd, DIR_RD));
 #endif
 						fd_insert(fd);
 						/* FIXME: we allow up to <inter> for a connection to establish, but we should use another parameter */
@@ -420,7 +420,6 @@
 				s->health = s->rise + s->fall - 1; /* OK now */
 			}
 			s->curfd = -1; /* no check running anymore */
-			//MY_FD_CLR(fd, StaticWriteEvent);
 			fd_delete(fd);
 			while (tv_cmp2_ms(&t->expire, &now) <= 0)
 				tv_delayfrom(&t->expire, &t->expire, s->inter);
@@ -436,7 +435,6 @@
 			else
 				set_server_down(s);
 			s->curfd = -1;
-			//MY_FD_CLR(fd, StaticWriteEvent);
 			fd_delete(fd);
 			while (tv_cmp2_ms(&t->expire, &now) <= 0)
 				tv_delayfrom(&t->expire, &t->expire, s->inter);
diff --git a/src/client.c b/src/client.c
index de8280b..6b27df6 100644
--- a/src/client.c
+++ b/src/client.c
@@ -99,7 +99,7 @@
 
 		if ((s = pool_alloc(session)) == NULL) { /* disable this proxy for a while */
 			Alert("out of memory in event_accept().\n");
-			MY_FD_CLR(fd, StaticReadEvent);
+			EV_FD_CLR(fd, DIR_RD);
 			p->state = PR_STIDLE;
 			close(cfd);
 			return 0;
@@ -122,7 +122,7 @@
 
 		if ((t = pool_alloc(task)) == NULL) { /* disable this proxy for a while */
 			Alert("out of memory in event_accept().\n");
-			MY_FD_CLR(fd, StaticReadEvent);
+			EV_FD_CLR(fd, DIR_RD);
 			p->state = PR_STIDLE;
 			close(cfd);
 			pool_free(session, s);
@@ -399,15 +399,9 @@
 			client_retnclose(s, &msg); /* forge an "OK" response */
 		}
 		else {
-			MY_FD_SET(cfd, StaticReadEvent);
+			EV_FD_SET(cfd, DIR_RD);
 		}
 
-#if defined(DEBUG_FULL) && defined(ENABLE_EPOLL)
-		if (PrevReadEvent) {
-			assert(!(MY_FD_ISSET(cfd, PrevReadEvent)));
-			assert(!(MY_FD_ISSET(cfd, PrevWriteEvent)));
-		}
-#endif
 		fd_insert(cfd);
 
 		tv_eternity(&s->req->rex);
@@ -417,9 +411,9 @@
 		tv_eternity(&s->rep->wex);
 
 		if (s->fe->clitimeout) {
-			if (MY_FD_ISSET(cfd, StaticReadEvent))
+			if (EV_FD_ISSET(cfd, DIR_RD))
 				tv_delayfrom(&s->req->rex, &now, s->fe->clitimeout);
-			if (MY_FD_ISSET(cfd, StaticWriteEvent))
+			if (EV_FD_ISSET(cfd, DIR_WR))
 				tv_delayfrom(&s->rep->wex, &now, s->fe->clitimeout);
 		}
 
diff --git a/src/haproxy.c b/src/haproxy.c
index 7b23e2f..bafff4b 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -277,10 +277,10 @@
 			 s, tv_remain(&now, &t->expire),
 			 s->cli_state,
 			 s->srv_state,
-			 MY_FD_ISSET(s->cli_fd, StaticReadEvent),
-			 MY_FD_ISSET(s->cli_fd, StaticWriteEvent),
-			 MY_FD_ISSET(s->srv_fd, StaticReadEvent),
-			 MY_FD_ISSET(s->srv_fd, StaticWriteEvent),
+			 EV_FD_ISSET(s->cli_fd, DIR_RD),
+			 EV_FD_ISSET(s->cli_fd, DIR_WR),
+			 EV_FD_ISSET(s->srv_fd, DIR_RD),
+			 EV_FD_ISSET(s->srv_fd, DIR_WR),
 			 s->req->l, s->rep?s->rep->l:0, s->cli_fd
 			 );
 	}
diff --git a/src/proto_http.c b/src/proto_http.c
index 38b2db0..6a2cc0b 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -437,8 +437,8 @@
  */
 void client_retnclose(struct session *s, const struct chunk *msg)
 {
-	MY_FD_CLR(s->cli_fd, StaticReadEvent);
-	MY_FD_SET(s->cli_fd, StaticWriteEvent);
+	EV_FD_CLR(s->cli_fd, DIR_RD);
+	EV_FD_SET(s->cli_fd, DIR_WR);
 	tv_eternity(&s->req->rex);
 	if (s->fe->clitimeout)
 		tv_delayfrom(&s->rep->wex, &now, s->fe->clitimeout);
@@ -1433,7 +1433,7 @@
 
 	DPRINTF(stderr,"process_cli: c=%s s=%s set(r,w)=%d,%d exp(r,w)=%d.%d,%d.%d\n",
 		cli_stnames[c], srv_stnames[s],
-		MY_FD_ISSET(t->cli_fd, StaticReadEvent), MY_FD_ISSET(t->cli_fd, StaticWriteEvent),
+		EV_FD_ISSET(t->cli_fd, DIR_RD), EV_FD_ISSET(t->cli_fd, DIR_WR),
 		req->rex.tv_sec, req->rex.tv_usec,
 		rep->wex.tv_sec, rep->wex.tv_usec);
 
@@ -1540,12 +1540,12 @@
 			}
 
 			/* 4: do we need to re-enable the read socket ? */
-			else if (unlikely(! MY_FD_ISSET(t->cli_fd, StaticReadEvent))) {
-				/* fd in StaticReadEvent was disabled, perhaps because of a previous buffer
+			else if (unlikely(! EV_FD_ISSET(t->cli_fd, DIR_RD))) {
+				/* fd in DIR_RD was disabled, perhaps because of a previous buffer
 				 * full. We cannot loop here since stream_sock_read will disable it only if
 				 * req->l == rlim-data
 				 */
-				MY_FD_SET(t->cli_fd, StaticReadEvent);
+				EV_FD_SET(t->cli_fd, DIR_RD);
 				if (t->fe->clitimeout)
 					tv_delayfrom(&req->rex, &now, t->fe->clitimeout);
 				else
@@ -1963,7 +1963,7 @@
 		}
 		/* last read, or end of server write */
 		else if (req->flags & BF_READ_NULL || s == SV_STSHUTW || s == SV_STCLOSE) {
-			MY_FD_CLR(t->cli_fd, StaticReadEvent);
+			EV_FD_CLR(t->cli_fd, DIR_RD);
 			tv_eternity(&req->rex);
 			shutdown(t->cli_fd, SHUT_RD);
 			t->cli_state = CL_STSHUTR;
@@ -1971,12 +1971,12 @@
 		}	
 		/* last server read and buffer empty */
 		else if ((s == SV_STSHUTR || s == SV_STCLOSE) && (rep->l == 0)) {
-			MY_FD_CLR(t->cli_fd, StaticWriteEvent);
+			EV_FD_CLR(t->cli_fd, DIR_WR);
 			tv_eternity(&rep->wex);
 			shutdown(t->cli_fd, SHUT_WR);
 			/* We must ensure that the read part is still alive when switching
 			 * to shutw */
-			MY_FD_SET(t->cli_fd, StaticReadEvent);
+			EV_FD_SET(t->cli_fd, DIR_RD);
 			if (t->fe->clitimeout)
 				tv_delayfrom(&req->rex, &now, t->fe->clitimeout);
 			t->cli_state = CL_STSHUTW;
@@ -1985,7 +1985,7 @@
 		}
 		/* read timeout */
 		else if (tv_cmp2_ms(&req->rex, &now) <= 0) {
-			MY_FD_CLR(t->cli_fd, StaticReadEvent);
+			EV_FD_CLR(t->cli_fd, DIR_RD);
 			tv_eternity(&req->rex);
 			shutdown(t->cli_fd, SHUT_RD);
 			t->cli_state = CL_STSHUTR;
@@ -2003,12 +2003,12 @@
 		}	
 		/* write timeout */
 		else if (tv_cmp2_ms(&rep->wex, &now) <= 0) {
-			MY_FD_CLR(t->cli_fd, StaticWriteEvent);
+			EV_FD_CLR(t->cli_fd, DIR_WR);
 			tv_eternity(&rep->wex);
 			shutdown(t->cli_fd, SHUT_WR);
 			/* We must ensure that the read part is still alive when switching
 			 * to shutw */
-			MY_FD_SET(t->cli_fd, StaticReadEvent);
+			EV_FD_SET(t->cli_fd, DIR_RD);
 			if (t->fe->clitimeout)
 				tv_delayfrom(&req->rex, &now, t->fe->clitimeout);
 
@@ -2028,15 +2028,15 @@
 
 		if (req->l >= req->rlim - req->data) {
 			/* no room to read more data */
-			if (MY_FD_ISSET(t->cli_fd, StaticReadEvent)) {
+			if (EV_FD_ISSET(t->cli_fd, DIR_RD)) {
 				/* stop reading until we get some space */
-				MY_FD_CLR(t->cli_fd, StaticReadEvent);
+				EV_FD_CLR(t->cli_fd, DIR_RD);
 				tv_eternity(&req->rex);
 			}
 		} else {
 			/* there's still some space in the buffer */
-			if (! MY_FD_ISSET(t->cli_fd, StaticReadEvent)) {
-				MY_FD_SET(t->cli_fd, StaticReadEvent);
+			if (! EV_FD_ISSET(t->cli_fd, DIR_RD)) {
+				EV_FD_SET(t->cli_fd, DIR_RD);
 				if (!t->fe->clitimeout ||
 				    (t->srv_state < SV_STDATA && t->be->srvtimeout))
 					/* If the client has no timeout, or if the server not ready yet, and we
@@ -2052,14 +2052,14 @@
 
 		if ((rep->l == 0) ||
 		    ((s < SV_STDATA) /* FIXME: this may be optimized && (rep->w == rep->h)*/)) {
-			if (MY_FD_ISSET(t->cli_fd, StaticWriteEvent)) {
-				MY_FD_CLR(t->cli_fd, StaticWriteEvent); /* stop writing */
+			if (EV_FD_ISSET(t->cli_fd, DIR_WR)) {
+				EV_FD_CLR(t->cli_fd, DIR_WR); /* stop writing */
 				tv_eternity(&rep->wex);
 			}
 		} else {
 			/* buffer not empty */
-			if (! MY_FD_ISSET(t->cli_fd, StaticWriteEvent)) {
-				MY_FD_SET(t->cli_fd, StaticWriteEvent); /* restart writing */
+			if (! EV_FD_ISSET(t->cli_fd, DIR_WR)) {
+				EV_FD_SET(t->cli_fd, DIR_WR); /* restart writing */
 				if (t->fe->clitimeout) {
 					tv_delayfrom(&rep->wex, &now, t->fe->clitimeout);
 					/* FIXME: to prevent the client from expiring read timeouts during writes,
@@ -2125,14 +2125,14 @@
 
 		if ((rep->l == 0)
 		    || ((s == SV_STHEADERS) /* FIXME: this may be optimized && (rep->w == rep->h)*/)) {
-			if (MY_FD_ISSET(t->cli_fd, StaticWriteEvent)) {
-				MY_FD_CLR(t->cli_fd, StaticWriteEvent); /* stop writing */
+			if (EV_FD_ISSET(t->cli_fd, DIR_WR)) {
+				EV_FD_CLR(t->cli_fd, DIR_WR); /* stop writing */
 				tv_eternity(&rep->wex);
 			}
 		} else {
 			/* buffer not empty */
-			if (! MY_FD_ISSET(t->cli_fd, StaticWriteEvent)) {
-				MY_FD_SET(t->cli_fd, StaticWriteEvent); /* restart writing */
+			if (! EV_FD_ISSET(t->cli_fd, DIR_WR)) {
+				EV_FD_SET(t->cli_fd, DIR_WR); /* restart writing */
 				if (t->fe->clitimeout) {
 					tv_delayfrom(&rep->wex, &now, t->fe->clitimeout);
 					/* FIXME: to prevent the client from expiring read timeouts during writes,
@@ -2191,16 +2191,16 @@
 			 * after the timeout by sending more data after it receives a close ?
 			 */
 
-			if (MY_FD_ISSET(t->cli_fd, StaticReadEvent)) {
+			if (EV_FD_ISSET(t->cli_fd, DIR_RD)) {
 				/* stop reading until we get some space */
-				MY_FD_CLR(t->cli_fd, StaticReadEvent);
+				EV_FD_CLR(t->cli_fd, DIR_RD);
 				tv_eternity(&req->rex);
 				//fprintf(stderr,"%p:%s(%d), c=%d, s=%d\n", t, __FUNCTION__, __LINE__, t->cli_state, t->cli_state);
 			}
 		} else {
 			/* there's still some space in the buffer */
-			if (! MY_FD_ISSET(t->cli_fd, StaticReadEvent)) {
-				MY_FD_SET(t->cli_fd, StaticReadEvent);
+			if (! EV_FD_ISSET(t->cli_fd, DIR_RD)) {
+				EV_FD_SET(t->cli_fd, DIR_RD);
 				if (t->fe->clitimeout)
 					tv_delayfrom(&req->rex, &now, t->fe->clitimeout);
 				else
@@ -2239,8 +2239,8 @@
 	fprintf(stderr,"process_srv: c=%s, s=%s\n", cli_stnames[c], srv_stnames[s]);
 #endif
 	//fprintf(stderr,"process_srv: c=%d, s=%d, cr=%d, cw=%d, sr=%d, sw=%d\n", c, s,
-	//MY_FD_ISSET(t->cli_fd, StaticReadEvent), MY_FD_ISSET(t->cli_fd, StaticWriteEvent),
-	//MY_FD_ISSET(t->srv_fd, StaticReadEvent), MY_FD_ISSET(t->srv_fd, StaticWriteEvent)
+	//EV_FD_ISSET(t->cli_fd, DIR_RD), EV_FD_ISSET(t->cli_fd, DIR_WR),
+	//EV_FD_ISSET(t->srv_fd, DIR_RD), EV_FD_ISSET(t->srv_fd, DIR_WR)
 	//);
 	if (s == SV_STIDLE) {
 		if (c == CL_STHEADERS)
@@ -2397,10 +2397,10 @@
 
 			//fprintf(stderr,"3: c=%d, s=%d\n", c, s);
 			if (req->l == 0) /* nothing to write */ {
-				MY_FD_CLR(t->srv_fd, StaticWriteEvent);
+				EV_FD_CLR(t->srv_fd, DIR_WR);
 				tv_eternity(&req->wex);
 			} else  /* need the right to write */ {
-				MY_FD_SET(t->srv_fd, StaticWriteEvent);
+				EV_FD_SET(t->srv_fd, DIR_WR);
 				if (t->be->srvtimeout) {
 					tv_delayfrom(&req->wex, &now, t->be->srvtimeout);
 					/* FIXME: to prevent the server from expiring read timeouts during writes,
@@ -2412,7 +2412,7 @@
 			}
 
 			if (t->be->mode == PR_MODE_TCP) { /* let's allow immediate data connection in this case */
-				MY_FD_SET(t->srv_fd, StaticReadEvent);
+				EV_FD_SET(t->srv_fd, DIR_RD);
 				if (t->be->srvtimeout)
 					tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
 				else
@@ -2497,12 +2497,12 @@
 		}
 
 
-		if ((rep->l < rep->rlim - rep->data) && ! MY_FD_ISSET(t->srv_fd, StaticReadEvent)) {
-			/* fd in StaticReadEvent was disabled, perhaps because of a previous buffer
+		if ((rep->l < rep->rlim - rep->data) && ! EV_FD_ISSET(t->srv_fd, DIR_RD)) {
+			/* fd in DIR_RD was disabled, perhaps because of a previous buffer
 			 * full. We cannot loop here since stream_sock_read will disable it only if
 			 * rep->l == rlim-data
 			 */
-			MY_FD_SET(t->srv_fd, StaticReadEvent);
+			EV_FD_SET(t->srv_fd, DIR_RD);
 			if (t->be->srvtimeout)
 				tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
 			else
@@ -2560,7 +2560,7 @@
 			else if (unlikely(rep->flags & BF_READ_NULL ||
 			                  c == CL_STSHUTW || c == CL_STCLOSE ||
 			                  rep->l >= rep->rlim - rep->data)) {
-				MY_FD_CLR(t->srv_fd, StaticReadEvent);
+				EV_FD_CLR(t->srv_fd, DIR_RD);
 				tv_eternity(&rep->rex);
 				shutdown(t->srv_fd, SHUT_RD);
 				t->srv_state = SV_STSHUTR;
@@ -2570,7 +2570,7 @@
 
 			/* read timeout : return a 504 to the client.
 			 */
-			else if (unlikely(MY_FD_ISSET(t->srv_fd, StaticReadEvent) &&
+			else if (unlikely(EV_FD_ISSET(t->srv_fd, DIR_RD) &&
 			                  tv_cmp2_ms(&rep->rex, &now) <= 0)) {
 				tv_eternity(&rep->rex);
 				tv_eternity(&req->wex);
@@ -2605,12 +2605,12 @@
 			 */
 			else if (unlikely((/*c == CL_STSHUTR ||*/ c == CL_STCLOSE) &&
 			                  (req->l == 0))) {
-				MY_FD_CLR(t->srv_fd, StaticWriteEvent);
+				EV_FD_CLR(t->srv_fd, DIR_WR);
 				tv_eternity(&req->wex);
 
 				/* We must ensure that the read part is still
 				 * alive when switching to shutw */
-				MY_FD_SET(t->srv_fd, StaticReadEvent);
+				EV_FD_SET(t->srv_fd, DIR_RD);
 				if (t->be->srvtimeout)
 					tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
 
@@ -2624,14 +2624,14 @@
 			 * client shuts read too early, because we may still have
 			 * some work to do on the headers.
 			 */
-			else if (unlikely(MY_FD_ISSET(t->srv_fd, StaticWriteEvent) &&
+			else if (unlikely(EV_FD_ISSET(t->srv_fd, DIR_WR) &&
 			                  tv_cmp2_ms(&req->wex, &now) <= 0)) {
-				MY_FD_CLR(t->srv_fd, StaticWriteEvent);
+				EV_FD_CLR(t->srv_fd, DIR_WR);
 				tv_eternity(&req->wex);
 				shutdown(t->srv_fd, SHUT_WR);
 				/* We must ensure that the read part is still alive
 				 * when switching to shutw */
-				MY_FD_SET(t->srv_fd, StaticReadEvent);
+				EV_FD_SET(t->srv_fd, DIR_RD);
 				if (t->be->srvtimeout)
 					tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
 
@@ -2652,8 +2652,8 @@
 			 * long posts.
 			 */
 			else if (likely(req->l)) {
-				if (! MY_FD_ISSET(t->srv_fd, StaticWriteEvent)) {
-					MY_FD_SET(t->srv_fd, StaticWriteEvent); /* restart writing */
+				if (! EV_FD_ISSET(t->srv_fd, DIR_WR)) {
+					EV_FD_SET(t->srv_fd, DIR_WR); /* restart writing */
 					if (t->be->srvtimeout) {
 						tv_delayfrom(&req->wex, &now, t->be->srvtimeout);
 						/* FIXME: to prevent the server from expiring read timeouts during writes,
@@ -2667,8 +2667,8 @@
 
 			/* nothing left in the request buffer */
 			else {
-				if (MY_FD_ISSET(t->srv_fd, StaticWriteEvent)) {
-					MY_FD_CLR(t->srv_fd, StaticWriteEvent); /* stop writing */
+				if (EV_FD_ISSET(t->srv_fd, DIR_WR)) {
+					EV_FD_CLR(t->srv_fd, DIR_WR); /* stop writing */
 					tv_eternity(&req->wex);
 				}
 			}
@@ -2942,12 +2942,12 @@
 		 */
 		if ((req->l == 0) &&
 		    (c == CL_STSHUTR || c == CL_STCLOSE || t->be->options & PR_O_FORCE_CLO)) {
-			MY_FD_CLR(t->srv_fd, StaticWriteEvent);
+			EV_FD_CLR(t->srv_fd, DIR_WR);
 			tv_eternity(&req->wex);
 
 			/* We must ensure that the read part is still alive when switching
 			 * to shutw */
-			MY_FD_SET(t->srv_fd, StaticReadEvent);
+			EV_FD_SET(t->srv_fd, DIR_RD);
 			if (t->be->srvtimeout)
 				tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
 
@@ -3004,7 +3004,7 @@
 		}
 		/* last read, or end of client write */
 		else if (rep->flags & BF_READ_NULL || c == CL_STSHUTW || c == CL_STCLOSE) {
-			MY_FD_CLR(t->srv_fd, StaticReadEvent);
+			EV_FD_CLR(t->srv_fd, DIR_RD);
 			tv_eternity(&rep->rex);
 			shutdown(t->srv_fd, SHUT_RD);
 			t->srv_state = SV_STSHUTR;
@@ -3013,12 +3013,12 @@
 		}
 		/* end of client read and no more data to send */
 		else if ((c == CL_STSHUTR || c == CL_STCLOSE) && (req->l == 0)) {
-			MY_FD_CLR(t->srv_fd, StaticWriteEvent);
+			EV_FD_CLR(t->srv_fd, DIR_WR);
 			tv_eternity(&req->wex);
 			shutdown(t->srv_fd, SHUT_WR);
 			/* We must ensure that the read part is still alive when switching
 			 * to shutw */
-			MY_FD_SET(t->srv_fd, StaticReadEvent);
+			EV_FD_SET(t->srv_fd, DIR_RD);
 			if (t->be->srvtimeout)
 				tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
 
@@ -3027,7 +3027,7 @@
 		}
 		/* read timeout */
 		else if (tv_cmp2_ms(&rep->rex, &now) <= 0) {
-			MY_FD_CLR(t->srv_fd, StaticReadEvent);
+			EV_FD_CLR(t->srv_fd, DIR_RD);
 			tv_eternity(&rep->rex);
 			shutdown(t->srv_fd, SHUT_RD);
 			t->srv_state = SV_STSHUTR;
@@ -3039,12 +3039,12 @@
 		}	
 		/* write timeout */
 		else if (tv_cmp2_ms(&req->wex, &now) <= 0) {
-			MY_FD_CLR(t->srv_fd, StaticWriteEvent);
+			EV_FD_CLR(t->srv_fd, DIR_WR);
 			tv_eternity(&req->wex);
 			shutdown(t->srv_fd, SHUT_WR);
 			/* We must ensure that the read part is still alive when switching
 			 * to shutw */
-			MY_FD_SET(t->srv_fd, StaticReadEvent);
+			EV_FD_SET(t->srv_fd, DIR_RD);
 			if (t->be->srvtimeout)
 				tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
 			t->srv_state = SV_STSHUTW;
@@ -3057,14 +3057,14 @@
 
 		/* recompute request time-outs */
 		if (req->l == 0) {
-			if (MY_FD_ISSET(t->srv_fd, StaticWriteEvent)) {
-				MY_FD_CLR(t->srv_fd, StaticWriteEvent); /* stop writing */
+			if (EV_FD_ISSET(t->srv_fd, DIR_WR)) {
+				EV_FD_CLR(t->srv_fd, DIR_WR); /* stop writing */
 				tv_eternity(&req->wex);
 			}
 		}
 		else { /* buffer not empty, there are still data to be transferred */
-			if (! MY_FD_ISSET(t->srv_fd, StaticWriteEvent)) {
-				MY_FD_SET(t->srv_fd, StaticWriteEvent); /* restart writing */
+			if (! EV_FD_ISSET(t->srv_fd, DIR_WR)) {
+				EV_FD_SET(t->srv_fd, DIR_WR); /* restart writing */
 				if (t->be->srvtimeout) {
 					tv_delayfrom(&req->wex, &now, t->be->srvtimeout);
 					/* FIXME: to prevent the server from expiring read timeouts during writes,
@@ -3078,14 +3078,14 @@
 
 		/* recompute response time-outs */
 		if (rep->l == BUFSIZE) { /* no room to read more data */
-			if (MY_FD_ISSET(t->srv_fd, StaticReadEvent)) {
-				MY_FD_CLR(t->srv_fd, StaticReadEvent);
+			if (EV_FD_ISSET(t->srv_fd, DIR_RD)) {
+				EV_FD_CLR(t->srv_fd, DIR_RD);
 				tv_eternity(&rep->rex);
 			}
 		}
 		else {
-			if (! MY_FD_ISSET(t->srv_fd, StaticReadEvent)) {
-				MY_FD_SET(t->srv_fd, StaticReadEvent);
+			if (! EV_FD_ISSET(t->srv_fd, DIR_RD)) {
+				EV_FD_SET(t->srv_fd, DIR_RD);
 				if (t->be->srvtimeout)
 					tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
 				else
@@ -3097,7 +3097,7 @@
 	}
 	else if (s == SV_STSHUTR) {
 		if (req->flags & BF_WRITE_ERROR) {
-			//MY_FD_CLR(t->srv_fd, StaticWriteEvent);
+			//EV_FD_CLR(t->srv_fd, DIR_WR);
 			tv_eternity(&req->wex);
 			fd_delete(t->srv_fd);
 			if (t->srv) {
@@ -3120,7 +3120,7 @@
 			return 1;
 		}
 		else if ((c == CL_STSHUTR || c == CL_STCLOSE) && (req->l == 0)) {
-			//MY_FD_CLR(t->srv_fd, StaticWriteEvent);
+			//EV_FD_CLR(t->srv_fd, DIR_WR);
 			tv_eternity(&req->wex);
 			fd_delete(t->srv_fd);
 			if (t->srv)
@@ -3136,7 +3136,7 @@
 			return 1;
 		}
 		else if (tv_cmp2_ms(&req->wex, &now) <= 0) {
-			//MY_FD_CLR(t->srv_fd, StaticWriteEvent);
+			//EV_FD_CLR(t->srv_fd, DIR_WR);
 			tv_eternity(&req->wex);
 			fd_delete(t->srv_fd);
 			if (t->srv)
@@ -3156,14 +3156,14 @@
 			return 1;
 		}
 		else if (req->l == 0) {
-			if (MY_FD_ISSET(t->srv_fd, StaticWriteEvent)) {
-				MY_FD_CLR(t->srv_fd, StaticWriteEvent); /* stop writing */
+			if (EV_FD_ISSET(t->srv_fd, DIR_WR)) {
+				EV_FD_CLR(t->srv_fd, DIR_WR); /* stop writing */
 				tv_eternity(&req->wex);
 			}
 		}
 		else { /* buffer not empty */
-			if (! MY_FD_ISSET(t->srv_fd, StaticWriteEvent)) {
-				MY_FD_SET(t->srv_fd, StaticWriteEvent); /* restart writing */
+			if (! EV_FD_ISSET(t->srv_fd, DIR_WR)) {
+				EV_FD_SET(t->srv_fd, DIR_WR); /* restart writing */
 				if (t->be->srvtimeout) {
 					tv_delayfrom(&req->wex, &now, t->be->srvtimeout);
 					/* FIXME: to prevent the server from expiring read timeouts during writes,
@@ -3178,7 +3178,7 @@
 	}
 	else if (s == SV_STSHUTW) {
 		if (rep->flags & BF_READ_ERROR) {
-			//MY_FD_CLR(t->srv_fd, StaticReadEvent);
+			//EV_FD_CLR(t->srv_fd, DIR_RD);
 			tv_eternity(&rep->rex);
 			fd_delete(t->srv_fd);
 			if (t->srv) {
@@ -3201,7 +3201,7 @@
 			return 1;
 		}
 		else if (rep->flags & BF_READ_NULL || c == CL_STSHUTW || c == CL_STCLOSE) {
-			//MY_FD_CLR(t->srv_fd, StaticReadEvent);
+			//EV_FD_CLR(t->srv_fd, DIR_RD);
 			tv_eternity(&rep->rex);
 			fd_delete(t->srv_fd);
 			if (t->srv)
@@ -3217,7 +3217,7 @@
 			return 1;
 		}
 		else if (tv_cmp2_ms(&rep->rex, &now) <= 0) {
-			//MY_FD_CLR(t->srv_fd, StaticReadEvent);
+			//EV_FD_CLR(t->srv_fd, DIR_RD);
 			tv_eternity(&rep->rex);
 			fd_delete(t->srv_fd);
 			if (t->srv)
@@ -3237,14 +3237,14 @@
 			return 1;
 		}
 		else if (rep->l == BUFSIZE) { /* no room to read more data */
-			if (MY_FD_ISSET(t->srv_fd, StaticReadEvent)) {
-				MY_FD_CLR(t->srv_fd, StaticReadEvent);
+			if (EV_FD_ISSET(t->srv_fd, DIR_RD)) {
+				EV_FD_CLR(t->srv_fd, DIR_RD);
 				tv_eternity(&rep->rex);
 			}
 		}
 		else {
-			if (! MY_FD_ISSET(t->srv_fd, StaticReadEvent)) {
-				MY_FD_SET(t->srv_fd, StaticReadEvent);
+			if (! EV_FD_ISSET(t->srv_fd, DIR_RD)) {
+				EV_FD_SET(t->srv_fd, DIR_RD);
 				if (t->be->srvtimeout)
 					tv_delayfrom(&rep->rex, &now, t->be->srvtimeout);
 				else
diff --git a/src/proxy.c b/src/proxy.c
index 41bf46b..ff3cdc7 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -147,7 +147,7 @@
 			fdtab[fd].cb[DIR_RD].b = fdtab[fd].cb[DIR_WR].b = NULL;
 			fdtab[fd].owner = (struct task *)curproxy; /* reference the proxy instead of a task */
 			fdtab[fd].state = FD_STLISTEN;
-			MY_FD_SET(fd, StaticReadEvent);
+			EV_FD_SET(fd, DIR_RD);
 			fd_insert(fd);
 			listeners++;
 		}
@@ -183,7 +183,7 @@
 			if (p->feconn < p->maxconn) {
 				if (p->state == PR_STIDLE) {
 					for (l = p->listen; l != NULL; l = l->next) {
-						MY_FD_SET(l->fd, StaticReadEvent);
+						EV_FD_SET(l->fd, DIR_RD);
 					}
 					p->state = PR_STRUN;
 				}
@@ -191,7 +191,7 @@
 			else {
 				if (p->state == PR_STRUN) {
 					for (l = p->listen; l != NULL; l = l->next) {
-						MY_FD_CLR(l->fd, StaticReadEvent);
+						EV_FD_CLR(l->fd, DIR_RD);
 					}
 					p->state = PR_STIDLE;
 				}
@@ -203,7 +203,7 @@
 		while (p) {
 			if (p->state == PR_STRUN) {
 				for (l = p->listen; l != NULL; l = l->next) {
-					MY_FD_CLR(l->fd, StaticReadEvent);
+					EV_FD_CLR(l->fd, DIR_RD);
 				}
 				p->state = PR_STIDLE;
 			}
@@ -276,7 +276,7 @@
 		if (shutdown(l->fd, SHUT_WR) == 0 &&
 		    listen(l->fd, p->maxconn) == 0 &&
 		    shutdown(l->fd, SHUT_RD) == 0) {
-			MY_FD_CLR(l->fd, StaticReadEvent);
+			EV_FD_CLR(l->fd, DIR_RD);
 			if (p->state != PR_STERROR)
 				p->state = PR_STPAUSED;
 		}
@@ -342,7 +342,7 @@
 			for (l = p->listen; l != NULL; l = l->next) {
 				if (listen(l->fd, p->maxconn) == 0) {
 					if (actconn < global.maxconn && p->feconn < p->maxconn) {
-						MY_FD_SET(l->fd, StaticReadEvent);
+						EV_FD_SET(l->fd, DIR_RD);
 						p->state = PR_STRUN;
 					}
 					else
diff --git a/src/stream_sock.c b/src/stream_sock.c
index f9e5627..a150a08 100644
--- a/src/stream_sock.c
+++ b/src/stream_sock.c
@@ -67,7 +67,7 @@
 			}
 	    
 			if (max == 0) {  /* not anymore room to store data */
-				MY_FD_CLR(fd, StaticReadEvent);
+				EV_FD_CLR(fd, DIR_RD);
 				break;
 			}
 
@@ -127,7 +127,7 @@
 	}
 
 	if (b->flags & BF_READ_STATUS) {
-		if (b->rto && MY_FD_ISSET(fd, StaticReadEvent))
+		if (b->rto && EV_FD_ISSET(fd, DIR_RD))
 			tv_delayfrom(&b->rex, &now, b->rto);
 		else
 			tv_eternity(&b->rex);
@@ -173,7 +173,7 @@
 					fdtab[fd].state = FD_STERROR;
 					task_wakeup(&rq, fdtab[fd].owner);
 					tv_eternity(&b->wex);
-					MY_FD_CLR(fd, StaticWriteEvent);
+					EV_FD_CLR(fd, DIR_WR);
 					return 0;
 				}
 			}
@@ -182,7 +182,7 @@
 			task_wakeup(&rq, fdtab[fd].owner);
 			fdtab[fd].state = FD_STREADY;
 			tv_eternity(&b->wex);
-			MY_FD_CLR(fd, StaticWriteEvent);
+			EV_FD_CLR(fd, DIR_WR);
 			return 0;
 		}