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

Method compute_signature

src/proxy/logging/LogObject.cc:277–302  ·  view source on GitHub ↗

we compute the object signature from the fieldlist_str and the printf_str of the LogFormat rather than from the format_str because the format_str is not part of a LogBuffer header

Source from the content-addressed store, hash-verified

275// is not part of a LogBuffer header
276//
277uint64_t
278LogObject::compute_signature(LogFormat *format, char *filename, unsigned int flags)
279{
280 std::string_view filename_sv{filename};
281 if (filename_sv == "stdout" || filename_sv == "stderr") {
282 return 0;
283 }
284 char *fl = format->fieldlist();
285 char *ps = format->printf_str();
286 uint64_t signature = 0;
287
288 if (fl && ps && filename) {
289 int buf_size = strlen(fl) + strlen(ps) + strlen(filename) + 2;
290 char *buffer = static_cast<char *>(ats_malloc(buf_size));
291
292 ink_string_concatenate_strings(buffer, fl, ps, filename,
293 flags & LogObject::BINARY ? "B" : (flags & LogObject::WRITES_TO_PIPE ? "P" : "A"), NULL);
294
295 CryptoHash hash;
296 CryptoContext().hash_immediate(hash, buffer, buf_size - 1);
297 signature = hash.fold();
298
299 ats_free(buffer);
300 }
301 return signature;
302}
303
304void
305LogObject::display(FILE *fd)

Callers

nothing calls this directly

Calls 7

ats_mallocFunction · 0.85
CryptoContextClass · 0.85
ats_freeFunction · 0.85
fieldlistMethod · 0.80
printf_strMethod · 0.80
hash_immediateMethod · 0.45

Tested by

no test coverage detected