--------------------- PatchSet 7076 Date: 2005/10/07 03:23:11 Author: adri Branch: tidyup_deferred_reads Tag: (none) Log: * extend the STKICK callback now to take a kick type, allowing us to hint to the server side it should start/stop/run IO (running being the 'current' way where it just always puts itself ready for IO) * tidy up the callback functions to actually check whether the cbdata is valid. Wow, I can't believe I forgot /that/.. * start calling the stop/start callbacks but don't actually use them yet in the HTTP code. This still isn't tested and I'm not seeing anywhere near enough 'kick' calls to match my 'wait' calls. Members: src/enums.h:1.29.2.14.10.2->1.29.2.14.10.3 src/http.c:1.17.6.27.4.11->1.17.6.27.4.12 src/protos.h:1.41.6.22.6.2->1.41.6.22.6.3 src/store.c:1.16.6.7.10.4->1.16.6.7.10.5 src/store_client.c:1.9.6.2.20.2->1.9.6.2.20.3 src/structs.h:1.48.2.34.4.5->1.48.2.34.4.6 src/typedefs.h:1.25.6.6.12.3->1.25.6.6.12.4 Index: squid/src/enums.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/enums.h,v retrieving revision 1.29.2.14.10.2 retrieving revision 1.29.2.14.10.3 diff -u -r1.29.2.14.10.2 -r1.29.2.14.10.3 --- squid/src/enums.h 2 Oct 2005 09:45:28 -0000 1.29.2.14.10.2 +++ squid/src/enums.h 7 Oct 2005 03:23:11 -0000 1.29.2.14.10.3 @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.29.2.14.10.2 2005/10/02 09:45:28 adri Exp $ + * $Id: enums.h,v 1.29.2.14.10.3 2005/10/07 03:23:11 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -742,8 +742,10 @@ #endif typedef enum { - SRV_STATE_NONE, - SRV_STATE_PENDING, -} store_kick_state_t; + STKICK_NONE, + STKICK_WAIT, + STKICK_FETCH, + STKICK_RUN +} store_kick_type_t; #endif /* SQUID_ENUMS_H */ Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.17.6.27.4.11 retrieving revision 1.17.6.27.4.12 diff -u -r1.17.6.27.4.11 -r1.17.6.27.4.12 --- squid/src/http.c 6 Oct 2005 03:14:58 -0000 1.17.6.27.4.11 +++ squid/src/http.c 7 Oct 2005 03:23:11 -0000 1.17.6.27.4.12 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.17.6.27.4.11 2005/10/06 03:14:58 adri Exp $ + * $Id: http.c,v 1.17.6.27.4.12 2005/10/07 03:23:11 adri Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -560,7 +560,7 @@ } static void -httpReadKick(StoreEntry *e, void *data) +httpReadKick(StoreEntry *e, void *data, store_kick_type_t type) { HttpStateData *httpState = (HttpStateData *)data; /* @@ -1140,6 +1140,11 @@ comm_write_mbuf(fd, mb, sendHeaderDone, httpState); } +/* + * [ahc] storeServerSetCallback() here is registering the callback after + * the initial storeClientCopy() by the client side. + * Hm! + */ void httpStart(FwdState * fwd) { Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.41.6.22.6.2 retrieving revision 1.41.6.22.6.3 diff -u -r1.41.6.22.6.2 -r1.41.6.22.6.3 --- squid/src/protos.h 6 Oct 2005 03:14:58 -0000 1.41.6.22.6.2 +++ squid/src/protos.h 7 Oct 2005 03:23:11 -0000 1.41.6.22.6.3 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.41.6.22.6.2 2005/10/06 03:14:58 adri Exp $ + * $Id: protos.h,v 1.41.6.22.6.3 2005/10/07 03:23:11 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -891,6 +891,7 @@ extern void storeRelease(StoreEntry *); extern int storeUnlockObject(StoreEntry *); extern void storeServerKick(StoreEntry *); +extern void storeServerWait(StoreEntry *); extern void storeServerSetCallback(StoreEntry *, STKICK *, void *); extern void storeServerClearCallback(StoreEntry *); extern EVH storeMaintainSwapSpace; Index: squid/src/store.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store.c,v retrieving revision 1.16.6.7.10.4 retrieving revision 1.16.6.7.10.5 diff -u -r1.16.6.7.10.4 -r1.16.6.7.10.5 --- squid/src/store.c 6 Oct 2005 03:14:58 -0000 1.16.6.7.10.4 +++ squid/src/store.c 7 Oct 2005 03:23:11 -0000 1.16.6.7.10.5 @@ -1,6 +1,6 @@ /* - * $Id: store.c,v 1.16.6.7.10.4 2005/10/06 03:14:58 adri Exp $ + * $Id: store.c,v 1.16.6.7.10.5 2005/10/07 03:23:11 adri Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -123,7 +123,6 @@ mem->object_sz = -1; mem->srv.callback = NULL; mem->srv.data = NULL; - mem->srv.state = SRV_STATE_NONE; /* XXX account log_url */ debug(20, 3) ("new_MemObject: returning %p\n", mem); return mem; @@ -559,7 +558,7 @@ /* fwdCheckDeferRead() not used here because it needs an FD .. */ if (storeCheckDefer(e)) { /* We're a little far in IO, so hint to the server side we should stop */ - debug (20, 2) ("storeAppend: too far ahead: should wait!\n"); + storeServerWait(e); } InvokeHandlers(e); storeSwapOut(e); @@ -1429,7 +1428,7 @@ assert(e); assert(e->mem_obj); assert(cb); - + debug (98, 3) ("storeServerSetCallback: %.8X: setting %.8X (%.8X)\n", e, cb, data); // assert(e->mem_obj->srv.callback == NULL); // assert(e->mem_obj->srv.data == NULL); if (e->mem_obj->srv.callback != NULL) { @@ -1438,11 +1437,9 @@ e->mem_obj->srv.callback = NULL; e->mem_obj->srv.data = NULL; } - assert(e->mem_obj->srv.state == SRV_STATE_NONE); e->mem_obj->srv.callback = cb; e->mem_obj->srv.data = data; - e->mem_obj->srv.state = SRV_STATE_NONE; cbdataLock(data); } @@ -1475,7 +1472,6 @@ assert(e); assert(e->mem_obj); // assert(e->mem_obj->srv.data == data); -// assert(e->mem_obj->srv.state == SRV_STATE_NONE); cbdataUnlock(e->mem_obj->srv.data); e->mem_obj->srv.callback = NULL; e->mem_obj->srv.data = NULL; @@ -1491,13 +1487,27 @@ void storeServerKick(StoreEntry *e) { + debug (98, 4) ("storeServerKick: called: %.8X, %.8X, %.8X\n", e, e->mem_obj, e->mem_obj->srv.callback); if (e->mem_obj == NULL) return; if (e->mem_obj->srv.callback == NULL) return; -// if (e->mem_obj->srv.state == SRV_STATE_PENDING) -// return; - e->mem_obj->srv.state = SRV_STATE_PENDING; - debug (20, 2) ("storeServerKick: kicking\n"); - e->mem_obj->srv.callback(e, e->mem_obj->srv.data); + if (cbdataValid(e->mem_obj->srv.data)) { + debug (98, 2) ("storeServerKick: kicking\n"); + e->mem_obj->srv.callback(e, e->mem_obj->srv.data, STKICK_RUN); + } +} + +void +storeServerWait(StoreEntry *e) +{ + debug (98, 4) ("storeServerWait: called: %.8X, %.8X, %.8X\n", e, e->mem_obj, e->mem_obj->srv.callback); + if (e->mem_obj == NULL) + return; + if (e->mem_obj->srv.callback == NULL) + return; + if (cbdataValid(e->mem_obj->srv.data)) { + debug (98, 3) ("storeServerWait: wait\n"); + e->mem_obj->srv.callback(e, e->mem_obj->srv.data, STKICK_WAIT); + } } Index: squid/src/store_client.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_client.c,v retrieving revision 1.9.6.2.20.2 retrieving revision 1.9.6.2.20.3 diff -u -r1.9.6.2.20.2 -r1.9.6.2.20.3 --- squid/src/store_client.c 6 Oct 2005 03:14:58 -0000 1.9.6.2.20.2 +++ squid/src/store_client.c 7 Oct 2005 03:23:11 -0000 1.9.6.2.20.3 @@ -1,6 +1,6 @@ /* - * $Id: store_client.c,v 1.9.6.2.20.2 2005/10/06 03:14:58 adri Exp $ + * $Id: store_client.c,v 1.9.6.2.20.3 2005/10/07 03:23:11 adri Exp $ * * DEBUG: section 20 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -274,7 +274,7 @@ * [ahc] - this is where we 'kick' the server side * to hint that it should resume feeding us data */ - storeServerKick(e); + storeServerKick(e); debug(20, 3) ("storeClientCopy3: Waiting for more\n"); return; } Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.48.2.34.4.5 retrieving revision 1.48.2.34.4.6 diff -u -r1.48.2.34.4.5 -r1.48.2.34.4.6 --- squid/src/structs.h 5 Oct 2005 14:54:00 -0000 1.48.2.34.4.5 +++ squid/src/structs.h 7 Oct 2005 03:23:11 -0000 1.48.2.34.4.6 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.48.2.34.4.5 2005/10/05 14:54:00 adri Exp $ + * $Id: structs.h,v 1.48.2.34.4.6 2005/10/07 03:23:11 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1537,7 +1537,6 @@ struct { STKICK *callback; void *data; - store_kick_state_t state; } srv; char *log_url; RemovalPolicyNode repl; Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.25.6.6.12.3 retrieving revision 1.25.6.6.12.4 diff -u -r1.25.6.6.12.3 -r1.25.6.6.12.4 --- squid/src/typedefs.h 2 Oct 2005 09:45:28 -0000 1.25.6.6.12.3 +++ squid/src/typedefs.h 7 Oct 2005 03:23:11 -0000 1.25.6.6.12.4 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.25.6.6.12.3 2005/10/02 09:45:28 adri Exp $ + * $Id: typedefs.h,v 1.25.6.6.12.4 2005/10/07 03:23:11 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -388,6 +388,6 @@ typedef struct _external_acl external_acl; typedef struct _external_acl_entry external_acl_entry; -typedef void STKICK(StoreEntry *, void *); +typedef void STKICK(StoreEntry *, void *, store_kick_type_t); #endif /* SQUID_TYPEDEFS_H */