MCPcopy Create free account
hub / github.com/RsyncProject/rsync / handle_stats

Function handle_stats

main.c:325–385  ·  view source on GitHub ↗

This function gets called from all 3 processes. We want the client side * to actually output the text, but the sender is the only process that has * all the stats we need. So, if we're a client sender, we do the report. * If we're a server sender, we write the stats on the supplied fd. If * we're the client receiver we read the stats from the supplied fd and do * the report. All processes

Source from the content-addressed store, hash-verified

323 * the verbose level is high enough (this is the only thing that the
324 * generator process and the server receiver ever do here). */
325static void handle_stats(int f)
326{
327 endtime = time(NULL);
328
329 /* Cache two stats because the read/write code can change it. */
330 total_read = stats.total_read;
331 total_written = stats.total_written;
332
333 if (INFO_GTE(STATS, 3)) {
334 /* These come out from every process */
335 show_malloc_stats();
336 show_flist_stats();
337 }
338
339 if (am_generator)
340 return;
341
342 if (am_daemon) {
343 if (f == -1 || !am_sender)
344 return;
345 }
346
347 if (am_server) {
348 if (am_sender) {
349 write_varlong30(f, total_read, 3);
350 write_varlong30(f, total_written, 3);
351 write_varlong30(f, stats.total_size, 3);
352 if (protocol_version >= 29) {
353 write_varlong30(f, stats.flist_buildtime, 3);
354 write_varlong30(f, stats.flist_xfertime, 3);
355 }
356 }
357 return;
358 }
359
360 /* this is the client */
361
362 if (f < 0 && !am_sender) /* e.g. when we got an empty file list. */
363 ;
364 else if (!am_sender) {
365 /* Read the first two in opposite order because the meaning of
366 * read/write swaps when switching from sender to receiver. */
367 total_written = read_varlong30(f, 3);
368 total_read = read_varlong30(f, 3);
369 stats.total_size = read_varlong30(f, 3);
370 if (protocol_version >= 29) {
371 stats.flist_buildtime = read_varlong30(f, 3);
372 stats.flist_xfertime = read_varlong30(f, 3);
373 }
374 } else if (write_batch) {
375 /* The --read-batch process is going to be a client
376 * receiver, so we need to give it the stats. */
377 write_varlong30(batch_fd, total_read, 3);
378 write_varlong30(batch_fd, total_written, 3);
379 write_varlong30(batch_fd, stats.total_size, 3);
380 if (protocol_version >= 29) {
381 write_varlong30(batch_fd, stats.flist_buildtime, 3);
382 write_varlong30(batch_fd, stats.flist_xfertime, 3);

Callers 3

do_server_senderFunction · 0.85
do_recvFunction · 0.85
client_runFunction · 0.85

Calls 4

show_malloc_statsFunction · 0.85
show_flist_statsFunction · 0.85
write_varlong30Function · 0.85
read_varlong30Function · 0.85

Tested by

no test coverage detected