File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 88
88
#include "dlt-control-common.h"
89
89
90
90
#define DLT_RECEIVE_ECU_ID "RECV"
91
+ #define FSYNC_BYTE_THRESHOLD (1000 * 1000)
91
92
92
93
DltClient dltclient ;
93
94
@@ -641,6 +642,7 @@ int dlt_receive_message_callback(DltMessage *message, void *data)
641
642
{
642
643
DltReceiveData * dltdata ;
643
644
static char text [DLT_RECEIVE_BUFSIZE ];
645
+ static uint32_t bytes_since_last_fsync = 0 ;
644
646
645
647
struct iovec iov [2 ];
646
648
int bytes_written ;
@@ -711,11 +713,20 @@ int dlt_receive_message_callback(DltMessage *message, void *data)
711
713
bytes_written = (int )writev (dltdata -> ohandle , iov , 2 );
712
714
713
715
dltdata -> totalbytes += bytes_written ;
716
+ bytes_since_last_fsync += bytes_written ;
714
717
715
718
if (0 > bytes_written ) {
716
719
printf ("dlt_receive_message_callback: writev(dltdata->ohandle, iov, 2); returned an error!" );
717
720
return -1 ;
718
721
}
722
+ else if (bytes_since_last_fsync >= FSYNC_BYTE_THRESHOLD ) {
723
+ if (fsync (dltdata -> ohandle ) < 0 ) {
724
+ printf ("dlt_receive_message_callback: fsync failed!" );
725
+ }
726
+ else {
727
+ bytes_since_last_fsync = 0 ;
728
+ }
729
+ }
719
730
}
720
731
}
721
732
You can’t perform that action at this time.
0 commit comments