Mailing List Archive

cvs commit: embperl/emacs embperl.el
richter 00/04/22 13:18:03

Modified: . Embperl.pm EmbperlObject.pm Faq.pod Makefile.PL
ep.h
Embperl Mail.pm Module.pm
emacs embperl.el
Log:
- fix win32 & perl 5.6

Revision Changes Path
1.100 +0 -0 embperl/Embperl.pm

Index: Embperl.pm
===================================================================
RCS file: /home/cvs/embperl/Embperl.pm,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -r1.99 -r1.100
--- Embperl.pm 2000/04/17 21:22:19 1.99
+++ Embperl.pm 2000/04/22 20:18:01 1.100
@@ -10,7 +10,7 @@
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: Embperl.pm,v 1.99 2000/04/17 21:22:19 richter Exp $
+# $Id: Embperl.pm,v 1.100 2000/04/22 20:18:01 richter Exp $
#
###################################################################################




1.24 +0 -0 embperl/EmbperlObject.pm

Index: EmbperlObject.pm
===================================================================
RCS file: /home/cvs/embperl/EmbperlObject.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- EmbperlObject.pm 2000/04/17 21:22:19 1.23
+++ EmbperlObject.pm 2000/04/22 20:18:01 1.24
@@ -10,7 +10,7 @@
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: EmbperlObject.pm,v 1.23 2000/04/17 21:22:19 richter Exp $
+# $Id: EmbperlObject.pm,v 1.24 2000/04/22 20:18:01 richter Exp $
#
###################################################################################




1.12 +76 -0 embperl/Faq.pod

Index: Faq.pod
===================================================================
RCS file: /home/cvs/embperl/Faq.pod,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Faq.pod 2000/03/29 19:41:40 1.11
+++ Faq.pod 2000/04/22 20:18:01 1.12
@@ -349,6 +349,82 @@
L<"Escaping & Unescaping"> is devoted to them.


+=head2 When I use a module inside a Embperl page, it behaves weired
+when the source changes.
+
+
+Nothing weird here. Everything is well defined. Just let us try to
+understand how I<Perl>, I<mod_perl> and I<Embperl> works together:
+
+"perldoc -f use" tells us:
+
+ Imports some semantics into the current package from the named module,
+ generally by aliasing certain subroutine or variable names into your
+ package. It is exactly equivalent to
+
+ BEGIN { require Module; import Module LIST; }
+
+ except that Module must be a bareword.
+
+So what's important here for us is, that C<use> executes a C<require> and
+this is always done before any other code is executed.
+
+"perldoc -f require" says (among other things):
+
+ ..., demands that a library file be included if it hasn't already
+ been included.
+
+and
+
+ Note that the file will not be included twice under the same specified
+ name.
+
+So now we know (or should know) that I<mod_perl> starts the Perl interpreter
+once when I<Apache> is started and the Perl interpreter is only terminated
+when Apache is terminated. Out of these two things follows, that a module
+that is loaded via C<use> or C<require> is only loaded once and will never
+be reloaded, regardless if the source changes or not.
+
+So far this is just standard Perl. Things get's a little bit more difficult
+when running under mod_perl (only Unix), because Apache forks a set of child
+processes as neccessary and from the moment they are forked, they run on their
+own and don't know of each other. So if a module is loaded at server startup
+time (before the fork), it is loaded in all childs (this can be used to save
+memory, because the code will actually only reside once in memory), but when
+the modul is loaded inside the child and the source changes, it could be
+happen, that one child has loaded an ealier version and another child has
+loaded a later version of that module, depending on the time the module
+is actualy loaded by the child.
+
+That explains, why sometimes it works and sometimes it doesn't, simply because
+different childs has loaded different versions of the same module and when you
+reload your page you hit different childs of Apache!
+
+Now there is one point that is special to Embperl to add.
+Since Embperl compiles every page in a different namespace,
+a module that doesn't contains a C<package foo> statement is compiled in the
+namespace of the page where it is first loaded.
+Because Perl will not load the module a second time,
+every other page will not see subs and vars that are defined in the loaded
+module. This could be simply avoided by giving every module that should be
+loaded via C<use>/C<require> an explicit namespace via the package statement.
+
+So what can we do?
+
+=over 4
+
+=item * If a module change, simply restart Apache. That's works always.
+
+=item * Use I<Apache::StatInc.> This will do a stat on every loaded module and compare
+the modification time. If the source has changed the module is reloaded. This
+works most times (but not all modules can be cleanly reloaded) and as the number
+of loaded modules increase, your sever will slow down, because of the stat it
+has to do for every module.
+
+=item * Use C<do> instead of C<require>. C<do> will execute your file everytime
+it is used. This also adds overhead, but this may be accpetable for small files
+or in a debugging environement. (B<NOTE:> Be sure to check C<$@> after a C<do>,
+because do works like C<eval>)


=head2 Why doesn't the following line work?



1.28 +4 -5 embperl/Makefile.PL

Index: Makefile.PL
===================================================================
RCS file: /home/cvs/embperl/Makefile.PL,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- Makefile.PL 2000/04/17 21:03:15 1.27
+++ Makefile.PL 2000/04/22 20:18:02 1.28
@@ -25,8 +25,7 @@
(
'mod_perl.c' => { name => 'perl_module',
path => ['$apache_src/modules/perl/libperl.so', '$EPBINDIR/modules/libperl.so'],
- win32path => ['$EPBINDIR/modules/apachemoduleperl.dll'],
- win32path => ['$mpdll'],
+ win32path => ['$mpdll', '$mpdll/apachemoduleperl.dll', '$EPBINDIR/modules/apachemoduleperl.dll'],
file => 'libperl.so',
win32file => 'apachemoduleperl.dll',
},
@@ -446,7 +445,6 @@
EOF
close FH;

-=pod
if ($ENV{APACHE_PERL_DLL})
{
$mpdll = $ENV{APACHE_PERL_DLL} ;
@@ -455,6 +453,7 @@
{
$mpdll = $1 ;
}
+=pod
else
{
SEARCH:
@@ -580,7 +579,7 @@
{
$path = cnvpath ("$addmodpath/$modfile") ;
#print "path = $_ -> $path\n" ;
- if (-e $path)
+ if (-f $path)
{ ## module fould
$EPMODPERL .= "\r\nLoadModule $opt->{name} $path" ;
print " + Load dynamic module $mod\n" ;
@@ -592,7 +591,7 @@
{
$path = cnvpath (eval "\"$_\"") ;
#print "path = $_ -> $path\n" ;
- if (-e $path)
+ if (-f $path)
{ ## module fould
$EPMODPERL .= "\r\nLoadModule $opt->{name} $path" ;
print " + Load dynamic module $mod\n" ;



1.23 +66 -0 embperl/ep.h

Index: ep.h
===================================================================
RCS file: /home/cvs/embperl/ep.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- ep.h 2000/04/17 21:03:15 1.22
+++ ep.h 2000/04/22 20:18:02 1.23
@@ -61,6 +61,72 @@
#undef FALSE
#endif

+#ifdef WIN32
+
+#ifdef uid_t
+#define apache_uid_t uid_t
+#undef uid_t
+#endif
+#define uid_t apache_uid_t
+
+#ifdef gid_t
+#define apache_gid_t gid_t
+#undef gid_t
+#endif
+#define gid_t apache_gid_t
+
+#ifdef mode_t
+#define apache_mode_t mode_t
+#undef mode_t
+#endif
+#define mode_t apache_mode_t
+
+#ifdef stat
+#define apache_stat stat
+#undef stat
+#endif
+
+#ifdef sleep
+#define apache_sleep sleep
+#undef sleep
+#endif
+
+#ifndef PERL_VERSION
+#include <patchlevel.h>
+#define PERL_VERSION PATCHLEVEL
+#define PERL_SUBVERSION SUBVERSION
+#endif
+
+#if PERL_VERSION >= 6
+
+#ifdef opendir
+#define apache_opendir opendir
+#undef opendir
+#endif
+
+#ifdef readdir
+#define apache_readdir readdir
+#undef readdir
+#endif
+
+#ifdef closedir
+#define apache_closedir closedir
+#undef closedir
+#endif
+
+#ifdef crypt
+#define apache_crypt crypt
+#undef crypt
+#endif
+
+#ifdef errno
+#define apache_errno errno
+#undef errno
+#endif
+
+#endif /* endif PERL_VERSION >= 6 */
+
+#endif /* endif WIN32 */

#include <httpd.h>
#include <http_config.h>



1.23 +0 -0 embperl/Embperl/Mail.pm

Index: Mail.pm
===================================================================
RCS file: /home/cvs/embperl/Embperl/Mail.pm,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- Mail.pm 2000/04/17 21:22:21 1.22
+++ Mail.pm 2000/04/22 20:18:02 1.23
@@ -9,7 +9,7 @@
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: Mail.pm,v 1.22 2000/04/17 21:22:21 richter Exp $
+# $Id: Mail.pm,v 1.23 2000/04/22 20:18:02 richter Exp $
#
###################################################################################




1.24 +0 -0 embperl/Embperl/Module.pm

Index: Module.pm
===================================================================
RCS file: /home/cvs/embperl/Embperl/Module.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- Module.pm 2000/04/17 21:22:21 1.23
+++ Module.pm 2000/04/22 20:18:03 1.24
@@ -9,7 +9,7 @@
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: Module.pm,v 1.23 2000/04/17 21:22:21 richter Exp $
+# $Id: Module.pm,v 1.24 2000/04/22 20:18:03 richter Exp $
#
###################################################################################

@@ -25,7 +25,7 @@
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: Module.pm,v 1.23 2000/04/17 21:22:21 richter Exp $
+# $Id: Module.pm,v 1.24 2000/04/22 20:18:03 richter Exp $
#
###################################################################################




1.92 +0 -0 embperl/emacs/embperl.el

Index: embperl.el
===================================================================
RCS file: /home/cvs/embperl/emacs/embperl.el,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -r1.91 -r1.92
--- embperl.el 2000/04/17 21:22:22 1.91
+++ embperl.el 2000/04/22 20:18:03 1.92
@@ -19,9 +19,9 @@
;; Author : Erik Arneson (erik@mind.net)
;; Created On : Wed Jul 22 17:16:39 PDT 1998
;; Last Modified By: Erik Arneson
-;; Last Modified On: $Date: 2000/04/17 21:22:22 $
+;; Last Modified On: $Date: 2000/04/22 20:18:03 $
;; Version : 1.00
-;; $Id: embperl.el,v 1.91 2000/04/17 21:22:22 richter Exp $
+;; $Id: embperl.el,v 1.92 2000/04/22 20:18:03 richter Exp $
;;
;; Please note that this software is very beta and rather broken. I
;; don't know how useful it will be, although I definitely plan on