Fixed hang when --hard-links was processing a large directory
authorWayne Davison <wayned@samba.org>
Sat, 3 Nov 2007 15:27:14 +0000 (15:27 +0000)
committerWayne Davison <wayned@samba.org>
Sat, 3 Nov 2007 15:27:14 +0000 (15:27 +0000)
hierarchy with no files.

generator.c

index db0824d..24435ea 100644 (file)
@@ -2027,8 +2027,14 @@ void generate_files(int f_out, const char *local_name)
        do {
 #ifdef SUPPORT_HARD_LINKS
                if (preserve_hard_links && inc_recurse) {
-                       while (!flist_eof && file_total < FILECNT_LOOKAHEAD/2)
+                       while (!flist_eof) {
+                               int cnt = first_flist->prev
+                                       ? first_flist->prev->ndx_end - first_flist->ndx_start + 1
+                                       : first_flist->ndx_end - first_flist->ndx_start + 1;
+                               if (cnt >= FILECNT_LOOKAHEAD/2)
+                                       break;
                                wait_for_receiver();
+                       }
                }
 #endif