DOC: fd: make it clear that some fields ordering must absolutely be respected

fd_set_running() and fd_takeover() may both use a double-word CAS on the
(running_mask, thread_mask) couple and as such they expect the fields to
be exactly arranged like this. It's critical not to reorder them, so add
a comment to avoid such a potential mistake later.
This commit is contained in:
Willy Tarreau 2020-06-17 19:58:37 +02:00
parent 4f72ec851c
commit c208a54ab2

View File

@ -116,6 +116,10 @@ struct fdlist {
/* info about one given fd. Note: only align on cache lines when using threads; /* info about one given fd. Note: only align on cache lines when using threads;
* 32-bit small archs can put everything in 32-bytes when threads are disabled. * 32-bit small archs can put everything in 32-bytes when threads are disabled.
*
* NOTE: DO NOT REORDER THIS STRUCT AT ALL! Some code parts rely on exact field
* ordering, for example fd_takeover() and fd_set_running() want running_mask
* immediately followed by thread_mask to perform a double-word-CAS on them.
*/ */
struct fdtab { struct fdtab {
unsigned long running_mask; /* mask of thread IDs currently using the fd */ unsigned long running_mask; /* mask of thread IDs currently using the fd */