Skip to content
Snippets Groups Projects
Commit 4fc1c5c4 authored by Beat Küng's avatar Beat Küng
Browse files

LogWriterFile: split long header messages that exceed the buffer length

Some message formats are longer than the 300 bytes. We can split the writes
because we have to wait until they are written anyway.
parent 28ac7679
No related branches found
No related tags found
No related merge requests found
......@@ -293,13 +293,33 @@ int LogWriterFile::write_message(LogType type, void *ptr, size_t size, uint64_t
if (_need_reliable_transfer) {
int ret;
while ((ret = write(type, ptr, size, dropout_start)) == -1) {
unlock();
notify();
usleep(3000);
lock();
// if there's a dropout, write it first (because we might split the message)
if (dropout_start) {
while ((ret = write(type, ptr, 0, dropout_start)) == -1) {
unlock();
notify();
usleep(3000);
lock();
}
}
uint8_t *uptr = (uint8_t *)ptr;
do {
// Split into several blocks if the data is longer than the write buffer
size_t write_size = math::min(size, _buffers[(int)type].buffer_size());
while ((ret = write(type, uptr, write_size, 0)) == -1) {
unlock();
notify();
usleep(3000);
lock();
}
uptr += write_size;
size -= write_size;
} while (size > 0);
return ret;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment