- DBG("writing full subbuffer (%ld) with valid_length = %ld", i_subbuf, valid_length);
- }
- else {
- /* If the subbuffer was not fully written, then we don't check data_size because
- * it hasn't been written yet. Instead we check commit_seq and use it to choose
- * a value for data_size. The viewer will need this value when parsing.
+ DBG("writing full subbuffer (%ld) with valid_length = %ld",
+ SUBBUF_INDEX(cons_off, buf), valid_length);
+ } else {
+ /*
+ * If the subbuffer was not fully written, then we don't
+ * check data_size because it hasn't been written yet.
+ * Instead we check commit_seq and use it to choose a
+ * value for data_size. The viewer will need this value
+ * when parsing. Generally, this will happen only for
+ * the last subbuffer. However, if we have threads still
+ * holding reserved slots in the previous subbuffers,
+ * which could happen for other subbuffers prior to the
+ * last one. Note that when data_size is set, the
+ * commit_seq count is still at a value that shows the
+ * amount of valid data to read. It's only _after_
+ * writing data_size that commit_seq is updated to
+ * include the end-of-buffer padding.