--------------------- PatchSet 4884 Date: 2007/06/26 09:34:34 Author: adri Branch: squid3_adri Tag: (none) Log: Handle partially-written iovec entries. Members: src/comm.cc:1.74.6.3->1.74.6.4 Index: squid3/src/comm.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/comm.cc,v retrieving revision 1.74.6.3 retrieving revision 1.74.6.4 diff -u -r1.74.6.3 -r1.74.6.4 --- squid3/src/comm.cc 26 Jun 2007 08:54:43 -0000 1.74.6.3 +++ squid3/src/comm.cc 26 Jun 2007 09:34:34 -0000 1.74.6.4 @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.74.6.3 2007/06/26 08:54:43 adri Exp $ + * $Id: comm.cc,v 1.74.6.4 2007/06/26 09:34:34 adri Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -1919,15 +1919,21 @@ cursize -= state->wv.iov[i].iov_len; } - /* For now, since I'm cheap, assume we've written all of an iovec, we'll - * do the partial stuff later */ - assert(cursize == 0); - /* Shift the iovec's down and update iovcnt */ memmove(&state->wv.iov[0], &state->wv.iov[i], sizeof(struct iovec) * (state->wv.iovcnt - i)); state->wv.iovcnt -= i; assert(state->wv.iovcnt > 0); + /* Fix the head if we only partially wrote the head entry */ + if (cursize > 0) { + // [ahc] why can't I just use a static cast to do this iov_base += cursize ? + char *a; + a = (char *) state->wv.iov[0].iov_base; + a += cursize; + state->wv.iov[0].iov_base = a; + state->wv.iov[0].iov_len -= cursize; + } + /* Register for another trip through the loop */ commSetSelect(fd, COMM_SELECT_WRITE, commHandleWriteV, state, 0); }