randyk 2004/06/15 20:55:48
Modified: lib/Apache Build.pm lib/ModPerl Code.pm src/modules/perl mod_perl.h modperl_apache_includes.h modperl_cmd.c modperl_config.c modperl_error.c modperl_gtop.h modperl_log.c modperl_log.h modperl_util.c modperl_util.h t/apr-ext perlio.t todo bugs_apr_ext xs/APR Makefile.PL xs/APR/APR APR.xs Makefile.PL xs/APR/PerlIO apr_perlio.c xs/Apache Makefile.PL xs/tables/current/ModPerl FunctionTable.pm Added: src/modules/perl modperl_apr_includes.h modperl_common_debug.c modperl_common_debug.h modperl_common_includes.h modperl_common_log.c modperl_common_log.h modperl_common_util.c modperl_common_util.h modperl_debug.c modperl_debug.h t/apr-ext table.t Log: commit of the original patch of Stas: http://marc.theaimsgroup.com/?l=apreq-dev&m=108381885618328&w=2 updated against the current cvs, towards getting APR to work without modperl. Revision Changes Path 1.163 +7 -2 modperl-2.0/lib/Apache/Build.pm Index: Build.pm =================================================================== RCS file: /home/cvs/modperl-2.0/lib/Apache/Build.pm,v retrieving revision 1.162 retrieving revision 1.163 diff -u -r1.162 -r1.163 --- Build.pm 27 Apr 2004 17:26:28 -0000 1.162 +++ Build.pm 16 Jun 2004 03:55:46 -0000 1.163 @@ -268,6 +268,7 @@ sub find_gtop_config { my %c = (); + my $ver_2_5_plus = 0; if (system('pkg-config --exists libgtop-2.0') == 0) { # 2.x chomp($c{ccopts} = qx|pkg-config --cflags libgtop-2.0|); @@ -279,7 +280,9 @@ chomp($c{ver} = qx|pkg-config --modversion libgtop-2.0|); ($c{ver_maj}, $c{ver_min}) = split /\./, $c{ver}; - if ($c{ver_maj} == 2 && $c{ver_min} >= 5) { + $ver_2_5_plus++ if $c{ver_maj} == 2 && $c{ver_min} >= 5; + + if ($ver_2_5_plus) { # some headers were removed in libgtop 2.5.0 so we need to # be able to exclude them at compile time $c{ccopts} .= ' -DGTOP_2_5_PLUS'; @@ -295,7 +298,9 @@ $c{ldopts} =~ s|^/|-L/|; } - if ($c{ccopts}) { + # starting from 2.5.0 'pkg-config --cflags libgtop-2.0' already + # gives us all the cflags that are needed + if ($c{ccopts} && !$ver_2_5_plus) { chomp(my $ginc = `glib-config --cflags`); $c{ccopts} .= " $ginc"; } 1.123 +4 -2 modperl-2.0/lib/ModPerl/Code.pm Index: Code.pm =================================================================== RCS file: /home/cvs/modperl-2.0/lib/ModPerl/Code.pm,v retrieving revision 1.122 retrieving revision 1.123 diff -u -r1.122 -r1.123 --- Code.pm 10 May 2004 20:10:15 -0000 1.122 +++ Code.pm 16 Jun 2004 03:55:47 -0000 1.123 @@ -642,7 +642,8 @@ my @c_src_names = qw(interp tipool log config cmd options callback handler gtop util io io_apache filter bucket mgv pcw global env cgi perl perl_global perl_pp sys module svptr_table - const constants apache_compat error); + const constants apache_compat error debug + common_util common_log); my @h_src_names = qw(perl_unembed); my @g_c_names = map { "modperl_$_" } qw(hooks directives flags xsinit); my @c_names = ('mod_perl', (map "modperl_$_", @c_src_names)); @@ -653,7 +654,8 @@ my @g_h_names = map { "modperl_$_" } qw(hooks directives flags trace largefiles); my @h_names = (@c_names, map { "modperl_$_" } @h_src_names, - qw(types time apache_includes perl_includes)); + qw(types time apache_includes perl_includes apr_includes + common_includes)); sub h_files { [map { "$_.h" } @h_names, @g_h_names] } sub clean_files { 1.66 +2 -1 modperl-2.0/src/modules/perl/mod_perl.h Index: mod_perl.h =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.h,v retrieving revision 1.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- mod_perl.h 4 May 2004 06:10:37 -0000 1.65 +++ mod_perl.h 16 Jun 2004 03:55:47 -0000 1.66 @@ -17,7 +17,7 @@ #define MOD_PERL_H #include "modperl_apache_includes.h" -#include "modperl_perl_includes.h" +#include "modperl_common_includes.h" #include "modperl_apache_compat.h" #ifdef WIN32 @@ -91,6 +91,7 @@ #include "modperl_perl.h" #include "modperl_svptr_table.h" #include "modperl_module.h" +#include "modperl_debug.h" int modperl_init_vhost(server_rec *s, apr_pool_t *p, server_rec *base_server); 1.29 +0 -12 modperl-2.0/src/modules/perl/modperl_apache_includes.h Index: modperl_apache_includes.h =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_apache_includes.h,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- modperl_apache_includes.h 4 Mar 2004 06:01:06 -0000 1.28 +++ modperl_apache_includes.h 16 Jun 2004 03:55:47 -0000 1.29 @@ -34,18 +34,6 @@ #include "http_vhost.h" #include "ap_mpm.h" -#include "apr_version.h" -#include "apr_poll.h" -#include "apr_lib.h" -#include "apr_strings.h" -#include "apr_uri.h" -#include "apr_date.h" -#include "apr_buckets.h" -#include "apr_time.h" -#include "apr_network_io.h" -#include "apr_general.h" -#include "apr_uuid.h" -#include "apr_env.h" #include "util_filter.h" #include "util_script.h" 1.60 +1 -1 modperl-2.0/src/modules/perl/modperl_cmd.c Index: modperl_cmd.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_cmd.c,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- modperl_cmd.c 10 May 2004 19:54:00 -0000 1.59 +++ modperl_cmd.c 16 Jun 2004 03:55:47 -0000 1.60 @@ -153,7 +153,7 @@ MP_CMD_SRV_DECLARE(trace) { MP_CMD_SRV_CHECK; - modperl_trace_level_set(parms->server, arg); + modperl_trace_level_set_apache(parms->server, arg); return NULL; } 1.79 +1 -1 modperl-2.0/src/modules/perl/modperl_config.c Index: modperl_config.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_config.c,v retrieving revision 1.78 retrieving revision 1.79 diff -u -r1.78 -r1.79 --- modperl_config.c 4 Mar 2004 06:01:07 -0000 1.78 +++ modperl_config.c 16 Jun 2004 03:55:47 -0000 1.79 @@ -268,7 +268,7 @@ * PerlTrace. This place is the earliest point in mod_perl * configuration parsing, when we have the server object */ - modperl_trace_level_set(s, NULL); + modperl_trace_level_set_apache(s, NULL); /* Must store the global server record as early as possible, * because if mod_perl happens to be started from within a 1.3 +4 -1 modperl-2.0/src/modules/perl/modperl_error.c Index: modperl_error.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_error.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- modperl_error.c 10 May 2004 01:21:24 -0000 1.2 +++ modperl_error.c 16 Jun 2004 03:55:47 -0000 1.3 @@ -55,7 +55,10 @@ HV *data; /* XXX: it'd be nice to arrange for it to load early */ - modperl_require_module(aTHX_ "APR::Error", TRUE); + Perl_require_pv(aTHX_ "APR/Error.pm"); + if (SvTRUE(ERRSV)) { + Perl_croak(aTHX_ "%s", SvPV_nolen(ERRSV)); + } stash = gv_stashpvn("APR::Error", 10, FALSE); data = newHV(); 1.7 +2 -1 modperl-2.0/src/modules/perl/modperl_gtop.h Index: modperl_gtop.h =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_gtop.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- modperl_gtop.h 27 Apr 2004 00:27:38 -0000 1.6 +++ modperl_gtop.h 16 Jun 2004 03:55:47 -0000 1.7 @@ -21,7 +21,8 @@ #endif #ifdef MP_USE_GTOP - +/* prevent undef symbol errors (glibtop_error_vr) */ +#define __GLIBTOP_ERROR_H__ #include <glibtop.h> #include <glibtop/open.h> #include <glibtop/close.h> 1.12 +0 -77 modperl-2.0/src/modules/perl/modperl_log.c Index: modperl_log.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_log.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- modperl_log.c 4 Mar 2004 06:01:07 -0000 1.11 +++ modperl_log.c 16 Jun 2004 03:55:47 -0000 1.12 @@ -13,81 +13,4 @@ * limitations under the License. */ -#include "modperl_apache_includes.h" -#include "apr_lib.h" -#include "modperl_trace.h" #include "modperl_log.h" - -#undef getenv /* from XSUB.h */ - -static apr_file_t *logfile = NULL; - -#ifdef WIN32 -static unsigned long debug_level = 0; -#else -unsigned long MP_debug_level = 0; -#define debug_level MP_debug_level -#endif - -unsigned long modperl_debug_level(void) -{ - return debug_level; -} - -void modperl_trace_logfile_set(apr_file_t *logfile_new) -{ - logfile = logfile_new; -} - -void modperl_trace(const char *func, const char *fmt, ...) -{ - char vstr[8192]; - apr_size_t vstr_len = 0; - va_list args; - - if (!logfile) { - return; - } - - if (func) { - apr_file_printf(logfile, "%s: ", func); - } - - va_start(args, fmt); - vstr_len = apr_vsnprintf(vstr, sizeof(vstr), fmt, args); - va_end(args); - - apr_file_write(logfile, vstr, &vstr_len); - apr_file_printf(logfile, "\n"); -} - -void modperl_trace_level_set(server_rec *s, const char *level) -{ - if (!level) { - if (!(level = getenv("MOD_PERL_TRACE"))) { - return; - } - } - debug_level = 0x0; - - if (strcasecmp(level, "all") == 0) { - debug_level = 0xffffffff; - } - else if (apr_isalpha(level[0])) { - static char debopts[] = MP_TRACE_OPTS; - char *d; - - for (; *level && (d = strchr(debopts, *level)); level++) { - debug_level |= 1 << (d - debopts); - } - } - else { - debug_level = atoi(level); - } - - debug_level |= 0x80000000; - - modperl_trace_logfile_set(s->error_log); - - MP_TRACE_any_do(MP_TRACE_dump_flags()); -} 1.14 +4 -40 modperl-2.0/src/modules/perl/modperl_log.h Index: modperl_log.h =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_log.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- modperl_log.h 4 Mar 2004 06:01:07 -0000 1.13 +++ modperl_log.h 16 Jun 2004 03:55:47 -0000 1.14 @@ -16,47 +16,11 @@ #ifndef MODPERL_LOG_H #define MODPERL_LOG_H -#define MP_STRINGIFY(n) MP_STRINGIFY_HELPER(n) -#define MP_STRINGIFY_HELPER(n) #n +#include "modperl_common_log.h" +#include "modperl_apache_includes.h" -#ifdef MP_TRACE -# if defined(__GNUC__) -# if (__GNUC__ > 2) -# define MP_FUNC __func__ -# else -# define MP_FUNC __FUNCTION__ -# endif -# else -# define MP_FUNC __FILE__ ":" MP_STRINGIFY(__LINE__) -# endif -#else -# define MP_FUNC NULL -#endif - -#include "modperl_trace.h" - -#ifdef _PTHREAD_H -#define modperl_thread_self() pthread_self() -#else -#define modperl_thread_self() 0 -#endif - -#define MP_TIDF \ -(unsigned long)modperl_thread_self() - -void modperl_trace_logfile_set(apr_file_t *logfile_new); - -unsigned long modperl_debug_level(void); - -#ifdef WIN32 -#define MP_debug_level modperl_debug_level() -#else -extern unsigned long MP_debug_level; -#endif - -void modperl_trace(const char *func, const char *fmt, ...); - -void modperl_trace_level_set(server_rec *s, const char *level); +#define modperl_trace_level_set_apache(s, level) \ + modperl_trace_level_set(s->error_log, level); #define modperl_log_warn(s,msg) \ ap_log_error(APLOG_MARK, APLOG_WARNING, 0, s, "%s", msg) 1.70 +0 -119 modperl-2.0/src/modules/perl/modperl_util.c Index: modperl_util.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_util.c,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- modperl_util.c 10 May 2004 02:37:05 -0000 1.69 +++ modperl_util.c 16 Jun 2004 03:55:47 -0000 1.70 @@ -290,19 +290,6 @@ return status; } -char *modperl_server_desc(server_rec *s, apr_pool_t *p) -{ - return apr_psprintf(p, "%s:%u", s->server_hostname, s->port); -} - -/* used in debug traces */ -MP_INLINE char *modperl_pid_tid(apr_pool_t *p) -{ - return apr_psprintf(p, "%lu" MP_TRACEf_TID, - (unsigned long)getpid() MP_TRACEv__TID); -} - - #define dl_librefs "DynaLoader::dl_librefs" #define dl_modules "DynaLoader::dl_modules" @@ -395,54 +382,6 @@ return uri; } -MP_INLINE SV *modperl_hash_tie(pTHX_ - const char *classname, - SV *tsv, void *p) -{ - SV *hv = (SV*)newHV(); - SV *rsv = sv_newmortal(); - - sv_setref_pv(rsv, classname, p); - sv_magic(hv, rsv, PERL_MAGIC_tied, Nullch, 0); - - return SvREFCNT_inc(sv_bless(sv_2mortal(newRV_noinc(hv)), - gv_stashpv(classname, TRUE))); -} - -MP_INLINE void *modperl_hash_tied_object(pTHX_ - const char *classname, - SV *tsv) -{ - if (sv_derived_from(tsv, classname)) { - if (SVt_PVHV == SvTYPE(SvRV(tsv))) { - SV *hv = SvRV(tsv); - MAGIC *mg; - - if (SvMAGICAL(hv)) { - if ((mg = mg_find(hv, PERL_MAGIC_tied))) { - return (void *)MgObjIV(mg); - } - else { - Perl_warn(aTHX_ "Not a tied hash: (magic=%c)", mg); - } - } - else { - Perl_warn(aTHX_ "SV is not tied"); - } - } - else { - return (void *)SvObjIV(tsv); - } - } - else { - Perl_croak(aTHX_ - "argument is not a blessed reference " - "(expecting an %s derived object)", classname); - } - - return NULL; -} - MP_INLINE void modperl_perl_av_push_elts_ref(pTHX_ AV *dst, AV *src) { I32 i, j, src_fill = AvFILLp(src), dst_fill = AvFILLp(dst); @@ -625,16 +564,6 @@ return (*name && gv_stashpv(name, FALSE)) ? 1 : 0; } -/* same as Symbol::gensym() */ -SV *modperl_perl_gensym(pTHX_ char *pack) -{ - GV *gv = newGVgen(pack); - SV *rv = newRV((SV*)gv); - (void)hv_delete(gv_stashpv(pack, TRUE), - GvNAME(gv), GvNAMELEN(gv), G_DISCARD); - return rv; -} - static int modperl_gvhv_is_stash(GV *gv) { int len = GvNAMELEN(gv); @@ -881,51 +810,3 @@ return text; } - -#ifdef MP_TRACE - -/* XXX: internal debug function, a candidate for modperl_debug.c */ -/* any non-false value for MOD_PERL_TRACE/PerlTrace enables this function */ -void modperl_apr_table_dump(pTHX_ apr_table_t *table, char *name) -{ - int i; - const apr_array_header_t *array; - apr_table_entry_t *elts; - - array = apr_table_elts(table); - elts = (apr_table_entry_t *)array->elts; - modperl_trace(MP_FUNC, "Contents of table %s", name); - for (i = 0; i < array->nelts; i++) { - if (!elts[i].key || !elts[i].val) { - continue; - } - modperl_trace(MP_FUNC, "%s => %s", elts[i].key, elts[i].val); - } -} - -/* XXX: internal debug function, a candidate for modperl_debug.c */ -void modperl_perl_modglobal_dump(pTHX) -{ - HV *hv = PL_modglobal; - AV *val; - char *key; - I32 klen; - hv_iterinit(hv); - - MP_TRACE_g(MP_FUNC, "|-------- PL_modglobal --------"); -#ifdef USE_ITHREADS - MP_TRACE_g(MP_FUNC, "| perl 0x%lx", (unsigned long)aTHX); -#endif - MP_TRACE_g(MP_FUNC, "| PL_modglobal 0x%lx", - (unsigned long)PL_modglobal); - - while ((val = (AV*)hv_iternextsv(hv, &key, &klen))) { - MP_TRACE_g(MP_FUNC, "| %s => 0x%lx", key, val); - } - - MP_TRACE_g(MP_FUNC, "|-------- PL_modglobal --------\n"); - -} - - -#endif 1.62 +1 -71 modperl-2.0/src/modules/perl/modperl_util.h Index: modperl_util.h =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_util.h,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- modperl_util.h 2 Jun 2004 21:35:58 -0000 1.61 +++ modperl_util.h 16 Jun 2004 03:55:47 -0000 1.62 @@ -16,54 +16,7 @@ #ifndef MODPERL_UTIL_H #define MODPERL_UTIL_H -#ifdef MP_DEBUG -#define MP_INLINE -#else -#define MP_INLINE APR_INLINE -#endif - -#ifdef WIN32 -# define MP_FUNC_T(name) (_stdcall *name) -/* XXX: not all functions get inlined - * so its unclear what to and not to include in the .def files - */ -# undef MP_INLINE -# define MP_INLINE -#else -# define MP_FUNC_T(name) (*name) -#endif - -#define MP_SSTRLEN(string) (sizeof(string)-1) - -#ifndef strcaseEQ -# define strcaseEQ(s1,s2) (!strcasecmp(s1,s2)) -#endif -#ifndef strncaseEQ -# define strncaseEQ(s1,s2,l) (!strncasecmp(s1,s2,l)) -#endif - -#ifndef SvCLASS -#define SvCLASS(o) HvNAME(SvSTASH(SvRV(o))) -#endif - -#define SvObjIV(o) SvIV((SV*)SvRV(o)) -#define MgObjIV(m) SvIV((SV*)SvRV(m->mg_obj)) - -#define MP_SvGROW(sv, len) \ - (void)SvUPGRADE(sv, SVt_PV); \ - SvGROW(sv, len+1) - -#define MP_SvCUR_set(sv, len) \ - SvCUR_set(sv, len); \ - *SvEND(sv) = '\0'; \ - SvPOK_only(sv) - -#define MP_magical_untie(sv, mg_flags) \ - mg_flags = SvMAGICAL((SV*)sv); \ - SvMAGICAL_off((SV*)sv) - -#define MP_magical_tie(sv, mg_flags) \ - SvFLAGS((SV*)sv) |= mg_flags +#include "modperl_common_util.h" /* check whether the response phase has been initialized already */ #define MP_CHECK_WBUCKET_INIT(func) \ @@ -100,10 +53,6 @@ int modperl_require_module(pTHX_ const char *pv, int logfailure); int modperl_require_file(pTHX_ const char *pv, int logfailure); -char *modperl_server_desc(server_rec *s, apr_pool_t *p); - -MP_INLINE char *modperl_pid_tid(apr_pool_t *p); - void modperl_xs_dl_handles_clear(pTHX); void **modperl_xs_dl_handles_get(pTHX); @@ -114,14 +63,6 @@ MP_INLINE modperl_uri_t *modperl_uri_new(apr_pool_t *p); -/* tie %hash */ -MP_INLINE SV *modperl_hash_tie(pTHX_ const char *classname, - SV *tsv, void *p); - -/* tied %hash */ -MP_INLINE void *modperl_hash_tied_object(pTHX_ const char *classname, - SV *tsv); - MP_INLINE void modperl_perl_av_push_elts_ref(pTHX_ AV *dst, AV *src); HE *modperl_perl_hv_fetch_he(pTHX_ HV *hv, @@ -156,8 +97,6 @@ */ SV *modperl_slurp_filename(pTHX_ request_rec *r, int tainted); -SV *modperl_perl_gensym(pTHX_ char *pack); - void modperl_clear_symtab(pTHX_ HV *symtab); char *modperl_file2package(apr_pool_t *p, const char *file); @@ -171,15 +110,6 @@ * @return string of original source code */ char *modperl_coderef2text(pTHX_ apr_pool_t *p, CV *cv); - -#ifdef MP_TRACE - -void modperl_apr_table_dump(pTHX_ apr_table_t *table, char *name); - -/* dump the contents of PL_modglobal */ -void modperl_perl_modglobal_dump(pTHX); - -#endif #if defined(MP_TRACE) && defined(APR_HAS_THREADS) #define MP_TRACEf_TID "/tid 0x%lx" 1.1 modperl-2.0/src/modules/perl/modperl_apr_includes.h Index: modperl_apr_includes.h =================================================================== /* Copyright 2001-2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MODPERL_APR_INCLUDES_H #define MODPERL_APR_INCLUDES_H /* header files for APR */ #ifndef CORE_PRIVATE #define CORE_PRIVATE #endif #include "apr_version.h" #include "apr_poll.h" #include "apr_lib.h" #include "apr_strings.h" #include "apr_uri.h" #include "apr_date.h" #include "apr_buckets.h" #include "apr_time.h" #include "apr_network_io.h" #include "apr_general.h" #include "apr_uuid.h" #include "apr_env.h" #endif /* MODPERL_APR_INCLUDES_H */ 1.1 modperl-2.0/src/modules/perl/modperl_common_debug.c Index: modperl_common_debug.c =================================================================== /* Copyright 2000-2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* This file must not contain any symbols from apache/mod_perl * (apr and perl are OK) */ #include "modperl_common_includes.h" 1.1 modperl-2.0/src/modules/perl/modperl_common_debug.h Index: modperl_common_debug.h =================================================================== /* Copyright 2000-2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MODPERL_COMMON_DEBUG_H #define MODPERL_COMMON_DEBUG_H #endif /* MODPERL_COMMON_DEBUG_H */ 1.1 modperl-2.0/src/modules/perl/modperl_common_includes.h Index: modperl_common_includes.h =================================================================== /* Copyright 2001-2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MODPERL_COMMON_INCLUDES_H #define MODPERL_COMMON_INCLUDES_H /* header files which are independet of Apache/mod_perl */ #include "modperl_apr_includes.h" #include "modperl_perl_includes.h" #endif /* MODPERL_COMMON_INCLUDES_H */ 1.1 modperl-2.0/src/modules/perl/modperl_common_log.c Index: modperl_common_log.c =================================================================== /* Copyright 2000-2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "modperl_common_includes.h" #include "modperl_common_log.h" #undef getenv /* from XSUB.h */ static apr_file_t *logfile = NULL; #ifdef WIN32 static unsigned long debug_level = 0; #else unsigned long MP_debug_level = 0; #define debug_level MP_debug_level #endif unsigned long modperl_debug_level(void) { return debug_level; } void modperl_trace_logfile_set(apr_file_t *logfile_new) { logfile = logfile_new; } void modperl_trace(const char *func, const char *fmt, ...) { char vstr[8192]; apr_size_t vstr_len = 0; va_list args; if (!logfile) { return; } if (func) { apr_file_printf(logfile, "%s: ", func); } va_start(args, fmt); vstr_len = apr_vsnprintf(vstr, sizeof(vstr), fmt, args); va_end(args); apr_file_write(logfile, vstr, &vstr_len); apr_file_printf(logfile, "\n"); } void modperl_trace_level_set(apr_file_t *logfile, const char *level) { if (!level) { if (!(level = getenv("MOD_PERL_TRACE"))) { return; } } debug_level = 0x0; if (strcasecmp(level, "all") == 0) { debug_level = 0xffffffff; } else if (apr_isalpha(level[0])) { static char debopts[] = MP_TRACE_OPTS; char *d; for (; *level && (d = strchr(debopts, *level)); level++) { debug_level |= 1 << (d - debopts); } } else { debug_level = atoi(level); } debug_level |= 0x80000000; modperl_trace_logfile_set(logfile); MP_TRACE_any_do(MP_TRACE_dump_flags()); } 1.1 modperl-2.0/src/modules/perl/modperl_common_log.h Index: modperl_common_log.h =================================================================== /* Copyright 2000-2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MODPERL_COMMON_LOG_H #define MODPERL_COMMON_LOG_H #define MP_STRINGIFY(n) MP_STRINGIFY_HELPER(n) #define MP_STRINGIFY_HELPER(n) #n #ifdef MP_TRACE # if defined(__GNUC__) # if (__GNUC__ > 2) # define MP_FUNC __func__ # else # define MP_FUNC __FUNCTION__ # endif # else # define MP_FUNC __FILE__ ":" MP_STRINGIFY(__LINE__) # endif #else # define MP_FUNC NULL #endif #include "modperl_apr_includes.h" #include "apr_lib.h" #include "modperl_trace.h" #ifdef _PTHREAD_H #define modperl_thread_self() pthread_self() #else #define modperl_thread_self() 0 #endif #define MP_TIDF \ (unsigned long)modperl_thread_self() void modperl_trace_logfile_set(apr_file_t *logfile_new); unsigned long modperl_debug_level(void); #ifdef WIN32 #define MP_debug_level modperl_debug_level() #else extern unsigned long MP_debug_level; #endif void modperl_trace(const char *func, const char *fmt, ...); void modperl_trace_level_set(apr_file_t *logfile, const char *level); #endif /* MODPERL_COMMON_LOG_H */ 1.1 modperl-2.0/src/modules/perl/modperl_common_util.c Index: modperl_common_util.c =================================================================== /* Copyright 2000-2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* This file must not contain any symbols from apache/mod_perl (apr * and perl are OK). Also try to keep all the mod_perl specific * functions (even if they don't contain symbols from apache/mod_perl * on in modperl_util.c, unless we want them elsewhere. That is * needed in order to keep the libraries used outside mod_perl * small */ #include "modperl_common_util.h" MP_INLINE SV *modperl_hash_tie(pTHX_ const char *classname, SV *tsv, void *p) { SV *hv = (SV*)newHV(); SV *rsv = sv_newmortal(); sv_setref_pv(rsv, classname, p); sv_magic(hv, rsv, PERL_MAGIC_tied, Nullch, 0); return SvREFCNT_inc(sv_bless(sv_2mortal(newRV_noinc(hv)), gv_stashpv(classname, TRUE))); } MP_INLINE void *modperl_hash_tied_object(pTHX_ const char *classname, SV *tsv) { if (sv_derived_from(tsv, classname)) { if (SVt_PVHV == SvTYPE(SvRV(tsv))) { SV *hv = SvRV(tsv); MAGIC *mg; if (SvMAGICAL(hv)) { if ((mg = mg_find(hv, PERL_MAGIC_tied))) { return (void *)MgObjIV(mg); } else { Perl_warn(aTHX_ "Not a tied hash: (magic=%c)", mg); } } else { Perl_warn(aTHX_ "SV is not tied"); } } else { return (void *)SvObjIV(tsv); } } else { Perl_croak(aTHX_ "argument is not a blessed reference " "(expecting an %s derived object)", classname); } return NULL; } /* same as Symbol::gensym() */ SV *modperl_perl_gensym(pTHX_ char *pack) { GV *gv = newGVgen(pack); SV *rv = newRV((SV*)gv); (void)hv_delete(gv_stashpv(pack, TRUE), GvNAME(gv), GvNAMELEN(gv), G_DISCARD); return rv; } 1.1 modperl-2.0/src/modules/perl/modperl_common_util.h Index: modperl_common_util.h =================================================================== /* Copyright 2000-2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "modperl_common_includes.h" #ifndef MODPERL_COMMON_UTIL_H #define MODPERL_COMMON_UTIL_H #ifdef MP_DEBUG #define MP_INLINE #else #define MP_INLINE APR_INLINE #endif #ifdef WIN32 # define MP_FUNC_T(name) (_stdcall *name) /* XXX: not all functions get inlined * so its unclear what to and not to include in the .def files */ # undef MP_INLINE # define MP_INLINE #else # define MP_FUNC_T(name) (*name) #endif #define MP_SSTRLEN(string) (sizeof(string)-1) #ifndef strcaseEQ # define strcaseEQ(s1,s2) (!strcasecmp(s1,s2)) #endif #ifndef strncaseEQ # define strncaseEQ(s1,s2,l) (!strncasecmp(s1,s2,l)) #endif #ifndef SvCLASS #define SvCLASS(o) HvNAME(SvSTASH(SvRV(o))) #endif #define SvObjIV(o) SvIV((SV*)SvRV(o)) #define MgObjIV(m) SvIV((SV*)SvRV(m->mg_obj)) #define MP_SvGROW(sv, len) \ (void)SvUPGRADE(sv, SVt_PV); \ SvGROW(sv, len+1) #define MP_SvCUR_set(sv, len) \ SvCUR_set(sv, len); \ *SvEND(sv) = '\0'; \ SvPOK_only(sv) #define MP_magical_untie(sv, mg_flags) \ mg_flags = SvMAGICAL((SV*)sv); \ SvMAGICAL_off((SV*)sv) #define MP_magical_tie(sv, mg_flags) \ SvFLAGS((SV*)sv) |= mg_flags /* tie %hash */ MP_INLINE SV *modperl_hash_tie(pTHX_ const char *classname, SV *tsv, void *p); /* tied %hash */ MP_INLINE void *modperl_hash_tied_object(pTHX_ const char *classname, SV *tsv); SV *modperl_perl_gensym(pTHX_ char *pack); #endif /* MODPERL_COMMON_UTIL_H */ 1.1 modperl-2.0/src/modules/perl/modperl_debug.c Index: modperl_debug.c =================================================================== /* Copyright 2000-2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "mod_perl.h" char *modperl_server_desc(server_rec *s, apr_pool_t *p) { return apr_psprintf(p, "%s:%u", s->server_hostname, s->port); } /* used in debug traces */ MP_INLINE char *modperl_pid_tid(apr_pool_t *p) { return apr_psprintf(p, "%lu" #if APR_HAS_THREADS "/%lu" #endif /* APR_HAS_THREADS */ , (unsigned long)getpid() #if APR_HAS_THREADS , (unsigned long)apr_os_thread_current() #endif /* APR_HAS_THREADS */ ); } #ifdef MP_TRACE /* any non-false value for MOD_PERL_TRACE/PerlTrace enables this function */ void modperl_apr_table_dump(pTHX_ apr_table_t *table, char *name) { int i; const apr_array_header_t *array; apr_table_entry_t *elts; array = apr_table_elts(table); elts = (apr_table_entry_t *)array->elts; modperl_trace(MP_FUNC, "Contents of table %s", name); for (i = 0; i < array->nelts; i++) { if (!elts[i].key || !elts[i].val) { continue; } modperl_trace(MP_FUNC, "%s => %s", elts[i].key, elts[i].val); } } #endif #ifdef MP_TRACE void modperl_perl_modglobal_dump(pTHX) { HV *hv = PL_modglobal; AV *val; char *key; I32 klen; hv_iterinit(hv); MP_TRACE_g(MP_FUNC, "|-------- PL_modglobal --------"); #ifdef USE_ITHREADS MP_TRACE_g(MP_FUNC, "| perl 0x%lx", (unsigned long)aTHX); #endif MP_TRACE_g(MP_FUNC, "| PL_modglobal 0x%lx", (unsigned long)PL_modglobal); while ((val = (AV*)hv_iternextsv(hv, &key, &klen))) { MP_TRACE_g(MP_FUNC, "| %s => 0x%lx", key, val); } MP_TRACE_g(MP_FUNC, "|-------- PL_modglobal --------\n"); } #endif 1.1 modperl-2.0/src/modules/perl/modperl_debug.h Index: modperl_debug.h =================================================================== /* Copyright 2000-2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MODPERL_DEBUG_H #define MODPERL_DEBUG_H #include "mod_perl.h" char *modperl_server_desc(server_rec *s, apr_pool_t *p); MP_INLINE char *modperl_pid_tid(apr_pool_t *p); #ifdef MP_TRACE void modperl_apr_table_dump(pTHX_ apr_table_t *table, char *name); /* dump the contents of PL_modglobal */ void modperl_perl_modglobal_dump(pTHX); #endif #endif /* MODPERL_DEBUG_H */ 1.5 +0 -6 modperl-2.0/t/apr-ext/perlio.t Index: perlio.t =================================================================== RCS file: /home/cvs/modperl-2.0/t/apr-ext/perlio.t,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- perlio.t 28 Aug 2003 01:59:28 -0000 1.4 +++ perlio.t 16 Jun 2004 03:55:48 -0000 1.5 @@ -13,12 +13,6 @@ use Apache::TestUtil; use Apache::Build (); -# XXX: skip for now until the dependency on mod_perl symbols is resolved -# see STATUS for more info -# to see the problems run: -# env PERL_DL_NONLAZY=1 t/TEST -v apr-ext/perlio' -plan tests => 1, under_construction; - use Fcntl (); use File::Spec::Functions qw(catfile); 1.1 modperl-2.0/t/apr-ext/table.t Index: table.t =================================================================== use Apache::Test; use blib; use Apache2; plan tests => 1; require APR; require APR::Table; require APR::Pool; my $p = APR::Pool->new; my $table = APR::Table::make($p, 2); ok ref $table eq 'APR::Table'; 1.2 +26 -16 modperl-2.0/todo/bugs_apr_ext Index: bugs_apr_ext =================================================================== RCS file: /home/cvs/modperl-2.0/todo/bugs_apr_ext,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- bugs_apr_ext 17 Nov 2003 23:00:34 -0000 1.1 +++ bugs_apr_ext 16 Jun 2004 03:55:48 -0000 1.2 @@ -17,21 +17,31 @@ server-side as well as the client-side (normally env var aren't propogated to the server). -* APR::Table now depends on modperl_hash_tie, so it can't be used - outside mod_perl. should probably abstract this function into a new - utils.c object that can be linked by APR.so. +* APR::Pool relies on interpreter management function: + modperl_interp_unselect. At the moment I've worked around it by + defining an empty function in APR.xs. But a cleaner solution is + desirable. - Status: see the next item +* modules that we need to add tests for in apr-ext: + APR::Date + APR::Const + APR::URI + APR::Base64 + APR::String + APR::Error + APR::XSLoader + APR::PerlIO + APR::OS + APR::Socket + APR::Brigade + APR::Finfo + APR::Util + APR::Bucket + APR::NetLib + APR::ThreadMutex + APR::SockAddr -* APR::PerlIO needs an equivalent of modperl_perl_gensym - - Status: we need to abstract those function into a separate object, - which can be linked by APR.so. However I think we should probably - provide a static build and after that see how to do the linking - right. Otherwise we may have collisions with statically linked - symbols and the dynamic ones. - - APR::Pool relies on interpreter management functions and therefore - can't be used outside mod_perl. - - Status: \ No newline at end of file + I think that it's enough to just load them, since most of them are + already thoroughly tested under mod_perl. Then if we find some + running-outside-mod_perl specific bugs we can write specific tests + for those. 1.4 +1 -1 modperl-2.0/xs/APR/Makefile.PL Index: Makefile.PL =================================================================== RCS file: /home/cvs/modperl-2.0/xs/APR/Makefile.PL,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Makefile.PL 22 Mar 2003 07:21:37 -0000 1.3 +++ Makefile.PL 16 Jun 2004 03:55:48 -0000 1.4 @@ -2,6 +2,6 @@ use ModPerl::BuildMM (); ModPerl::BuildMM::WriteMakefile( - NAME => "APR", + NAME => "APR_build", VERSION => '0.01' ); 1.11 +17 -0 modperl-2.0/xs/APR/APR/APR.xs Index: APR.xs =================================================================== RCS file: /home/cvs/modperl-2.0/xs/APR/APR/APR.xs,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- APR.xs 4 Mar 2004 06:01:09 -0000 1.10 +++ APR.xs 16 Jun 2004 03:55:48 -0000 1.11 @@ -15,6 +15,12 @@ #include "mod_perl.h" +/* XXX: provide the missing symbol for APR::Pool as a tmp workaround */ +#ifndef modperl_interp_unselect +apr_status_t modperl_interp_unselect(void *data); +apr_status_t modperl_interp_unselect(void *data) { return APR_SUCCESS; } +#endif + #ifdef MP_HAVE_APR_LIBS # define APR_initialize apr_initialize # define APR_terminate apr_terminate @@ -41,6 +47,17 @@ /* XXX: mutex locking? */ apr_hook_global_pool = global_pool; } + { + apr_file_t *stderr_apr_handle; + apr_status_t rv = apr_file_open_stderr(&stderr_apr_handle, + apr_hook_global_pool); + if (rv != APR_SUCCESS) { + PerlIO_printf(PerlIO_stderr(), + "Fatal error: failed to open stderr "); + } + modperl_trace_level_set(stderr_apr_handle, NULL); + } + } #else # define extra_apr_init(aTHX) 1.20 +28 -0 modperl-2.0/xs/APR/APR/Makefile.PL Index: Makefile.PL =================================================================== RCS file: /home/cvs/modperl-2.0/xs/APR/APR/Makefile.PL,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- Makefile.PL 3 Jan 2004 01:17:33 -0000 1.19 +++ Makefile.PL 16 Jun 2004 03:55:48 -0000 1.20 @@ -54,4 +54,32 @@ $args{LIBS} = [$libs] if $libs; +my $srcdir = '../../../src/modules/perl'; + +# link the following into APR.so so other APR:: modules can be used +# outside of httpd +my @names = map { "modperl_$_" } (qw(error), + map { "common_$_" } qw(util log)); +my(@obj, @clean, %src); +for (@names) { + push @obj, join '.', $_, 'o'; + my $cfile = join '.', $_, 'c'; + push @clean, $cfile; + $src{$cfile} = "$srcdir/$cfile"; +} + +$args{OBJECT} = "APR.o @obj"; +$args{clean} = { FILES => "@clean" }; + ModPerl::BuildMM::WriteMakefile(%args); + +sub MY::postamble { + my $self = shift; + my $string = $self->ModPerl::BuildMM::MY::postamble; + + $string .= join '', map { + "$_: $src{$_}\n\t\$(CP) $src{$_} .\n"; + } keys %src; + + return $string; +} 1.41 +2 -13 modperl-2.0/xs/APR/PerlIO/apr_perlio.c Index: apr_perlio.c =================================================================== RCS file: /home/cvs/modperl-2.0/xs/APR/PerlIO/apr_perlio.c,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- apr_perlio.c 2 Jun 2004 18:49:21 -0000 1.40 +++ apr_perlio.c 16 Jun 2004 03:55:48 -0000 1.41 @@ -18,16 +18,6 @@ #include "mod_perl.h" #include "apr_perlio.h" -/* XXX: modperl_perl_gensym() cannot be used outside of httpd */ -static SV *apr_perlio_gensym(pTHX_ char *pack) -{ - GV *gv = newGVgen(pack); - SV *rv = newRV((SV*)gv); - (void)hv_delete(gv_stashpv(pack, TRUE), - GvNAME(gv), GvNAMELEN(gv), G_DISCARD); - return rv; -} - #if defined(PERLIO_LAYERS) && defined(PERLIO_K_MULTIARG) /* 5.7.2+ */ /********************************************************************** @@ -502,7 +492,7 @@ static SV *apr_perlio_PerlIO_to_glob(pTHX_ PerlIO *pio, apr_perlio_hook_e type) { - SV *retval = apr_perlio_gensym(aTHX_ "APR::PerlIO"); + SV *retval = modperl_perl_gensym(aTHX_ "APR::PerlIO"); GV *gv = (GV*)SvRV(retval); gv_IOadd(gv); @@ -594,8 +584,7 @@ SV *apr_perlio_apr_file_to_glob(pTHX_ apr_file_t *file, apr_pool_t *pool, apr_perlio_hook_e type) { - /* XXX: modperl_perl_gensym() cannot be used outside of httpd */ - SV *retval = apr_perlio_gensym(aTHX_ "APR::PerlIO"); + SV *retval = modperl_perl_gensym(aTHX_ "APR::PerlIO"); GV *gv = (GV*)SvRV(retval); gv_IOadd(gv); 1.4 +1 -1 modperl-2.0/xs/Apache/Makefile.PL Index: Makefile.PL =================================================================== RCS file: /home/cvs/modperl-2.0/xs/Apache/Makefile.PL,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Makefile.PL 22 Mar 2003 07:21:37 -0000 1.3 +++ Makefile.PL 16 Jun 2004 03:55:48 -0000 1.4 @@ -2,6 +2,6 @@ use ModPerl::BuildMM (); ModPerl::BuildMM::WriteMakefile( - NAME => "Apache", + NAME => "Apache_build", VERSION => '0.01' ); 1.165 +2 -2 modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm Index: FunctionTable.pm =================================================================== RCS file: /home/cvs/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v retrieving revision 1.164 retrieving revision 1.165 diff -u -r1.164 -r1.165 --- FunctionTable.pm 13 Jun 2004 05:39:08 -0000 1.164 +++ FunctionTable.pm 16 Jun 2004 03:55:48 -0000 1.165 @@ -4979,8 +4979,8 @@ 'name' => 'modperl_trace_level_set', 'args' => [ { - 'type' => 'server_rec *', - 'name' => 's' + 'type' => 'apr_file_t *', + 'name' => 'logfile' }, { 'type' => 'const char *',