mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-20 10:55:01 +00:00
Use glob instead of opendir and readdir.
This commit is contained in:
15
bin/pt-agent
15
bin/pt-agent
@@ -6503,16 +6503,11 @@ sub send_data {
|
|||||||
);
|
);
|
||||||
|
|
||||||
# Send data files in the service's spool dir.
|
# Send data files in the service's spool dir.
|
||||||
opendir(my $service_dh, $service_dir)
|
# Only iterator over data files because run_service() writes
|
||||||
or die "Error opening $service_dir: $OS_ERROR";
|
# them last to avoid a race condition with us. See the code
|
||||||
|
# comment about writing the .meta file first in run_service().
|
||||||
DATA_FILE:
|
DATA_FILE:
|
||||||
while ( my $file = readdir($service_dh) ) {
|
foreach my $data_file ( glob "$service_dir/*.data" ) {
|
||||||
# Only iterator over data files because run_service() writes
|
|
||||||
# them last to avoid a race condition with us. See the code
|
|
||||||
# comment about writing the .meta file first in run_service().
|
|
||||||
next unless $file =~ m/\.data$/;
|
|
||||||
|
|
||||||
my $data_file = "$service_dir/$file";
|
|
||||||
(my $meta_file = $data_file) =~ s/\.data/.meta/;
|
(my $meta_file = $data_file) =~ s/\.data/.meta/;
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
@@ -6553,8 +6548,6 @@ sub send_data {
|
|||||||
|
|
||||||
_info("Sent and removed $data_file");
|
_info("Sent and removed $data_file");
|
||||||
}
|
}
|
||||||
closedir $service_dh
|
|
||||||
or _warn("Error closing $service_dir: $OS_ERROR");
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user