Hi,
At astaro.com, we are using ActivePerl and PerlApp to wrap
modules
for the Astaro Security Gateway. Currently, i'm trying to
evaluate
whether it might be possible to compile various modules
into
shared object files in order to load and unload them on
demand.
Two goals are involved: (1) Modules should not be accessible
when
disabled and (2) unused modules should not bloat the
application in
question.
The module names belong to a hierarchy. Typically, they
contain
at least one "::", e.g.
modules::IPSec::LocalKey::RSA.pm.
The Modules are clean: they export nothing. They are
intended
to be required, not used. The module names are saved in
perl scalar variables, so the require statements are
wrapped
in eval.
For getting started, i wrote a toy application, but now i'm
stuck
even after reading the docs at
http://aspn.activestate.com/ASPN/docs/PDK/7.0/PerlApp.
html and
http://comm
unity.activestate.com/faq-list and
http://aspn.activestate.com/ASPN/Mail/Browse/Threaded/p
dk
Please be so kind to look at this:
ischwarze sles10:~/Test> uname -a
Linux sles10 2.6.16.21-0.8-bigsmp #1 SMP Mon Jul 3 18:25:39
UTC 2006
i686 i686 i386 GNU/Linux
ischwarze sles10:~/Test> /usr/local/ap587/bin/perl --version
| head -n9
This is perl, v5.8.7 built for i686-linux-thread-multi
(with 13 registered patches, see perl -V for more detail)
Copyright 1987-2005, Larry Wall
Binary build 815 [211909] provided by ActiveState http://www.ActiveState.com
ActiveState is a division of Sophos.
Built Nov 2 2005 07:43:57
ischwarze sles10:~/Test> /usr/local/pdk/bin/perlapp
--version
PerlApp 6.0.2 build 203380
Copyright (C) 1998-2005 ActiveState Corp. All rights
reserved.
ActiveState is a division of Sophos Plc.
Commercial license for XXX <XXX astaro.com>
ischwarze sles10:~/Test> find . -exec ls -ald {} ;
drwxr-xr-x 5 ischwarze users 4096 2007-06-26 15:03 .
drwxr-xr-x 2 ischwarze users 4096 2007-06-26 15:03 ./MyPack
-rw-r--r-- 1 ischwarze users 167 2007-06-26 15:03
./MyPack/MyMod.pm
drwxr-xr-x 2 ischwarze users 4096 2007-06-26 15:01 ./lib
-rw-r--r-- 1 ischwarze users 432 2007-06-26 14:41
./Makefile
drwxr-xr-x 2 ischwarze users 4096 2007-06-26 15:01 ./bin
-rw-r--r-- 1 ischwarze users 206 2007-06-26 14:36
./MyApp.pl
ischwarze sles10:~/Test> cat MyPack/MyMod.pm
package MyPack::MyMod;
use warnings;
use strict;
BEGIN { print "MyMod: executing BEGINn"; }
print "MyMod: DOn";
sub myFunc { print "MyMod: executing myFuncn"; }
1;
ischwarze sles10:~/Test> cat MyApp.pl
my $modname = 'MyPack::MyMod';
print "main: requiren";
print " eval: ".eval("require
$modname")."n";
print $ ;
print "main: calln";
print " eval:
".eval("$::myFunc()")."n"
;
print $ ;
exit 0;
ischwarze sles10:~/Test> /usr/local/ap587/bin/perl MyApp.pl
main: require
MyMod: executing BEGIN
MyMod: DO
eval: 1
main: call
MyMod: executing myFunc
eval: 1
ischwarze sles10:~/Test> cat Makefile
PERLAPP=/usr/local/pdk/bin/perlapp --perl
/usr/local/ap587/bin/perl --force
LIBSRC=MyPack/MyMod.pm
LIBBIN=lib/MyMod.so
APPSRC=MyApp.pl
APPBIN=bin/MyApp
all: $(LIBBIN) $(APPBIN)
$(LIBBIN): $(LIBSRC)
$(PERLAPP) --shared private $(LIBSRC) --exe
$(LIBBIN)
$(APPBIN): $(APPSRC)
$(PERLAPP) --shared private --runlib ../lib --use
$(LIBBIN)
$(APPSRC) --exe $(APPBIN)
clean:
rm -rf /tmp/pdk-ischwarze lib/* bin/*
.PHONY: clean
# end of Makefile
ischwarze sles10:~/Test> make
/usr/local/pdk/bin/perlapp --perl /usr/local/ap587/bin/perl
--force
--shared private MyPack/MyMod.pm --exe lib/MyMod.so
PerlApp 6.0.2 build 203380
Copyright (C) 1998-2005 ActiveState Corp. All rights
reserved.
ActiveState is a division of Sophos Plc.
Commercial license for XXX <XXX astaro.com>
Created 'lib/MyMod.so'
/usr/local/pdk/bin/perlapp --perl /usr/local/ap587/bin/perl
--force
--shared private --runlib ../lib --use lib/MyMod.so
MyApp.pl --exe bin/MyApp
PerlApp 6.0.2 build 203380
Copyright (C) 1998-2005 ActiveState Corp. All rights
reserved.
ActiveState is a division of Sophos Plc.
Commercial license for XXX <XXX astaro.com>
Created 'bin/MyApp'
# end of make
schwarze sles10:~/Test> ./bin/MyApp
main: require
eval:
Can't locate MyPack/MyMod.pm in INC
( INC contains: /home/ischwarze/Test/bin/../lib) at
(eval 3) line 3.
main: call
eval:
Undefined subroutine &MyPack::MyMod::myFunc called at
(eval 5) line 1.
To summarize, both the module and the application compile,
but the
application won't access the module in the shared object.
With
simple module names, this problem does not occur, i.e.
my $modname = 'MySimple';
is working fine.
I would be grateful for any hints...
Besides, we would need to compile about two dozen modules
like
MyPack::MyMod. Do i understand correctly that each module
must
contain the whole perllib? Do i understand correctly that
we
could build these modules without perllib if we were using
PDK
version 7?
And finally, what about unloading previouly used modules in
order
to free RAM or in order to make the code inaccessible when
the
respective features are diabled by the administrator of the
server program, similar to dlclose(3)? Is there any such
functionality?
Yours,
Ingo
--
Ingo Schwarze <ischwarze astaro.com> | Software
Engineer | Framework Team
Astaro AG | www.astaro.com | 76227 Karlsruhe | Germany
_______________________________________________
PDK mailing list
PDK listserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs
|