]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DOC: fd: make it clear that some fields ordering must absolutely be respected
authorWilly Tarreau <w@1wt.eu>
Wed, 17 Jun 2020 17:58:37 +0000 (19:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 17 Jun 2020 17:58:37 +0000 (19:58 +0200)
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.

include/haproxy/fd-t.h

index 1bffb26c4413e2105496007e86708872dd7b264f..5e17b6fe0e152fdb70c0c58d12776d275636787b 100644 (file)
@@ -116,6 +116,10 @@ struct fdlist {
 
 /* 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.
+ *
+ * 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 {
        unsigned long running_mask;          /* mask of thread IDs currently using the fd */