Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dlt-receive: Synchronize file's in-core state with storage device #600

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/console/dlt-receive.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
#include "dlt-control-common.h"

#define DLT_RECEIVE_ECU_ID "RECV"
#define FSYNC_BYTE_THRESHOLD (1000 * 1000)

DltClient dltclient;

Expand Down Expand Up @@ -641,6 +642,7 @@ int dlt_receive_message_callback(DltMessage *message, void *data)
{
DltReceiveData *dltdata;
static char text[DLT_RECEIVE_BUFSIZE];
static uint32_t bytes_since_last_fsync = 0;

struct iovec iov[2];
int bytes_written;
Expand Down Expand Up @@ -711,11 +713,20 @@ int dlt_receive_message_callback(DltMessage *message, void *data)
bytes_written = (int)writev(dltdata->ohandle, iov, 2);

dltdata->totalbytes += bytes_written;
bytes_since_last_fsync += bytes_written;

if (0 > bytes_written) {
printf("dlt_receive_message_callback: writev(dltdata->ohandle, iov, 2); returned an error!");
return -1;
}
else if (bytes_since_last_fsync >= FSYNC_BYTE_THRESHOLD) {
if (fsync(dltdata->ohandle) < 0) {
printf("dlt_receive_message_callback: fsync failed!");
}
else {
bytes_since_last_fsync = 0;
}
}
}
}

Expand Down
Loading