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

Function maybe_send_keepalive

io.c:1453–1481  ·  view source on GitHub ↗

Older rsync versions used to send either a MSG_NOOP (protocol 30) or a * raw-data-based keep-alive (protocol 29), both of which implied forwarding of * the message through the sender. Since the new timeout method does not need * any forwarding, we just send an empty MSG_DATA message, which works with all * rsync versions. This avoids any message forwarding, and leaves the raw-data * stream

Source from the content-addressed store, hash-verified

1451 * stream alone (since we can never be quite sure if that stream is in the
1452 * right state for a keep-alive message). */
1453void maybe_send_keepalive(time_t now, int flags)
1454{
1455 if (flags & MSK_ACTIVE_RECEIVER)
1456 last_io_in = now; /* Fudge things when we're working hard on the files. */
1457
1458 /* Early in the transfer (before the receiver forks) the receiving side doesn't
1459 * care if it hasn't sent data in a while as long as it is receiving data (in
1460 * fact, a pre-3.1.0 rsync would die if we tried to send it a keep alive during
1461 * this time). So, if we're an early-receiving proc, just return and let the
1462 * incoming data determine if we timeout. */
1463 if (!am_sender && !am_receiver && !am_generator)
1464 return;
1465
1466 if (now - last_io_out >= allowed_lull) {
1467 /* The receiver is special: it only sends keep-alive messages if it is
1468 * actively receiving data. Otherwise, it lets the generator timeout. */
1469 if (am_receiver && now - last_io_in >= io_timeout)
1470 return;
1471
1472 if (!iobuf.msg.len && iobuf.out.len == iobuf.out_empty_len)
1473 send_msg(MSG_DATA, "", 0, 0);
1474 if (!(flags & MSK_ALLOW_FLUSH)) {
1475 /* Let the caller worry about writing out the data. */
1476 } else if (iobuf.msg.len)
1477 perform_io(iobuf.msg.size - iobuf.msg.len + 1, PIO_NEED_MSGROOM);
1478 else if (iobuf.out.len > iobuf.out_empty_len)
1479 io_flush(NORMAL_FLUSH);
1480 }
1481}
1482
1483void start_flist_forward(int ndx)
1484{

Callers 10

receive_sumsFunction · 0.85
check_timeoutFunction · 0.85
safe_writeFunction · 0.85
perform_ioFunction · 0.85
read_a_msgFunction · 0.85
read_ndx_and_attrsFunction · 0.85
delete_in_dirFunction · 0.85
touch_up_dirsFunction · 0.85
generate_filesFunction · 0.85
receive_dataFunction · 0.85

Calls 3

send_msgFunction · 0.85
perform_ioFunction · 0.85
io_flushFunction · 0.85

Tested by

no test coverage detected