X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Ftracefile-array.h;h=09c425fad43267f96e40b30063e28ebdf95159df;hp=9158f4fe40c3c16bd5446ea811cc44cef379b966;hb=9a9c8637bbfb1b12b8302e03d5bc0453672b4d06;hpb=a44ca2ca85e4b64729f7b88b1919fd6737dfff8a diff --git a/src/bin/lttng-relayd/tracefile-array.h b/src/bin/lttng-relayd/tracefile-array.h index 9158f4fe4..09c425fad 100644 --- a/src/bin/lttng-relayd/tracefile-array.h +++ b/src/bin/lttng-relayd/tracefile-array.h @@ -2,20 +2,10 @@ #define _TRACEFILE_ARRAY_H /* - * Copyright (C) 2015 - Mathieu Desnoyers + * Copyright (C) 2015 Mathieu Desnoyers * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License, version 2 only, as - * published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include @@ -29,15 +19,30 @@ struct tracefile { uint64_t seq_tail; /* Oldest seqcount. Inclusive. */ }; +enum tracefile_rotate_type { + TRACEFILE_ROTATE_READ, + TRACEFILE_ROTATE_WRITE, +}; + /* * Represents an array of trace files in a stream. + * head is the most recent file/trace packet. + * tail is the oldest file/trace packet. + * + * There are two heads: a "read" head and a "write" head. The "write" head is + * the position of the newest data file. The "read" head position is only moved + * forward when the index is received. + * + * The viewer uses the "read" head position as upper bound, which + * ensures it never attempts to open a non-existing index file. */ struct tracefile_array { struct tracefile *tf; size_t count; /* Current head/tail files. */ - uint64_t file_head; + uint64_t file_head_read; + uint64_t file_head_write; uint64_t file_tail; /* Overall head/tail seq for the entire array. Inclusive. */ @@ -48,10 +53,12 @@ struct tracefile_array { struct tracefile_array *tracefile_array_create(size_t count); void tracefile_array_destroy(struct tracefile_array *tfa); -void tracefile_array_file_rotate(struct tracefile_array *tfa); -void tracefile_array_commit_seq(struct tracefile_array *tfa); +void tracefile_array_file_rotate(struct tracefile_array *tfa, enum tracefile_rotate_type type); +void tracefile_array_commit_seq(struct tracefile_array *tfa, + uint64_t new_seq_head); +void tracefile_array_reset(struct tracefile_array *tfa); -uint64_t tracefile_array_get_file_index_head(struct tracefile_array *tfa); +uint64_t tracefile_array_get_read_file_index_head(struct tracefile_array *tfa); /* May return -1ULL in the case where we have not received any indexes yet. */ uint64_t tracefile_array_get_seq_head(struct tracefile_array *tfa);