------------------------------------------------------------------------- RecSyncStatsFile -------------------------------------------------------------------------
| 328 | // RecSyncStatsFile |
| 329 | //------------------------------------------------------------------------- |
| 330 | RecErrT |
| 331 | RecSyncStatsFile() |
| 332 | { |
| 333 | RecRecord *r; |
| 334 | RecMessage *m; |
| 335 | int i, num_records; |
| 336 | bool sync_to_disk; |
| 337 | ats_scoped_str snap_fpath(RecConfigReadPersistentStatsPath()); |
| 338 | |
| 339 | m = RecMessageAlloc(RECG_NULL); |
| 340 | num_records = g_num_records; |
| 341 | sync_to_disk = false; |
| 342 | for (i = 0; i < num_records; i++) { |
| 343 | r = &(g_records[i]); |
| 344 | rec_mutex_acquire(&(r->lock)); |
| 345 | if (REC_TYPE_IS_STAT(r->rec_type)) { |
| 346 | if (r->stat_meta.persist_type == RECP_PERSISTENT) { |
| 347 | m = RecMessageMarshal_Realloc(m, r); |
| 348 | sync_to_disk = true; |
| 349 | } |
| 350 | } |
| 351 | rec_mutex_release(&(r->lock)); |
| 352 | } |
| 353 | if (sync_to_disk) { |
| 354 | RecDebug(DL_Note, "Writing '%s' [%d bytes]", (const char *)snap_fpath, m->o_write - m->o_start + sizeof(RecMessageHdr)); |
| 355 | RecMessageWriteToDisk(m, snap_fpath); |
| 356 | } |
| 357 | RecMessageFree(m); |
| 358 | |
| 359 | return REC_ERR_OKAY; |
| 360 | } |
| 361 | |
| 362 | // Consume a parsed record, pushing it into the records hash table. |
| 363 | static void |
no test coverage detected