stas        2004/07/02 15:43:17

  Modified:    src/modules/perl modperl_io_apache.c
               xs/Apache/RequestIO Apache__RequestIO.h
               xs/maps  modperl_functions.map
               xs/tables/current/ModPerl FunctionTable.pm
               .        Changes
  Log:
  - polishing Apache::RequestIO API and implementation
  - $r->read()/READ now throw exceptions
  - $r->rflush now returns nothing (was always returning APR::SUCCESS
  before)
  
  Revision  Changes    Path
  1.22      +15 -39    modperl-2.0/src/modules/perl/modperl_io_apache.c
  
  Index: modperl_io_apache.c
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_io_apache.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -u -r1.21 -r1.22
  --- modperl_io_apache.c       2 Jun 2004 21:35:58 -0000       1.21
  +++ modperl_io_apache.c       2 Jul 2004 22:43:16 -0000       1.22
  @@ -110,21 +110,13 @@
   {
       PerlIOApache *st = PerlIOSelf(f, PerlIOApache);
       request_rec *r = st->r;
  -    long total = 0;
   
       if (!(PerlIOBase(f)->flags & PERLIO_F_CANREAD) ||
           PerlIOBase(f)->flags & (PERLIO_F_EOF|PERLIO_F_ERROR)) {
           return 0;
       }
   
  -    total = modperl_request_read(aTHX_ r, (char*)vbuf, count);
  -
  -    if (total < 0) {
  -        PerlIOBase(f)->flags |= PERLIO_F_ERROR;
  -        /* modperl_request_read takes care of setting ERRSV */
  -    }
  -
  -    return total;
  +    return modperl_request_read(aTHX_ r, (char*)vbuf, count);
   }
   
   static SSize_t
  @@ -259,8 +251,8 @@
   MP_INLINE SSize_t modperl_request_read(pTHX_ request_rec *r,
                                          char *buffer, Size_t len)
   {
  -    long total = 0;
  -    int wanted = len;
  +    SSize_t total = 0;
  +    Size_t wanted = len;
       int seen_eos = 0;
       char *tmp = buffer;
       apr_bucket_brigade *bb;
  @@ -272,35 +264,22 @@
       bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
       if (bb == NULL) {
           r->connection->keepalive = AP_CONN_CLOSE;
  -        return -1;
  +        Perl_croak(aTHX_ "failed to create bucket brigade");
       }
   
       do {
           apr_size_t read;
  -        int rc;
  +        apr_status_t rc;
   
           rc = ap_get_brigade(r->input_filters, bb, AP_MODE_READBYTES,
                               APR_BLOCK_READ, len);
           if (rc != APR_SUCCESS) { 
  -            char *error;
  -            /* if we fail here, we want to just return and stop trying
  -             * to read data from the client.
  +            /* if we fail here, we want to stop trying to read data
  +             * from the client.
                */
               r->connection->keepalive = AP_CONN_CLOSE;
               apr_brigade_destroy(bb);
  -
  -            if (SvTRUE(ERRSV)) {
  -                STRLEN n_a;
  -                error = SvPV(ERRSV, n_a);
  -            }
  -            else {
  -                error = modperl_error_strerror(aTHX_ rc);
  -            }
  -            sv_setpv(ERRSV,
  -                     (char *)apr_psprintf(r->pool, 
  -                                          "failed to get bucket brigade: %s",
  -                                          error));
  -            return -1;
  +            modperl_croak(aTHX_ rc, "Apache::RequestIO::read");
           }
   
           /* If this fails, it means that a filter is written
  @@ -312,11 +291,11 @@
               apr_brigade_destroy(bb);
               /* we can't tell which filter is broken, since others may
                * just pass data through */
  -            sv_setpv(ERRSV, "Aborting read from client. "
  -                     "One of the input filters is broken. "
  -                     "It returned an empty bucket brigade for "
  -                     "the APR_BLOCK_READ mode request");
  -            return -1;
  +            Perl_croak(aTHX_ "Apache::RequestIO::read: "
  +                       "Aborting read from client. "
  +                       "One of the input filters is broken. "
  +                       "It returned an empty bucket brigade for "
  +                       "the APR_BLOCK_READ mode request");
           }
   
           if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(bb))) {
  @@ -327,12 +306,9 @@
           rc = apr_brigade_flatten(bb, tmp, &read);
           if (rc != APR_SUCCESS) {
               apr_brigade_destroy(bb);
  -            sv_setpv(ERRSV,
  -                     (char *)apr_psprintf(r->pool, 
  -                                          "failed to read: %s",
  -                                          modperl_error_strerror(aTHX_ rc)));
  -            return -1;
  +            modperl_croak(aTHX_ rc, "Apache::RequestIO::read");
           }
  +        
           total += read;
           tmp   += read;
           len   -= read;
  
  
  
  1.51      +15 -20    modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h
  
  Index: Apache__RequestIO.h
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -u -r1.50 -r1.51
  --- Apache__RequestIO.h       1 Jul 2004 21:19:19 -0000       1.50
  +++ Apache__RequestIO.h       2 Jul 2004 22:43:17 -0000       1.51
  @@ -131,26 +131,26 @@
   }  
   
   /* alias */
  -#define mpxs_Apache__RequestRec_WRITE(r, buffer, bufsiz, offset) \
  -    mpxs_Apache__RequestRec_write(aTHX_ r, buffer, bufsiz, offset)
  +#define mpxs_Apache__RequestRec_WRITE(r, buffer, len, offset) \
  +    mpxs_Apache__RequestRec_write(aTHX_ r, buffer, len, offset)
   
   static MP_INLINE
   apr_size_t mpxs_Apache__RequestRec_write(pTHX_ request_rec *r,
  -                                         SV *buffer, apr_size_t bufsiz,
  -                                         int offset)
  +                                         SV *buffer, apr_size_t len,
  +                                         apr_off_t offset)
   {
  -    apr_size_t wlen = bufsiz;
  +    apr_size_t wlen;
       const char *buf;
  -    STRLEN svlen;
  +    STRLEN avail;
       MP_dRCFG;
   
  -    buf = (const char *)SvPV(buffer, svlen);
  +    buf = (const char *)SvPV(buffer, avail);
   
  -    if (bufsiz == -1) {
  -        wlen = offset ? svlen - offset : svlen;
  +    if (len == -1) {
  +        wlen = offset ? avail - offset : avail;
       }
       else {
  -        wlen = bufsiz;
  +        wlen = len;
       }
   
       MP_CHECK_WBUCKET_INIT("$r->write");
  @@ -162,7 +162,7 @@
   }
   
   static MP_INLINE
  -int mpxs_Apache__RequestRec_rflush(pTHX_ I32 items,
  +void mpxs_Apache__RequestRec_rflush(pTHX_ I32 items,
                                      SV **MARK, SV **SP)
   {
       modperl_config_req_t *rcfg;
  @@ -180,8 +180,6 @@
                                 rcfg->wbucket->outcnt));
       MP_RUN_CROAK(modperl_wbucket_flush(rcfg->wbucket, TRUE),
                    "Apache::RequestIO::rflush");
  -
  -    return APR_SUCCESS;
   }
   
   static MP_INLINE long mpxs_ap_get_client_block(pTHX_ request_rec *r,
  @@ -229,10 +227,10 @@
       mpxs_Apache__RequestRec_read(aTHX_ r, bufsv, len, offset)
   
   static SV *mpxs_Apache__RequestRec_read(pTHX_ request_rec *r,
  -                                         SV *bufsv, int len,
  -                                         int offset)
  +                                         SV *bufsv, apr_size_t len,
  +                                         apr_off_t offset)
   {
  -    long total;
  +    SSize_t total;
   
       if (!SvOK(bufsv)) {
           sv_setpvn(bufsv, "", 0);
  @@ -252,11 +250,8 @@
           mpxs_sv_cur_set(bufsv, offset+total);
           SvTAINTED_on(bufsv);
       } 
  -    else if (total == 0) {
  -        sv_setpvn(bufsv, "", 0);
  -    }
       else {
  -        return &PL_sv_undef;
  +        sv_setpvn(bufsv, "", 0);
       }
   
       return newSViv(total);
  
  
  
  1.75      +5 -5      modperl-2.0/xs/maps/modperl_functions.map
  
  Index: modperl_functions.map
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/maps/modperl_functions.map,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -u -r1.74 -r1.75
  --- modperl_functions.map     4 Jun 2004 03:20:46 -0000       1.74
  +++ modperl_functions.map     2 Jul 2004 22:43:17 -0000       1.75
  @@ -55,11 +55,11 @@
    SV *:DEFINE_UNTIE    | | request_rec *:r, int:refcnt
    mpxs_Apache__RequestRec_sendfile | | r, filename=r->filename, offset=0, len=0
    mpxs_Apache__RequestRec_read | | r, bufsv, len, offset=0
  - SV *:DEFINE_READ | | request_rec *:r, SV *:bufsv, int:len, int:offset=0
  - mpxs_Apache__RequestRec_write | | r, buffer, bufsiz=-1, offset=0
  + SV *:DEFINE_READ | | request_rec *:r, SV *:bufsv, apr_size_t:len, 
apr_off_t:offset=0
  + mpxs_Apache__RequestRec_write | | r, buffer, len=-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
  + apr_size_t:DEFINE_WRITE | | \
  +             request_rec *:r, SV *:buffer, apr_size_t:len=-1, apr_off_t:offset=0
    mpxs_Apache__RequestRec_rflush | | ...
    mpxs_Apache__RequestRec_GETC
    mpxs_Apache__RequestRec_OPEN | | SV *:self, SV *:arg1, SV *:arg2=Nullsv
  @@ -99,7 +99,7 @@
    mpxs_Apache__Filter_remove   | | ...
   
    SV *:DEFINE_TIEHANDLE | | SV *:stashsv, SV *:sv=Nullsv
  - int:DEFINE_PRINT      | | ...
  + apr_size_t:DEFINE_PRINT      | | ...
   
   MODULE=Apache::Filter PACKAGE=Apache::RequestRec
    mpxs_Apache__RequestRec_add_input_filter
  
  
  
  1.167     +6 -6      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.166
  retrieving revision 1.167
  diff -u -u -r1.166 -r1.167
  --- FunctionTable.pm  29 Jun 2004 22:56:17 -0000      1.166
  +++ FunctionTable.pm  2 Jul 2004 22:43:17 -0000       1.167
  @@ -2,7 +2,7 @@
   
   # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   # ! WARNING: generated by ModPerl::ParseSource/0.01
  -# !          Sun Jun 13 07:53:14 2004
  +# !          Fri Jul  2 15:05:46 2004
   # !          do NOT edit, any changes will be lost !
   # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   
  @@ -6514,17 +6514,17 @@
           'name' => 'bufsv'
         },
         {
  -        'type' => 'int',
  +        'type' => 'apr_size_t',
           'name' => 'len'
         },
         {
  -        'type' => 'int',
  +        'type' => 'apr_off_t',
           'name' => 'offset'
         }
       ]
     },
     {
  -    'return_type' => 'int',
  +    'return_type' => 'void',
       'name' => 'mpxs_Apache__RequestRec_rflush',
       'args' => [
         {
  @@ -6665,10 +6665,10 @@
         },
         {
           'type' => 'apr_size_t',
  -        'name' => 'bufsiz'
  +        'name' => 'len'
         },
         {
  -        'type' => 'int',
  +        'type' => 'apr_off_t',
           'name' => 'offset'
         }
       ]
  
  
  
  1.398     +5 -0      modperl-2.0/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/Changes,v
  retrieving revision 1.397
  retrieving revision 1.398
  diff -u -u -r1.397 -r1.398
  --- Changes   2 Jul 2004 01:25:52 -0000       1.397
  +++ Changes   2 Jul 2004 22:43:17 -0000       1.398
  @@ -12,6 +12,11 @@
   
   =item 1.99_15-dev
   
  +$r->read()/READ now throw exceptions [Stas]
  +
  +$r->rflush now returns nothing (was always returning APR::SUCCESS
  +before) [Stas]
  +
   bug reports generating code: [Stas]
   - add (apr|apu)-config linking info
   - show the full path to the config file used to get the data for the
  
  
  

Reply via email to