Calling kea-lfc on a CSV file without a trailing blank line makes it not process the last line
Replication steps:
printf address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_rev,hostname > kea-dhcp4.csv
kea-lfc -4 -c ignored-path -f kea-dhcp4.csv.completed -i kea-dhcp4.csv -o kea-dhcp4.csv.output -p kea-dhcp4.csv.pid -x kea-dhcp4.csv.2
You'll get no error, because kea-lfc
doesn't output anything outside of Kea, but notice there's no kea-dhcp4.csv.2
. There should be. kea-dhcp4.csv
is not removed. It should be.
What happens is line is not empty but EOF is set. Good flag is not set, so it enters the second branch below.
csv_file.cc:273
std::string line;
std::getline(*fs_, line);
// If we got empty line because we reached the end of file
// return an empty row.
if (line.empty() && fs_->eof()) {
row = EMPTY_ROW();
return (true);
} else if (!fs_->good()) {
// If we hit an IO error, communicate it to the caller but do NOT close
// the stream. Caller may try again.
setReadMsg("error reading a row from CSV file '"
+ std::string(filename_) + "'");
return (false);
}
It should be:
std::string line;
// Read the next non-empty line.
while (line.empty() && fs_->good()) {
std::getline(*fs_, line);
}
// If we reached the end of file, return an empty row.
if (fs_->eof()) {
row = EMPTY_ROW();
return (true);
...