ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/bin/treescan
(Generate patch)

Comparing IO-AIO/bin/treescan (file contents):
Revision 1.19 by root, Fri Aug 23 07:20:21 2019 UTC vs.
Revision 1.20 by root, Tue Dec 29 15:16:28 2020 UTC

131 ); 131 );
132} 132}
133 133
134@ARGV = "." unless @ARGV; 134@ARGV = "." unless @ARGV;
135 135
136my @todo; # list of dirs/files still left to scan
137
136$opt_grep &&= qr{$opt_grep}s; 138$opt_grep &&= qr{$opt_grep}s;
137 139
138my ($n_dirs, $n_files, $n_stats) = (0, 0, 0); 140my ($n_dirs, $n_files, $n_stats) = (0, 0, 0);
139my ($n_last, $n_start) = (Time::HiRes::time) x 2; 141my ($n_last, $n_start) = (Time::HiRes::time) x 2;
140 142
195 aio_pathsync [$wd, $_] for @$files; 197 aio_pathsync [$wd, $_] for @$files;
196 aio_pathsync $wd; 198 aio_pathsync $wd;
197 }; 199 };
198 } 200 }
199 201
200 &scan ("$path$_") for @$dirs; 202 push @todo, "$path$_"
203 for sort { $b cmp $a } @$dirs;
201 }; 204 };
202} 205}
203 206
204IO::AIO::max_outstanding 100; # two fds per directory, so limit accordingly 207IO::AIO::max_outstanding 100; # two fds per directory, so limit accordingly
205IO::AIO::min_parallel 20; 208IO::AIO::min_parallel 20;
206 209
207for my $seed (@ARGV) { 210@todo = reverse @ARGV;
211
212while () {
213 if (@todo) {
214printf "(%d)",scalar @todo;$|=1;#d#
215 my $seed = pop @todo;
208 $seed =~ s/\/+$//; 216 $seed =~ s/\/+$//;
209 aio_lstat "$seed/.", sub { 217 aio_lstat "$seed/.", sub {
210 if ($_[0]) { 218 if ($_[0]) {
211 print STDERR "$seed: $!\n"; 219 print STDERR "$seed: $!\n";
212 } elsif (-d _) { 220 } elsif (-d _) {
213 scan $seed; 221 scan $seed;
214 } else { 222 } else {
215 printfn "", $seed, "/"; 223 printfn "", $seed, "/";
224 }
216 } 225 };
226 } else {
227print "w";$|=1;#d#
228 IO::AIO::poll_wait;
217 }; 229 }
218}
219 230
220IO::AIO::flush; 231 last unless IO::AIO::nreqs;
221 232
233 IO::AIO::poll_cb;
234}
235

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines