MCPcopy Index your code
hub / github.com/RsyncProject/rsync / read_a_msg

Function read_a_msg

io.c:1495–1730  ·  view source on GitHub ↗

Read a message from a multiplexed source. */

Source from the content-addressed store, hash-verified

1493
1494/* Read a message from a multiplexed source. */
1495static void read_a_msg(void)
1496{
1497 char data[BIGPATHBUFLEN];
1498 int tag, val;
1499 size_t msg_bytes;
1500
1501 /* This ensures that perform_io() does not try to do any message reading
1502 * until we've read all of the data for this message. We should also
1503 * try to avoid calling things that will cause data to be written via
1504 * perform_io() prior to this being reset to 1. */
1505 iobuf.in_multiplexed = -1;
1506
1507 tag = raw_read_int();
1508
1509 msg_bytes = tag & 0xFFFFFF;
1510 tag = (tag >> 24) - MPLEX_BASE;
1511
1512 if (msgs2stderr == 1 && DEBUG_GTE(IO, 1)) {
1513 rprintf(FINFO, "[%s] got msg=%d, len=%" SIZE_T_FMT_MOD "d\n",
1514 who_am_i(), (int)tag, (SIZE_T_FMT_CAST)msg_bytes);
1515 }
1516
1517 switch (tag) {
1518 case MSG_DATA:
1519 assert(iobuf.raw_input_ends_before == 0);
1520 /* Though this does not yet read the data, we do mark where in
1521 * the buffer the msg data will end once it is read. It is
1522 * possible that this points off the end of the buffer, in
1523 * which case the gradual reading of the input stream will
1524 * cause this value to wrap around and eventually become real. */
1525 if (msg_bytes)
1526 iobuf.raw_input_ends_before = iobuf.in.pos + msg_bytes;
1527 iobuf.in_multiplexed = 1;
1528 break;
1529 case MSG_STATS:
1530 if (msg_bytes != sizeof stats.total_read || !am_generator)
1531 goto invalid_msg;
1532 raw_read_buf((char*)&stats.total_read, sizeof stats.total_read);
1533 iobuf.in_multiplexed = 1;
1534 break;
1535 case MSG_REDO:
1536 if (msg_bytes != 4 || !am_generator)
1537 goto invalid_msg;
1538 val = raw_read_int();
1539 iobuf.in_multiplexed = 1;
1540 got_flist_entry_status(FES_REDO, val);
1541 break;
1542 case MSG_IO_ERROR:
1543 if (msg_bytes != 4)
1544 goto invalid_msg;
1545 val = raw_read_int();
1546 iobuf.in_multiplexed = 1;
1547 io_error |= val;
1548 if (am_receiver)
1549 send_msg_int(MSG_IO_ERROR, val);
1550 break;
1551 case MSG_IO_TIMEOUT:
1552 if (msg_bytes != 4 || am_server || am_generator)

Callers 4

perform_ioFunction · 0.85
drain_multiplex_messagesFunction · 0.85
wait_for_receiverFunction · 0.85
read_bufFunction · 0.85

Calls 15

raw_read_intFunction · 0.85
raw_read_bufFunction · 0.85
got_flist_entry_statusFunction · 0.85
send_msg_intFunction · 0.85
set_io_timeoutFunction · 0.85
maybe_send_keepaliveFunction · 0.85
send_msgFunction · 0.85
iconvbufsFunction · 0.85
memmoveFunction · 0.85
log_deleteFunction · 0.85
IVALFunction · 0.85
successful_sendFunction · 0.85

Tested by

no test coverage detected