]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: debug: make ha_thread_dump_done() take the pointer to be used
authorWilly Tarreau <w@1wt.eu>
Sat, 19 Oct 2024 12:52:35 +0000 (14:52 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 19 Oct 2024 13:42:07 +0000 (15:42 +0200)
This will allow the caller to decide whether to definitely clear the
pointer and release the thread, or to leave it unlocked so that it's
easy to analyse from the struct (the goal will be to use that in panic()
so that cores are easy to analyse).

src/debug.c

index 0f97759232d8b1f60c5e341f2d54380ba76b21f1..55b1744baec57699b477db80234c404532304bfe 100644 (file)
@@ -395,9 +395,10 @@ struct buffer *ha_thread_dump_fill(struct buffer *buf, int thr)
        return (struct buffer *)((ulong)old & ~0x1UL);
 }
 
-/* Indicates to the called thread that the dumped data are collected. It waits
- * for the dump to be completed if it was not the case, and can also leave if
- * the pointer is NULL (e.g. if a thread has aborted).
+/* Indicates to the called thread that the dumped data are collected by writing
+ * <buf> into the designated thread's dump buffer (usually buf is NULL). It
+ * waits for the dump to be completed if it was not the case, and can also
+ * leave if the pointer is NULL (e.g. if a thread has aborted).
  */
 void ha_thread_dump_done(struct buffer *buf, int thr)
 {
@@ -412,7 +413,7 @@ void ha_thread_dump_done(struct buffer *buf, int thr)
                        ha_thread_relax();
                        continue;
                }
-       } while (!HA_ATOMIC_CAS(&ha_thread_ctx[thr].thread_dump_buffer, &old, 0));
+       } while (!HA_ATOMIC_CAS(&ha_thread_ctx[thr].thread_dump_buffer, &old, buf));
 }
 
 /* performs a complete thread dump: calls the remote thread and marks the
@@ -421,7 +422,7 @@ void ha_thread_dump_done(struct buffer *buf, int thr)
 void ha_thread_dump(struct buffer *buf, int thr)
 {
        ha_thread_dump_fill(buf, thr);
-       ha_thread_dump_done(buf, thr);
+       ha_thread_dump_done(NULL, thr);
 }
 
 /* dumps into the buffer some information related to task <task> (which may