MCPcopy Create free account
hub / github.com/apache/trafficserver / RecMessageReadFromDisk

Function RecMessageReadFromDisk

src/records/RecMessage.cc:247–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245//-------------------------------------------------------------------------
246
247RecMessage *
248RecMessageReadFromDisk(const char *fpath)
249{
250 RecMessageHdr msg_hdr;
251 RecMessage *msg = nullptr;
252 RecHandle h_file;
253 int bytes_read;
254
255 if ((h_file = RecFileOpenR(fpath)) == REC_HANDLE_INVALID) {
256 goto Lerror;
257 }
258 if (RecFileRead(h_file, reinterpret_cast<char *>(&msg_hdr), sizeof(RecMessageHdr), &bytes_read) == REC_ERR_FAIL) {
259 goto Lerror;
260 }
261 msg = static_cast<RecMessage *>(ats_malloc((msg_hdr.o_end - msg_hdr.o_start) + sizeof(RecMessageHdr)));
262 memcpy(msg, &msg_hdr, sizeof(RecMessageHdr));
263 if (RecSnapFileRead(h_file, reinterpret_cast<char *>(msg) + msg_hdr.o_start, msg_hdr.o_end - msg_hdr.o_start, &bytes_read) ==
264 REC_ERR_FAIL) {
265 goto Lerror;
266 }
267
268 goto Ldone;
269
270Lerror:
271 ats_free(msg);
272 msg = nullptr;
273
274Ldone:
275 if (h_file != REC_HANDLE_INVALID) {
276 RecFileClose(h_file);
277 }
278
279 return msg;
280}
281
282//-------------------------------------------------------------------------
283// RecMessageWriteToDisk

Callers 1

RecReadStatsFileFunction · 0.85

Calls 7

RecFileOpenRFunction · 0.85
RecFileReadFunction · 0.85
ats_mallocFunction · 0.85
RecSnapFileReadFunction · 0.85
ats_freeFunction · 0.85
RecFileCloseFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected