Commit 07f06f8c authored by Robert Schmidt's avatar Robert Schmidt

nrMAC_stats.log: handle file errors, add truncate to reset file

truncate resets the file size to 0. Without this, e.g., when
disconnecting a UE, the old UE remains at the end and is not
overwritten, which is confusing.
parent 7e8245c4
......@@ -97,10 +97,16 @@ void *nrmac_stats_thread(void *arg) {
p += print_meas_log(&gNB->nr_srs_ri_computation_timer, "UL-RI computation time", NULL, NULL, p, end - p);
p += print_meas_log(&gNB->nr_srs_tpmi_computation_timer, "UL-TPMI computation time", NULL, NULL, p, end - p);
NR_SCHED_UNLOCK(&gNB->sched_lock);
fwrite(output, p - output, 1, file);
fflush(file);
size_t len = p - output;
if (fwrite(output, len, 1, file) != 1 || fflush(file) != 0) {
LOG_E(NR_MAC, "error while writing nrMAC_stats.log: %d, %s\n", errno, strerror(errno));
break;
}
sleep(1);
fseek(file,0,SEEK_SET);
if (ftruncate(fileno(file), 0) != 0 || fseek(file, 0, SEEK_SET) != 0) {
LOG_E(NR_MAC, "error while writing nrMAC_stats.log: %d, %s\n", errno, strerror(errno));
break;
}
}
fclose(file);
return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment