Fixed get_xattr_acl() -- it needed to zero *len_p.
[rsync/rsync.git] / flist.c
diff --git a/flist.c b/flist.c
index 733344c..4d81f15 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -65,6 +65,9 @@ extern int protocol_version;
 extern int sanitize_paths;
 extern struct stats stats;
 extern char *filesfrom_host;
+#ifdef ICONV_OPTION
+extern char *iconv_opt;
+#endif
 
 extern char curr_dir[MAXPATHLEN];
 
@@ -1654,19 +1657,17 @@ void send_extra_file_list(int f, int at_least)
        struct file_list *flist;
        int64 start_write;
        uint16 prev_flags;
-       int future_cnt, save_io_error = io_error;
+       int old_cnt, save_io_error = io_error;
 
        if (flist_eof)
                return;
 
        /* Keep sending data until we have the requested number of
         * files in the upcoming file-lists. */
-       if (cur_flist->next) {
-               flist = first_flist->prev; /* the newest flist */
-               future_cnt = flist->ndx_end - cur_flist->next->ndx_start + 1;
-       } else
-               future_cnt = 0;
-       while (future_cnt < at_least) {
+       old_cnt = cur_flist->used;
+       for (flist = first_flist; flist != cur_flist; flist = flist->next)
+               old_cnt += flist->used;
+       while (file_total - old_cnt < at_least) {
                struct file_struct *file = dir_flist->sorted[send_dir_ndx];
                int dir_ndx, dstart = dir_count;
                const char *pathname = F_PATHNAME(file);
@@ -1717,14 +1718,16 @@ void send_extra_file_list(int f, int at_least)
 
                clean_flist(flist, 0);
 
-               flist->ndx_end = flist->ndx_start + flist->used - 1
-                              - (dir_count - dstart);
+               flist->ndx_end = flist->ndx_start + flist->used - 1;
+#ifdef ICONV_OPTION
+               if (!iconv_opt)
+#endif
+                       flist->ndx_end -= (dir_count - dstart);
 
                add_dirs_to_tree(send_dir_ndx, flist, dir_count - dstart);
                flist_done_allocating(flist);
 
                file_total += flist->used;
-               future_cnt += flist->used;
                stats.flist_size += stats.total_written - start_write;
                stats.num_files += flist->used;
                if (verbose > 3)
@@ -2140,7 +2143,11 @@ struct file_list *recv_file_list(int f)
        file_total += flist->used;
 
        flist->ndx_end = flist->ndx_start + flist->used - 1;
-       if (inc_recurse && flist->ndx_start > 1)
+       if (inc_recurse
+#ifdef ICONV_OPTION
+        && !iconv_opt
+#endif
+        && flist->ndx_start > 1)
                flist->ndx_end -= dir_flist->used - dstart;
 
        if (verbose > 2)
@@ -2323,7 +2330,7 @@ struct file_list *flist_new(int flags, char *msg)
                        if (!flist->file_pool)
                                out_of_memory(msg);
 
-                       flist->ndx_start = 1;
+                       flist->ndx_start = inc_recurse ? 1 : 0;
 
                        first_flist = cur_flist = flist->prev = flist;
                } else {
@@ -2563,7 +2570,7 @@ static void output_flist(struct file_list *flist)
        rprintf(FINFO, "[%s] flist start=%d, end=%d, used=%d, low=%d, high=%d\n",
                who, flist->ndx_start, flist->ndx_end, flist->used, flist->low, flist->high);
        for (i = 0; i < flist->used; i++) {
-               file = flist->sorted[i];
+               file = flist->files[i];
                if ((am_root || am_sender) && uid_ndx) {
                        snprintf(uidbuf, sizeof uidbuf, " uid=%u",
                                 F_OWNER(file));