Handle the flush of the last subbuffer
Currently, when doing lttng stop, we use the SWITCH_ACTIVE flag of the flush command to finalize the current subbuffer and prepare a new one, so when we do the destroy command, we always flush a subbuffer that contains only the headers (no data).
The reason for this is that we absolutely want to know the duration of the trace capture, so we can then reliably use the packet-intersect feature in the trace readers.
The only case where creating a new empty packet is required is when we recorded no new event since the last packet was completed and the stop command. Not creating a new packet on stop would then result in a trace that seems to have been recording up to the last event event though the trace was still active for some time after this event (but no events were generated).
The drawback of always creating a new packet on stop, is on architectures with big pages (ex: ppc with 64k pages) when running in tracefile rotation, because a big page of zeros can trigger the tracefile rotation more easily and overwrite useful data.
So we would need to create a new flush mode to only create a new packet if at the time we have no currently opened packet (the last packet has been closed and no new events have been recorded since so we don't have a current packet initialized).
In this particular case, we would create and immediately close a new packet to make sure we have the real duration of the session.
In addition, this would remove the timestamp of the destroy command from the trace, we would only have the timestamp of the stop command which is more accurate for the packet-intersect feature.
No data to display