2011/11/17 Jarek Lubczyński <el...@elkomtech.com.pl>:
> And the point is: in the first phase of executing PAR loader looks for temp
> directory, if it doesn't exist, loader extracts archive into it and then
> runs the main script. But if something break the extraction (the user will
> press Ctrl-C for example), the archive will not execute anymore (because
> extractor will 'see' the temp dir which is broken) until the temp dir will
> be manually removed.
>
> Question is: how to avoid such effect?

Rewrite the extraction stuff :) Note that this is not a trivial task, since
extraction proceeds in several phases, split across different executables
(the name of the cache directory is passed in an evironment variable).

In theory, one could proceed as follows:
(1) if cache directory already exists then do nothing (assuming it has already
     been extracted successfully)
(2) otherwise extract into a unique temp directory
(3) when finished, rename the temp directory to the expected name;
     if renaming fails because the cache directory already exists
     assume another invocation was faster, abandon the temp directory
     and proceed with the cache directory (as in (1))

If a process is interrupted during (2) the worst is that it leaves a
half-extracted
temp directory lying around. If several invocations proceed with (2)
simultaneously
the first one to finish will win the "rename" race, the others simply have done
unnecessary work. The tricky part comes in (3) when trying to switch
from the temp directory to the cache directory, because at that point
we are already using stuff from the temp directory, e.g. the libperl DLL.
In order to properly free these resources we'll probably have to re-exec...

> And: is there *any* chance to execute PAR 'in place', that is without
> extracting the archive?

No. Most (pure) perl modules are already used 'in place' i.e. they are loaded
directly from the PAR archive. This is done by hooking into Perl's
module loading implementation. (Yeah, I know that these modules are also
extracted which is not necessary - that's a bug, patches welcome.)
But DLLs cannot be loaded from the archive, no operating system
I know supports this. Also lots of perl modules read files that are
neither modules (i.e. loaded via "require" or "use") nor DLLs
(the Unicode tables are an example).These have to be extracted, too
(in the hope that the module uses some reasonable algorithm to search
for them).

Cheers, Roderich

Reply via email to