@@ -354,9 +354,11 @@ void ha_thread_dump_one(int thr, int from_signal)
354354 * current thread or if thread dump signals are not implemented, or by sending
355355 * a signal if it's a remote one and the feature is supported. The buffer <buf>
356356 * will get the dump appended, and the caller is responsible for making sure
357- * there is enough room otherwise some contents will be truncated.
357+ * there is enough room otherwise some contents will be truncated. The function
358+ * waits for the called thread to fill the buffer before returning. It does not
359+ * release the called thread yet.
358360 */
359- void ha_thread_dump (struct buffer * buf , int thr )
361+ void ha_thread_dump_fill (struct buffer * buf , int thr )
360362{
361363 struct buffer * old = NULL ;
362364
@@ -379,14 +381,37 @@ void ha_thread_dump(struct buffer *buf, int thr)
379381#endif
380382 ha_thread_dump_one (thr , thr != tid );
381383
384+ /* now wait for the dump to be done */
385+ while (HA_ATOMIC_LOAD (& ha_thread_ctx [thr ].thread_dump_buffer ) != (void * )0x1UL )
386+ ha_thread_relax ();
387+ }
388+
389+ /* Indicates to the called thread that the dumped data are collected. It waits
390+ * for the dump to be completed if it was not the case.
391+ */
392+ void ha_thread_dump_done (struct buffer * buf , int thr )
393+ {
394+ struct buffer * old ;
395+
382396 /* now wait for the dump to be done, and release it */
383397 do {
384- if (old )
398+ old = HA_ATOMIC_LOAD (& ha_thread_ctx [thr ].thread_dump_buffer );
399+ if (old != (void * )0x1UL ) {
385400 ha_thread_relax ();
386- old = (void * )0x01 ;
401+ continue ;
402+ }
387403 } while (!HA_ATOMIC_CAS (& ha_thread_ctx [thr ].thread_dump_buffer , & old , 0 ));
388404}
389405
406+ /* performs a complete thread dump: calls the remote thread and marks the
407+ * buffer as read.
408+ */
409+ void ha_thread_dump (struct buffer * buf , int thr )
410+ {
411+ ha_thread_dump_fill (buf , thr );
412+ ha_thread_dump_done (buf , thr );
413+ }
414+
390415/* dumps into the buffer some information related to task <task> (which may
391416 * either be a task or a tasklet, and prepend each line except the first one
392417 * with <pfx>. The buffer is only appended and the first output starts by the
0 commit comments