httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Olly Stephens <>
Subject upload hangs when file is multiple of 64K size
Date Thu, 14 Sep 2006 21:25:39 GMT

I discovered this bug in a huge chunk of code that deals with huge 
uploads and it took me *ages* to work out what was causing it.  But once 
I had, I whittled it down to a small testcase.  Any upload whose size is 
an exact multiple of 64K (which appears to be the block size used by the 
filter code) will hang during the parse, eventually timing out.

I'm using apreq2-2.08 with httpd-2.2.3 on solaris 10.  It's a 64-bit build.

The code that I use to reproduce this (just to make sure I'm not doing 
something wrong) is:

static int apreqbug_handler(request_rec *r)
     apreq_handle_t      *apreq ;
     const apr_table_t   *paramt ;
     const apreq_param_t *param ;
     apr_status_t         status ;
     apr_size_t           size ;
     char                 buf[256] ;

     if (strcmp(r->handler, "apreqbug")) {
       return DECLINED ;
     r->content_type = "text/html";

     if (r->method_number != M_POST) {
       ap_rputs("Not a POST request\n", r) ;
       return OK ;

     apreq = apreq_handle_apache2(r) ;
     status = apreq_body(apreq, &paramt) ;
     if (status != APR_SUCCESS) {
       ap_rputs("Failed to get apreq params\n", r) ;
       return OK ;
     param = apreq_upload(paramt, "upload");
     if (param == NULL) {
       ap_rputs("No upload parameter provided\n", r) ;
       return OK ;
     status = apr_brigade_length(param->upload, 0, &size) ;
     if (status != APR_SUCCESS) {
       ap_rputs("Failed to get length of upload\n", r) ;
       return OK ;
     sprintf(buf, "upload size is %ld\n", size) ;
     ap_rputs(buf, r) ;
     return OK ;

I'm using curl to upload test files to it.

Uploading a 65535 byte file, or a 65537 byte file works fine; uploading 
a 65536 byte file (or any exact multiple) hangs in the apreq_body() call 
and finally fails with a brigade timeout error.

Am I doing something wrong in my code?

If not, can anyone else reproduce this problem? (if so, is it a 
solaris-specific issue?)

Finally, any hints on how to go about debugging it would be most welcome.

Thanks in advance,


View raw message