[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mv fails with "Too many open files" when moving _many_ files
From: |
Jim Meyering |
Subject: |
Re: mv fails with "Too many open files" when moving _many_ files |
Date: |
Thu, 21 Oct 2004 12:41:39 +0200 |
My patch of Monday (2004-10-18) was wrong.
Here's a fix that introduces fewer bugs.
I've added a test for the cross-partition mv failure
and another that makes rm fail with Monday's patch.
2004-10-21 Jim Meyering <address@hidden>
* tests/mv/leak-fd: New file.
* tests/mv/Makefile.am (TESTS): Add it.
* tests/rm/dot-rel: New file.
* tests/rm/Makefile.am (TESTS): Add it.
Correct my patch of 2004-10-18.
* src/remove.c (rm): Destroy the saved_cwd here (via cwd_state),
if necessary, not in remove_dir. Otherwise, removing multiple
`.'-relative nonempty directories no longer worked.
This highlights some minor duplication in the current code:
Since the changes of 2004-05-22, the u.saved_cwd member at
the bottom of the active-directory stack was no longer
strictly necessary. An upcoming change will remove that member.
Index: src/remove.c
===================================================================
RCS file: /fetish/cu/src/remove.c,v
retrieving revision 1.117
diff -u -p -r1.117 remove.c
--- src/remove.c 18 Oct 2004 08:59:12 -0000 1.117
+++ src/remove.c 21 Oct 2004 10:11:37 -0000
@@ -1151,10 +1151,7 @@ remove_dir (Dirstack_state *ds, char con
free (empty_dir);
if (AD_stack_height (ds) == 1)
- {
- free_cwd (&AD_stack_top(ds)->u.saved_cwd);
- break;
- }
+ break;
}
}
@@ -1235,6 +1232,9 @@ rm (size_t n_files, char const *const *f
ds_free (ds);
+ if (cwd_state && cwd_state->saved_errno == 0)
+ free_cwd (&cwd_state->saved_cwd);
+
free (cwd_state);
return status;