avoid that a cached source stream is being closed while used by another process
authorStefan Vogel <sv@exept.de>
Sat, 20 Jun 2009 11:16:54 +0200
changeset 11778 a4d708790f90
parent 11777 000651e1db46
child 11779 73c3f28d8960
avoid that a cached source stream is being closed while used by another process
Method.st
--- a/Method.st	Tue Jun 16 20:33:37 2009 +0200
+++ b/Method.st	Sat Jun 20 11:16:54 2009 +0200
@@ -522,16 +522,22 @@
         chunk notNil ifTrue:[
             ^ chunk
         ].
-        aStream := self sourceStream.
-        aStream notNil ifTrue:[
-            [
-                chunk := self sourceChunkFromStream:aStream.
-            ] on:DecodingError do:[:ex|
-                "CharacterEncoder>>#guessEncoding is not fail safe - retry with plain unecoded data"
-
-                ('DecodingError ignored when reading <1p> (<2p>)' expandMacrosWith:self whoString with:ex description) infoPrintCR.
-                aStream := self rawSourceStream.
-                ex restart.
+
+        LastFileLock critical:[
+            "have to protect aStream from being closed as a side effect 
+             of some other process fetching some the source from a different source file"
+
+            aStream := self sourceStream.
+            aStream notNil ifTrue:[
+                [
+                    chunk := self sourceChunkFromStream:aStream.
+                ] on:DecodingError do:[:ex|
+                    "CharacterEncoder>>#guessEncoding is not fail safe - retry with plain unencoded data"
+
+                    ('DecodingError ignored when reading <1p> (<2p>)' expandMacrosWith:self whoString with:ex description) infoPrintCR.
+                    aStream := self rawSourceStream.
+                    ex restart.
+                ].
             ].
         ].
     ].
@@ -2848,7 +2854,7 @@
 !Method class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.319 2009-04-07 09:15:16 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.320 2009-06-20 09:16:54 stefan Exp $'
 ! !
 
 Method initialize!