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
| 1451 | * stream alone (since we can never be quite sure if that stream is in the |
| 1452 | * right state for a keep-alive message). */ |
| 1453 | void 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 | |
| 1483 | void start_flist_forward(int ndx) |
| 1484 | { |
no test coverage detected