MINOR: poller: centralize poll return handling

When returning from the polling syscall, all pollers have a certain
dance to follow, made of wall clock updates, thread harmless updates,
idle time management and sleeping mask updates. Let's have a centralized
function to deal with all of this boring stuff: fd_leaving_poll(), and
make all the pollers use it.
diff --git a/include/haproxy/fd.h b/include/haproxy/fd.h
index 010fdac..fa24240 100644
--- a/include/haproxy/fd.h
+++ b/include/haproxy/fd.h
@@ -79,6 +79,7 @@
 void my_closefrom(int start);
 
 int compute_poll_timeout(int next);
+void fd_leaving_poll(int wait_time, int status);
 
 /* disable the specified poller */
 void disable_poller(const char *poller_name);
diff --git a/src/ev_epoll.c b/src/ev_epoll.c
index 5832062..fd49d92 100644
--- a/src/ev_epoll.c
+++ b/src/ev_epoll.c
@@ -208,13 +208,7 @@
 			break;
 	} while (1);
 
-	clock_leaving_poll(wait_time, status);
-
-	thread_harmless_end();
-	thread_idle_end();
-
-	if (sleeping_thread_mask & tid_bit)
-		_HA_ATOMIC_AND(&sleeping_thread_mask, ~tid_bit);
+	fd_leaving_poll(wait_time, status);
 
 	/* process polled events */
 
diff --git a/src/ev_evports.c b/src/ev_evports.c
index 4d61154..301e86e 100644
--- a/src/ev_evports.c
+++ b/src/ev_evports.c
@@ -202,13 +202,7 @@
 			break;
 	} while(1);
 
-	clock_leaving_poll(wait_time, nevlist);
-
-	thread_harmless_end();
-	thread_idle_end();
-
-	if (sleeping_thread_mask & tid_bit)
-		_HA_ATOMIC_AND(&sleeping_thread_mask, ~tid_bit);
+	fd_leaving_poll(wait_time, nevlist);
 
 	if (nevlist > 0)
 		activity[tid].poll_io++;
diff --git a/src/ev_kqueue.c b/src/ev_kqueue.c
index 3bc7121..43643fb 100644
--- a/src/ev_kqueue.c
+++ b/src/ev_kqueue.c
@@ -174,13 +174,7 @@
 			break;
 	} while (1);
 
-	clock_leaving_poll(wait_time, status);
-
-	thread_harmless_end();
-	thread_idle_end();
-
-	if (sleeping_thread_mask & tid_bit)
-		_HA_ATOMIC_AND(&sleeping_thread_mask, ~tid_bit);
+	fd_leaving_poll(wait_time, status);
 
 	for (count = 0; count < status; count++) {
 		unsigned int n = 0;
diff --git a/src/ev_poll.c b/src/ev_poll.c
index 5f52262..92e45a6 100644
--- a/src/ev_poll.c
+++ b/src/ev_poll.c
@@ -205,13 +205,8 @@
 	clock_entering_poll();
 	status = poll(poll_events, nbfd, wait_time);
 	clock_update_date(wait_time, status);
-	clock_leaving_poll(wait_time, status);
-
-	thread_harmless_end();
-	thread_idle_end();
 
-	if (sleeping_thread_mask & tid_bit)
-		_HA_ATOMIC_AND(&sleeping_thread_mask, ~tid_bit);
+	fd_leaving_poll(wait_time, status);
 
 	if (status > 0)
 		activity[tid].poll_io++;
diff --git a/src/ev_select.c b/src/ev_select.c
index 3880d0d..b3e1b40 100644
--- a/src/ev_select.c
+++ b/src/ev_select.c
@@ -180,13 +180,7 @@
 			NULL,
 			&delta);
 	clock_update_date(delta_ms, status);
-	clock_leaving_poll(delta_ms, status);
-
-	thread_harmless_end();
-	thread_idle_end();
-
-	if (sleeping_thread_mask & tid_bit)
-		_HA_ATOMIC_AND(&sleeping_thread_mask, ~tid_bit);
+	fd_leaving_poll(delta_ms, status);
 
 	if (status <= 0)
 		return;
diff --git a/src/fd.c b/src/fd.c
index 99c8c4e..5dd648e 100644
--- a/src/fd.c
+++ b/src/fd.c
@@ -759,6 +759,21 @@
 	return wait_time;
 }
 
+/* Handle the return of the poller, which consists in calculating the idle
+ * time, saving a few clocks, marking the thread harmful again etc. All that
+ * is some boring stuff that all pollers have to do anyway.
+ */
+void fd_leaving_poll(int wait_time, int status)
+{
+	clock_leaving_poll(wait_time, status);
+
+	thread_harmless_end();
+	thread_idle_end();
+
+	if (sleeping_thread_mask & tid_bit)
+		_HA_ATOMIC_AND(&sleeping_thread_mask, ~tid_bit);
+}
+
 /* disable the specified poller */
 void disable_poller(const char *poller_name)
 {