Re: mod_perl programming logic error

1999-11-03 Thread Doug MacEachern

> thanks Michael!  I've committed your change to the cvs tree.

actually, Eric Cholet did, mine failed, cvs rocks.  need more coffee.

cvs server: Up-to-date check failed for `Changes'
cvs server: Up-to-date check failed for `src/modules/perl/Apache.xs'
cvs [server aborted]: correct above errors first!
cvs commit: saving log message in /tmp/cvs00820baa




Re: mod_perl programming logic error

1999-11-03 Thread Doug MacEachern

> Granted we're running an older copy of mod_perl; but when we noticed
> that we were getting hammered by the spam of "rwrite returned -1"
> in our log files, I took a look at the source code.  I then compared
> it to the current source code; I believe I have found a programming
> logic error that is still in the current version.  Below is the
> code (from the current version) that I believe needs to be modified
> for correctness (in the write_client function):

thanks Michael!  I've committed your change to the cvs tree.  so this
explains why people were being hammered with the "rwrite -1" message, not
just because of using 1.2.6, but -DAPACHE_SSL.



Re: mod_perl programming logic error

1999-11-03 Thread Vivek Khera

> "MD" == Michael Douglass <[EMAIL PROTECTED]> writes:

MD> Notice that if len < HUGE_STRING_LEN; we REQUEST to write 'len' bytes,
MD> but we only write 'sent' bytes.  If 0 < sent < len; then we iterate
MD> back over this while loop because len > 0 after the len -= sent command.
MD> On the next write, however, we are rewriting from the position the
MD> buffer had on the LAST write because the buffer was not incremented.

MD> Notice also, that if len >= HUGE_STRING_LEN that we are requesting
MD> to write HUGE_STRING_LEN bytes; but we only write 'sent' bytes.  Now,
MD> if sent < HUGE_STRING_LEN, then we decrement our len by the correct
MD> number of bytes--but we increment our buffer HUGE_STRING_LEN - sent
MD> bytes beyond the correct position.

Both excellent catches.  I agree with your reasoning and your fix.
I'll leave it to DougM to incorporate into the CVS tree, hopefully
soon!

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.Khera Communications, Inc.
Internet: [EMAIL PROTECTED]   Rockville, MD   +1-301-545-6996
PGP & MIME spoken herehttp://www.kciLink.com/home/khera/



mod_perl programming logic error

1999-11-02 Thread Michael Douglass


(Note: I'm no longer on the mailing list; so if you wish to respond
to me, please be certain to include my email address in the response.
Also, [EMAIL PROTECTED] no longer works FYI.  Thanks.)

Granted we're running an older copy of mod_perl; but when we noticed
that we were getting hammered by the spam of "rwrite returned -1"
in our log files, I took a look at the source code.  I then compared
it to the current source code; I believe I have found a programming
logic error that is still in the current version.  Below is the
code (from the current version) that I believe needs to be modified
for correctness (in the write_client function):

while(len > 0) {
sent = 0;
if(len < HUGE_STRING_LEN) {
sent = rwrite(buffer, len, r);
}
else {
sent = rwrite(buffer, HUGE_STRING_LEN, r);
buffer += HUGE_STRING_LEN;
}
if(sent < 0) {
rwrite_neg_trace(r);
break;
}
len -= sent;
RETVAL += sent;
}

Notice that if len < HUGE_STRING_LEN; we REQUEST to write 'len' bytes,
but we only write 'sent' bytes.  If 0 < sent < len; then we iterate
back over this while loop because len > 0 after the len -= sent command.
On the next write, however, we are rewriting from the position the
buffer had on the LAST write because the buffer was not incremented.

Notice also, that if len >= HUGE_STRING_LEN that we are requesting
to write HUGE_STRING_LEN bytes; but we only write 'sent' bytes.  Now,
if sent < HUGE_STRING_LEN, then we decrement our len by the correct
number of bytes--but we increment our buffer HUGE_STRING_LEN - sent
bytes beyond the correct position.

Below is code that corrects for these counting errors.  I've consolidated
the rwrite into one command using the ?: operator to decide the length
to request be written.  Then I've incremented buffer by the correct the
amount sent--no matter what is written this incrementation will be correct.

while(len > 0) {
sent = rwrite (buffer,
  (len