From: Sam H. v. a. <we...@ma...> - 2005-08-10 18:00:47
|
Log Message: ----------- make .def searching thread-safe (resolves bug #814). changed @found_set_defs to be a lexical local to get_set_defs(). replaced get_set_defs_wanted() with a closure over @found_set_defs defined in get_set_defs(). output is identical to the previous case, but no global(-ish) variables are used. Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator/Instructor: SetMaker.pm Revision Data ------------- Index: SetMaker.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v retrieving revision 1.48 retrieving revision 1.49 diff -Llib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm -Llib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm -u -r1.48 -r1.49 --- lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm +++ lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm @@ -144,21 +144,18 @@ ## Search for set definition files -# initialize global variable for search -my @found_set_defs = (); - -sub get_set_defs_wanted { - my $fn = $_; - my $fdir = $File::Find::dir; - return() if($fn !~ /^set.*\.def$/); - #return() if(not -T $fn); - push @found_set_defs, "$fdir/$fn"; -} - sub get_set_defs { my $topdir = shift; - @found_set_defs = (); - find({ wanted => \&get_set_defs_wanted, follow_fast=>1}, $topdir); + my @found_set_defs; + # get_set_defs_wanted is a closure over @found_set_defs + my $get_set_defs_wanted = sub { + my $fn = $_; + my $fdir = $File::Find::dir; + return() if($fn !~ /^set.*\.def$/); + #return() if(not -T $fn); + push @found_set_defs, "$fdir/$fn"; + }; + find({ wanted => $get_set_defs_wanted, follow_fast=>1}, $topdir); map { $_ =~ s|^$topdir/?|| } @found_set_defs; return @found_set_defs; } |