Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Preparing cache directory fails on multi process #103

Merged
merged 2 commits into from Jan 23, 2014

Conversation

Projects
None yet
2 participants
Contributor

hitode909 commented Jan 23, 2014

When other process creates cache directory between if(not -e $cachedir) { and mkpath, mkpath returns false and Xslate throws an exception.
I changed to check whether cachedir exists when mkpath returns false.

Test

https://github.com/hitode909/p5-Text-Xslate/blob/6100f3466408d683b6e299f2966b86d0eec5253b/t/900_bugs/041_cachedir_other_process.t

Result

before

% prove -v t/900_bugs/041_cachedir_other_process.t
[20:18:34] t/900_bugs/041_cachedir_other_process.t ..
ok 1 - cache directory does not exists
# waiting if(not -e $cachedir) {
# waiting child process
# mkpath on child process
ok 2 - cache_dir seems created on child process
# mkpath on parent pwaiting child process
Xslate: Cannot prepare cache directory .xslate_cache/t/900_bugs/041_cachedir_other_process.t/%2FUsers%2Fhitode909%2Fco%2Fp5-Text-Xslate%2Ft%2Fnr0qd_QVre/hello.txc (ignored):  at t/900_bugs/041_cachedir_other_process.t line 40
# Tests were run but no plan was declared and done_testing() was not seen.
Dubious, test returned 60 (wstat 15360, 0x3c00)
All 2 subtests passed
[20:18:34]

after

% prove -v t/900_bugs/041_cachedir_other_process.t
[20:19:03] t/900_bugs/041_cachedir_other_process.t ..
ok 1 - cache directory does not exists
# waiting if(not -e $cachedir) {
# waiting child process
# mkpath on child process
ok 2 - cache_dir seems created on child process
# mkpath on parent pwaiting child process
ok 3 - cache directory exists
1..3
ok      356 ms
[20:19:04]
All tests successful.
Files=1, Tests=3,  1 wallclock secs ( 0.03 usr  0.01 sys +  0.13 cusr  0.03 csys =  0.20 CPU)
Result: PASS
Owner

gfx commented Jan 23, 2014

LGTM. Thank you!

@gfx gfx added a commit that referenced this pull request Jan 23, 2014

@gfx gfx Merge pull request #103 from hitode909/cache-directory
Preparing cache directory fails on multi process
c88b7c7

@gfx gfx merged commit c88b7c7 into xslate:master Jan 23, 2014

1 check failed

default The Travis CI build could not complete due to an error
Details

@hitode909 hitode909 deleted the hitode909:cache-directory branch Jan 23, 2014

Contributor

hitode909 commented Jan 23, 2014

Thank you!!!!

@gfx gfx added a commit that referenced this pull request Jan 23, 2014

@gfx gfx Checking in changes prior to tagging of version 3.1.1.
Changelog diff is:

diff --git a/Changes b/Changes
index e3ee433..44033aa 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,13 @@
 Revision history for Perl extension Text::Xslate

+3.1.1 2014-01-24 07:50:52+0900
+    [DOCUMENTS]
+    - Fix some typos (#102)
+    - Add an explanation of `validate()` (#101)
+
+    [BUG FIXES]
+    - Fix a race condition on making cache dirs (#103)
+
 3.1.0 2013-11-16 16:46:35+0900
     [BUG FIXES]
     - Close #96; $/ affected the parse() method
44e503c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment