journal-gatewayd: fix handling of num_skip pointing beyond the last entry
When `num_skip` is supplied to the `Range` header, journal-gatewayd always returns the very last record even though it should have been skipped. This is because the `sd_journal_next_skip` always returns non-zero value on the first call, leading to one iteration of the `request_reader_entries` returning the last record. To avoid this unexpected behavior, check that the number of lines we have skipped by is not lower than the requested skip value. If it is, then it means there are lines which should not be returned now - decrement the n_skip counter then and return from the function, closing the stream if follow flag is not set. Fixes #37954
This commit is contained in:
@@ -82,6 +82,12 @@ timeout 5 curl -LSfs \
|
||||
--header "Range: entries=:-20:10" \
|
||||
http://localhost:19531/entries?follow >"$LOG_FILE"
|
||||
jq -se "length == 10" "$LOG_FILE"
|
||||
# Test positive skip beyond the last entry
|
||||
curl -LSfs \
|
||||
--header "Accept: application/json" \
|
||||
--header "Range: entries=$TEST_CURSOR:1:1" \
|
||||
http://localhost:19531/entries?SYSLOG_IDENTIFIER="$TEST_TAG" >"$LOG_FILE"
|
||||
jq -se "length == 0" "$LOG_FILE"
|
||||
# Check if the specified cursor refers to an existing entry and return just that entry
|
||||
curl -LSfs \
|
||||
--header "Accept: application/json" \
|
||||
|
||||
Reference in New Issue
Block a user