On Wed, Sep 12, 2001 at 09:31:30AM -0700, Doug MacEachern wrote:
> On Tue, 11 Sep 2001, Philippe M . Chiasson wrote:
>
> > Here is my second attempt at $r->print(), notice I removed the MP_USE_AP_RWRITE
> > since it wasn't needed anymore.
> >
> > All test still pass with my patch applied.
> >
> > Here is the patch #2 and I even think it's proprely indented ;-)
>
> looks good. i didn't notice the first time, but why ap_rvprint? since
> the function does not exist in apache, just make a modperl specific
> mpxs_Apache__RequestRec_print
The only reason is that I am slowly starting to understand how all the XS
stuff gets discovered/parsed/written, and I have to play around with cut and
paste ;-) I am starting to understand how it works better every day and I promised
Stas that I would write something about my experience this week-end.
>
> style is much better, thanks :)
I try ;-)
> just missing alignment here:
>
> > +static MP_INLINE apr_size_t mpxs_ap_rvprint(pTHX_ I32 items,
> > + SV ** MARK, SV ** SP)
>
> and this:
> > + if(IoFLUSH(PL_defoutgv)){
> should be:
> if (...) {
fixed.
Index: lib/Apache/compat.pm
===================================================================
RCS file: /home/anoncvs/mod_perl-2-cvs/lib/Apache/compat.pm,v
retrieving revision 1.11
diff -u -I'$Id' -I'$Revision' -r1.11 compat.pm
--- lib/Apache/compat.pm 2001/09/13 04:41:44 1.11
+++ lib/Apache/compat.pm 2001/09/14 13:40:50
@@ -111,8 +111,6 @@
#XXX resolve '.' in @INC to basename $r->filename
}
-*print = \&puts;
-
sub finfo {
my $r = shift;
stat $r->filename;
Index: t/response/TestAPI/request_rec.pm
===================================================================
RCS file: /home/anoncvs/mod_perl-2-cvs/t/response/TestAPI/request_rec.pm,v
retrieving revision 1.5
diff -u -I'$Id' -I'$Revision' -r1.5 request_rec.pm
--- t/response/TestAPI/request_rec.pm 2001/09/08 18:26:46 1.5
+++ t/response/TestAPI/request_rec.pm 2001/09/14 13:40:51
@@ -8,7 +8,7 @@
sub handler {
my $r = shift;
- plan $r, tests => 37;
+ plan $r, tests => 40;
#Apache->request($r); #PerlOptions +GlobalRequest takes care
my $gr = Apache->request;
@@ -88,6 +88,15 @@
#no_cache
ok $r->no_cache || 1;
+
+ {
+ local $| = 0;
+ ok 9 == $r->print("buffered\n");
+ ok 0 == $r->print();
+ local $| = 1;
+ ok 13 == $r->print('n','o','t',' ','b','u','f','f','e','r','e','d',"\n");
+ }
+
#no_local_copy
Index: todo/api.txt
===================================================================
RCS file: /home/anoncvs/mod_perl-2-cvs/todo/api.txt,v
retrieving revision 1.2
diff -u -I'$Id' -I'$Revision' -r1.2 api.txt
--- todo/api.txt 2001/09/08 18:26:46 1.2
+++ todo/api.txt 2001/09/14 13:40:51
@@ -68,9 +68,6 @@
however, $r->sendfile is a new function that opens the file for you
and calls ap_send_fd() underneath.
-$r->print:
-does not yet honor $|
-
$r->{hard,reset,soft,kill}_timeout:
do not exist in 2.0. should be deprecated. consider adding noops in
Apache::compat
Index: xs/Apache/RequestIO/Apache__RequestIO.h
===================================================================
RCS file: /home/anoncvs/mod_perl-2-cvs/xs/Apache/RequestIO/Apache__RequestIO.h,v
retrieving revision 1.12
diff -u -I'$Id' -I'$Revision' -r1.12 Apache__RequestIO.h
--- xs/Apache/RequestIO/Apache__RequestIO.h 2001/06/20 23:59:37 1.12
+++ xs/Apache/RequestIO/Apache__RequestIO.h 2001/09/14 13:40:51
@@ -1,17 +1,8 @@
#define mpxs_Apache__RequestRec_TIEHANDLE(stashsv, sv) \
modperl_newSVsv_obj(aTHX_ stashsv, sv)
-#define mpxs_Apache__RequestRec_PRINT mpxs_ap_rvputs
+#define mpxs_Apache__RequestRec_PRINT mpxs_Apache__RequestRec_print
-#if 0
-#define MP_USE_AP_RWRITE
-#endif
-
-#ifdef MP_USE_AP_RWRITE
-
-#define mpxs_call_rwrite(r,buf,len) \
-ap_rwrite(buf, len, r)
-
#define mpxs_rwrite_loop(func,obj) \
while (MARK <= SP) { \
STRLEN len; \
@@ -21,8 +12,6 @@
MARK++; \
}
-#endif
-
static MP_INLINE apr_size_t mpxs_ap_rvputs(pTHX_ I32 items,
SV **MARK, SV **SP)
{
@@ -39,11 +28,7 @@
MP_START_TIMES();
-#ifdef MP_USE_AP_RWRITE
- mpxs_rwrite_loop(mpxs_call_rwrite, r);
-#else
mpxs_write_loop(modperl_wbucket_write, &rcfg->wbucket);
-#endif
MP_END_TIMES();
MP_PRINT_TIMES("r->puts");
@@ -52,6 +37,33 @@
return bytes;
}
+
+static MP_INLINE apr_size_t mpxs_Apache__RequestRec_print(pTHX_ I32 items,
+ SV **
+MARK, SV ** SP)
+{
+ modperl_config_srv_t *scfg;
+ modperl_config_req_t *rcfg;
+ request_rec *r;
+
+ /* bytes must be called bytes */
+ apr_size_t bytes = 0;
+
+ /* this also magically assings to r ;-) */
+ mpxs_usage_va_1(r, "$r->print(...)");
+
+ rcfg = modperl_config_req_get(r);
+ scfg = modperl_config_srv_get(r->server);
+
+ mpxs_write_loop(modperl_wbucket_write, &rcfg->wbucket);
+
+ /* if ($|) */
+ if (IoFLUSH(PL_defoutgv)){
+ modperl_wbucket_flush(&rcfg->wbucket);
+ ap_rflush(r);
+ }
+
+ return bytes;
+}
/* alias */
#define mpxs_Apache__RequestRec_WRITE mpxs_Apache__RequestRec_write
Index: xs/maps/modperl_functions.map
===================================================================
RCS file: /home/anoncvs/mod_perl-2-cvs/xs/maps/modperl_functions.map,v
retrieving revision 1.18
diff -u -I'$Id' -I'$Revision' -r1.18 modperl_functions.map
--- xs/maps/modperl_functions.map 2001/09/13 04:41:44 1.18
+++ xs/maps/modperl_functions.map 2001/09/14 13:40:51
@@ -21,6 +21,7 @@
mpxs_Apache__RequestRec_read | | r, buffer, bufsiz, offset=0
long:DEFINE_READ | | request_rec *:r, SV *:buffer, int:bufsiz, int:offset=0
mpxs_Apache__RequestRec_write | | r, buffer, bufsiz=-1, offset=0
+ mpxs_Apache__RequestRec_print | | ...
apr_ssize_t:DEFINE_WRITE | | \
request_rec *:r, SV *:buffer, apr_ssize_t:bufsiz=-1, int:offset=0
Index: xs/tables/current/ModPerl/FunctionTable.pm
===================================================================
RCS file: /home/anoncvs/mod_perl-2-cvs/xs/tables/current/ModPerl/FunctionTable.pm,v
retrieving revision 1.24
diff -u -I'$Id' -I'$Revision' -r1.24 FunctionTable.pm
--- xs/tables/current/ModPerl/FunctionTable.pm 2001/09/13 04:41:44 1.24
+++ xs/tables/current/ModPerl/FunctionTable.pm 2001/09/14 13:40:51
@@ -3400,6 +3400,28 @@
]
},
{
+ 'return_type' => 'apr_size_t',
+ 'name' => 'mpxs_Apache__RequestRec_print',
+ 'args' => [
+ {
+ 'type' => 'PerlInterpreter *',
+ 'name' => 'my_perl'
+ },
+ {
+ 'type' => 'I32',
+ 'name' => 'items'
+ },
+ {
+ 'type' => 'SV **',
+ 'name' => 'mark'
+ },
+ {
+ 'type' => 'SV **',
+ 'name' => 'sp'
+ }
+ ]
+ },
+ {
'return_type' => 'int',
'name' => 'mpxs_Apache__RequestRec_push_handlers',
'args' => [
--
Philippe M. Chiasson <[EMAIL PROTECTED]>
Extropia's Resident System Guru
http://www.eXtropia.com/
Had to create %s unexpectedly : A routine asked for a
symbol from a symbol table that ought to have existed
already, but for some reason it didn't, and had to be
created on an emergency basis to prevent a core dump.
-- perldiag(1)
perl -e '$$=\${gozer};{$_=unpack(P26,pack(L,$$));/^Just Another Perl
Hacker!\n$/&&print||$$++&&redo}'
PGP signature