+ ndx = NDX_FLIST_OFFSET - ndx;
+ if (ndx < 0 || ndx >= dir_flist->used) {
+ ndx = NDX_FLIST_OFFSET - ndx;
+ rprintf(FERROR,
+ "[%s] Invalid dir index: %d (%d - %d)\n",
+ who_am_i(), ndx, NDX_FLIST_OFFSET,
+ NDX_FLIST_OFFSET - dir_flist->used + 1);
+ exit_cleanup(RERR_PROTOCOL);
+ }
+
+ /* Send everything read from f_in to msg_fd_out. */
+ if (verbose > 3) {
+ rprintf(FINFO, "[%s] receiving flist for dir %d\n",
+ who_am_i(), ndx);
+ }
+ verbose = 0;
+ send_msg_int(MSG_FLIST, ndx);
+ start_flist_forward(f_in);
+ flist = recv_file_list(f_in);
+ flist->parent_ndx = ndx;
+ stop_flist_forward();
+ verbose = save_verbose;
+ }
+
+ iflags = protocol_version >= 29 ? read_shortint(f_in)
+ : ITEM_TRANSFER | ITEM_MISSING_DATA;
+
+ /* Honor the old-style keep-alive indicator. */
+ if (protocol_version < 30
+ && ndx == cur_flist->used && iflags == ITEM_IS_NEW) {
+ if (am_sender)
+ maybe_send_keepalive();
+ goto read_loop;
+ }
+
+ if (!(flist = flist_for_ndx(ndx))) {
+ int start, used;
+ invalid_ndx:
+ start = first_flist ? first_flist->ndx_start : 0;
+ used = first_flist ? first_flist->used : 0;
+ rprintf(FERROR,
+ "Invalid file index: %d (%d - %d) with iflags %x [%s]\n",
+ ndx, start - 1, start + used -1, iflags, who_am_i());
+ exit_cleanup(RERR_PROTOCOL);
+ }
+ cur_flist = flist;
+
+ if (iflags & ITEM_BASIS_TYPE_FOLLOWS)
+ fnamecmp_type = read_byte(f_in);
+ *type_ptr = fnamecmp_type;