--------------------- PatchSet 10649 Date: 2008/07/15 15:59:54 Author: adri Branch: delay_pool_write Tag: (none) Log: Shoehorn in a delayid into CommWriteState and begin fleshing out the write-side delay pool hackery. Members: src/comm.c:1.60->1.60.2.1 src/protos.h:1.170->1.170.2.1 src/structs.h:1.188->1.188.2.1 Index: squid/src/comm.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/comm.c,v retrieving revision 1.60 retrieving revision 1.60.2.1 diff -u -r1.60 -r1.60.2.1 --- squid/src/comm.c 27 Jun 2008 16:52:31 -0000 1.60 +++ squid/src/comm.c 15 Jul 2008 15:59:54 -0000 1.60.2.1 @@ -1,6 +1,6 @@ /* - * $Id: comm.c,v 1.60 2008/06/27 16:52:31 squidadm Exp $ + * $Id: comm.c,v 1.60.2.1 2008/07/15 15:59:54 adri Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -1188,6 +1188,9 @@ { int len = 0; int nleft; +#if DELAY_POOLS + int writesz; +#endif CommWriteStateData *state = &fd_table[fd].rwstate; assert(state->valid); @@ -1195,13 +1198,35 @@ debug(5, 5) ("commHandleWrite: FD %d: off %ld, hd %ld, sz %ld.\n", fd, (long int) state->offset, (long int) state->header_size, (long int) state->size); + /* Find the maximum size for this write */ + if (state->offset < state->header_size) + writesz = state->header_size - state->offset; + else + writesz = state->size + state->header_size - state->offset; + +#if DELAY_POOLS + if (state->delayid) { + writesz = delayBytesWanted(state->delayid, 0, writesz); + /* + * If the bucket is empty then we push ourselves onto the slow write fds + * list and worry about the write later. + */ + + /* Ok we have some bytes to write; write them */ + } +#endif + nleft = state->size + state->header_size - state->offset; if (state->offset < state->header_size) - len = FD_WRITE_METHOD(fd, state->header + state->offset, state->header_size - state->offset); + len = FD_WRITE_METHOD(fd, state->header + state->offset, writesz); else - len = FD_WRITE_METHOD(fd, state->buf + state->offset - state->header_size, nleft); + len = FD_WRITE_METHOD(fd, state->buf + state->offset - state->header_size, writesz); debug(5, 5) ("commHandleWrite: write() returns %d\n", len); fd_bytes(fd, len, FD_WRITE); +#if DELAY_POOLS + /* Is this enough for per-client pools? Possibly not */ + delayBytesIn(state->delayid, len); +#endif statCounter.syscalls.sock.writes++; if (len == 0) { @@ -1247,6 +1272,22 @@ +#if DELAY_POOLS +/* + * Map a given comm_write() into the given delay_id for delay pools. + * This call should be made -immediately after- a comm_write*() call to push said + * comm_write into a delay pool. Eventually it should be folded into the + * comm_write() function calls. + */ +void +comm_write_set_delaypool(int fd, delay_id delayid) +{ + CommWriteStateData *state = &fd_table[fd].rwstate; + assert(state->valid); + state->delayid = delayid; +} +#endif + /* Select for Writing on FD, until SIZE bytes are sent. Call * *HANDLER when complete. */ void @@ -1267,6 +1308,9 @@ state->handler_data = handler_data; state->free_func = free_func; state->valid = 1; +#if DELAY_POOLS + state->delayid = 0; /* no pool */ +#endif cbdataLock(handler_data); commSetSelect(fd, COMM_SELECT_WRITE, commHandleWrite, NULL, 0); } Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.170 retrieving revision 1.170.2.1 diff -u -r1.170 -r1.170.2.1 --- squid/src/protos.h 11 Jul 2008 19:54:22 -0000 1.170 +++ squid/src/protos.h 15 Jul 2008 15:59:54 -0000 1.170.2.1 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.170 2008/07/11 19:54:22 squidadm Exp $ + * $Id: protos.h,v 1.170.2.1 2008/07/15 15:59:54 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -179,6 +179,7 @@ extern void comm_add_close_handler(int fd, PF *, void *); extern void comm_remove_close_handler(int fd, PF *, void *); extern int comm_udp_sendto(int, const struct sockaddr_in *, int, const void *, int); +extern void comm_write_set_delaypool(int fd, delay_id poolid); extern void comm_write(int fd, const char *buf, int size, Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.188 retrieving revision 1.188.2.1 diff -u -r1.188 -r1.188.2.1 --- squid/src/structs.h 11 Jul 2008 19:54:22 -0000 1.188 +++ squid/src/structs.h 15 Jul 2008 15:59:55 -0000 1.188.2.1 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.188 2008/07/11 19:54:22 squidadm Exp $ + * $Id: structs.h,v 1.188.2.1 2008/07/15 15:59:55 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -897,6 +897,9 @@ FREE *free_func; char header[32]; size_t header_size; +#if DELAY_POOLS + delay_id delayid; +#endif };