MEDIUM: fd: Introduce a running mask, and use it instead of the spinlock.
In the struct fdtab, introduce a new mask, running_mask. Each thread should
add its bit before using the fd.
Use the running_mask instead of a lock, in fd_insert/fd_delete, we'll just
spin as long as the mask is non-zero, to be sure we access the data
exclusively.
fd_set_running_excl() spins until the mask is 0, fd_set_running() just
adds the thread bit, and fd_clr_running() removes it.
diff --git a/include/types/fd.h b/include/types/fd.h
index e62e2a4..b4535af 100644
--- a/include/types/fd.h
+++ b/include/types/fd.h
@@ -118,8 +118,8 @@
/* info about one given fd */
struct fdtab {
- __decl_hathreads(HA_SPINLOCK_T lock);
- unsigned long thread_mask; /* mask of thread IDs authorized to process the task */
+ unsigned long running_mask; /* mask of thread IDs currntly using the fd */
+ unsigned long thread_mask; /* mask of thread IDs authorized to process the fd */
unsigned long update_mask; /* mask of thread IDs having an update for fd */
struct fdlist_entry update; /* Entry in the global update list */
void (*iocb)(int fd); /* I/O handler */