Skip to content

Commit

Permalink
logger: log write file allow single retry on write failure
Browse files Browse the repository at this point in the history
  • Loading branch information
dagar authored and LorenzMeier committed Nov 13, 2021
1 parent 333629c commit 177fe4b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/modules/logger/log_writer_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ void LogWriterFile::run()
}

int poll_count = 0;
int written = 0;
hrt_abstime last_fsync = hrt_absolute_time();

pthread_mutex_lock(&_mtx);
Expand Down Expand Up @@ -420,7 +419,14 @@ void LogWriterFile::run()

#endif

written = buffer.write_to_file(read_ptr, available, call_fsync);
int written = buffer.write_to_file(read_ptr, available, call_fsync);

if (written < 0) {
// retry once
PX4_ERR("write failed errno:%i (%s), retrying", errno, strerror(errno));
px4_usleep(10000); // 10 milliseconds
written = buffer.write_to_file(read_ptr, available, call_fsync);
}

/* buffer.mark_read() requires _mtx to be locked */
pthread_mutex_lock(&_mtx);
Expand Down

0 comments on commit 177fe4b

Please sign in to comment.