MINOR: threads/fd: Use a bitfield to know if there are FDs for a thread in the FD cache

A bitfield has been added to know if there are some FDs processable by a
specific thread in the FD cache. When a FD is inserted in the FD cache, the bits
corresponding to its thread_mask are set. On each thread, the bitfield is
updated when the FD cache is processed. If there is no FD processed, the thread
is removed from the bitfield by unsetting its tid_bit.

Note that this bitfield is updated but not checked in
fd_process_cached_events. So, when this function is called, the FDs cache is
always processed.

[wt: should be backported to 1.8 as it will help fix a design limitation]
diff --git a/include/proto/fd.h b/include/proto/fd.h
index 8cc191f..44370e7 100644
--- a/include/proto/fd.h
+++ b/include/proto/fd.h
@@ -35,6 +35,7 @@
 
 extern unsigned int *fd_cache;      // FD events cache
 extern int fd_cache_num;            // number of events in the cache
+extern unsigned long fd_cache_mask; // Mask of threads with events in the cache
 
 extern THREAD_LOCAL int *fd_updt;  // FD updates list
 extern THREAD_LOCAL int fd_nbupdt; // number of updates in the list
@@ -115,6 +116,7 @@
 	if (fdtab[fd].cache)
 		goto end;
 	fd_cache_num++;
+	fd_cache_mask |= fdtab[fd].thread_mask;
 	fdtab[fd].cache = fd_cache_num;
 	fd_cache[fd_cache_num-1] = fd;
   end: