You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Jerry Zhou <zh...@ugsolutions.com> on 2001/02/27 23:15:58 UTC

mod_isapi/7327: WriteClient doesn't work

>Number:         7327
>Category:       mod_isapi
>Synopsis:       WriteClient doesn't work
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    apache
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Tue Feb 27 14:20:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     zhou@ugsolutions.com
>Release:        2.0a9
>Organization:
apache
>Environment:
Windows NT 4.0 Service Pack 6
Visual Studio 6.0
>Description:
First, it failed to create bucket (see code below). After I fixed the bug, WriteClient works only for buffer less than 4096 bytes. 

If I provide a buffer larger than 4096 bytes (defined as DEFAULT_BUCKET_SIZE in ap_buckets_heap.c), it will be chopped. The Content-Length is still correct, causing the client to wait for more data that will never arrive. 

If I divide the buffer into small sizes and call WriteClient multiple times, the data will be all send out, but the Content-Length was put into a bucket the first time it reaches an eos, causing the client to read only the first buffer and discard all the remaining buffers.
>How-To-Repeat:
Call WriteClient with a buffer larger than 4096 bytes.
Or, devide the buffer into small ones and call WriteClient multiple times.
>Fix:
Here is my suggestion. It works as I tested.

BOOL WINAPI WriteClient (HCONN ConnID, LPVOID Buffer, LPDWORD lpwdwBytes,
                         DWORD dwReserved)
{
    request_rec *r = ((isapi_cid *)ConnID)->r;
    ap_bucket_brigade *bb;
    ap_bucket *b;

    if (dwReserved == HSE_IO_SYNC)
        ; /* XXX: Fake it */

    bb = ap_brigade_create(r->pool);
	/***************** JJZ: Is this a bug?
    b = ap_bucket_create_transient(Buffer, (apr_size_t)lpwdwBytes);
	******************/
    b = ap_bucket_create_transient(Buffer, (apr_size_t)*lpwdwBytes);
    AP_BRIGADE_INSERT_TAIL(bb, b);
	/***************** JJZ: eos caused Content-Length less than total of WriteClient
    b = ap_bucket_create_eos();
    AP_BRIGADE_INSERT_TAIL(bb, b);
	******************/
    ap_pass_brigade(r->output_filters, bb);

    return TRUE;
}
>Release-Note:
>Audit-Trail:
>Unformatted:
 [In order for any reply to be added to the PR database, you need]
 [to include <ap...@Apache.Org> in the Cc line and make sure the]
 [subject line starts with the report component and number, with ]
 [or without any 'Re:' prefixes (such as "general/1098:" or      ]
 ["Re: general/1098:").  If the subject doesn't match this       ]
 [pattern, your message will be misfiled and ignored.  The       ]
 ["apbugs" address is not added to the Cc line of messages from  ]
 [the database automatically because of the potential for mail   ]
 [loops.  If you do not include this Cc, your reply may be ig-   ]
 [nored unless you are responding to an explicit request from a  ]
 [developer.  Reply only with text; DO NOT SEND ATTACHMENTS!     ]