diff --context --recursive squid-1.1.6/src/Makefile.in squid-1.1.6.ucs/src/Makefile.in *** squid-1.1.6/src/Makefile.in Sat Dec 7 01:53:57 1996 --- squid-1.1.6.ucs/src/Makefile.in Tue Feb 11 12:29:25 1997 *************** *** 5,22 **** # # Uncomment and customize the following to suit your needs: # ! HOST_OPT = # -DCACHEMGR_HOSTNAME="getfullhostname()" AUTH_OPT = # -DUSE_PROXY_AUTH=1 LOG_HDRS_OPT = # -DLOG_FULL_HEADERS=1 ICMP_OPT = # -DUSE_ICMP=1 ! DELAY_HACK = # -DDELAY_HACK=1 USERAGENT_OPT = # -DUSE_USERAGENT_LOG=1 KILL_PARENT_OPT = # -DKILL_PARENT_OPT USE_POLL_OPT = # -DUSE_POLL ANON_OPT = # -DUSE_ANONYMIZER DEFINES = $(HOST_OPT) $(AUTH_OPT) $(LOG_HDRS_OPT) \ $(ICMP_OPT) $(DELAY_HACK) $(USERAGENT_OPT) \ ! $(KILL_PARENT_OPT) $(USE_POLL_OPT) $(ANON_OPT) prefix = @prefix@ exec_prefix = @exec_prefix@ --- 5,23 ---- # # Uncomment and customize the following to suit your needs: # ! HOST_OPT = -DCACHEMGR_HOSTNAME="getfullhostname()" AUTH_OPT = # -DUSE_PROXY_AUTH=1 LOG_HDRS_OPT = # -DLOG_FULL_HEADERS=1 ICMP_OPT = # -DUSE_ICMP=1 ! DELAY_HACK = -DDELAY_HACK=1 USERAGENT_OPT = # -DUSE_USERAGENT_LOG=1 KILL_PARENT_OPT = # -DKILL_PARENT_OPT USE_POLL_OPT = # -DUSE_POLL ANON_OPT = # -DUSE_ANONYMIZER + UDP_OPT = -DNO_LOG_UDP DEFINES = $(HOST_OPT) $(AUTH_OPT) $(LOG_HDRS_OPT) \ $(ICMP_OPT) $(DELAY_HACK) $(USERAGENT_OPT) \ ! $(KILL_PARENT_OPT) $(USE_POLL_OPT) $(ANON_OPT) $(UDP_OPT) prefix = @prefix@ exec_prefix = @exec_prefix@ diff --context --recursive squid-1.1.6/src/acl.c squid-1.1.6.ucs/src/acl.c *** squid-1.1.6/src/acl.c Tue Feb 11 12:47:56 1997 --- squid-1.1.6.ucs/src/acl.c Tue Feb 11 12:40:13 1997 *************** *** 42,49 **** struct _acl_access *HTTPAccessList = NULL; struct _acl_access *ICPAccessList = NULL; struct _acl_access *MISSAccessList = NULL; ! #if DELAY_HACK struct _acl_access *DelayAccessList = NULL; #endif static struct _acl *AclList = NULL; --- 42,50 ---- struct _acl_access *HTTPAccessList = NULL; struct _acl_access *ICPAccessList = NULL; struct _acl_access *MISSAccessList = NULL; ! #ifdef DELAY_HACK struct _acl_access *DelayAccessList = NULL; + struct _acl_access *DelayChildAccessList = NULL; #endif static struct _acl *AclList = NULL; diff --context --recursive squid-1.1.6/src/acl.h squid-1.1.6.ucs/src/acl.h *** squid-1.1.6/src/acl.h Tue Feb 11 12:47:56 1997 --- squid-1.1.6.ucs/src/acl.h Tue Feb 11 12:40:13 1997 *************** *** 153,158 **** extern struct _acl_deny_info_list *DenyInfoList; extern const char *AclMatchedName; ! #if DELAY_HACK extern struct _acl_access *DelayAccessList; #endif --- 153,159 ---- extern struct _acl_deny_info_list *DenyInfoList; extern const char *AclMatchedName; ! #ifdef DELAY_HACK extern struct _acl_access *DelayAccessList; + extern struct _acl_access *DelayChildAccessList; #endif diff --context --recursive squid-1.1.6/src/cache_cf.c squid-1.1.6.ucs/src/cache_cf.c *** squid-1.1.6/src/cache_cf.c Tue Feb 11 12:47:56 1997 --- squid-1.1.6.ucs/src/cache_cf.c Tue Feb 11 12:46:17 1997 *************** *** 116,121 **** --- 116,130 ---- #define DefaultNetdbHigh 1000 /* counts, not percents */ #define DefaultNetdbLow 900 + #ifdef DELAY_HACK + #define DefaultDelayMaxBytes 102400 + #define DefaultDelayRestoreBytes 3584 + #define DefaultDelayHostMaxBytes 10240 + #define DefaultDelayHostRestoreBytes 384 + #define DefaultDelayChildMaxBytes 204800 + #define DefaultDelayChildRestoreBytes 8192 + #endif + #define DefaultWaisRelayHost (char *)NULL #define DefaultWaisRelayPort 0 *************** *** 230,235 **** --- 239,252 ---- static void parseCacheAnnounceLine _PARAMS((void)); static void parseCacheHostLine _PARAMS((void)); static void parseDebugOptionsLine _PARAMS((void)); + #ifdef DELAY_HACK + static void parseDelayRestoreLine _PARAMS((void)); + static void parseDelayHostRestoreLine _PARAMS((void)); + static void parseDelayChildRestoreLine _PARAMS((void)); + static void parseDelayMaxLine _PARAMS((void)); + static void parseDelayHostMaxLine _PARAMS((void)); + static void parseDelayChildMaxLine _PARAMS((void)); + #endif static void parseEffectiveUserLine _PARAMS((void)); static void parseErrHtmlLine _PARAMS((void)); static void parseFtpOptionsLine _PARAMS((void)); *************** *** 493,498 **** --- 510,519 ---- options |= NEIGHBOR_NO_QUERY; } else if (!strcasecmp(token, "multicast-responder")) { options |= NEIGHBOR_MCAST_RESPONDER; + #ifdef DELAY_HACK + } else if (!strcasecmp(token, "no-delay")) { + options |= NEIGHBOR_NO_DELAY; + #endif } else if (!strncasecmp(token, "weight=", 7)) { weight = atoi(token + 7); } else if (!strncasecmp(token, "ttl=", 4)) { *************** *** 884,889 **** --- 905,966 ---- Config.debugOptions = xstrdup(token); } + #ifdef DELAY_HACK + static + void parseDelayRestoreLine() + { + char *token; + int i; + GetInteger(i); + Config.delay_restore = i; /* number of bytes per sec to give to pool */ + } + + static void + parseDelayHostRestoreLine() + { + char *token; + int i; + GetInteger(i); + Config.delay_host_restore = i; /* ditto, per-host pool */ + } + + static void + parseDelayChildRestoreLine() + { + char *token; + int i; + GetInteger(i); + Config.delay_child_restore = i; /* ditto, per-host pool */ + } + + static void + parseDelayMaxLine() + { + char *token; + int i; + GetInteger(i); + Config.delay_max = i; /* max number of bytes in pool */ + } + + static void + parseDelayHostMaxLine() + { + char *token; + int i; + GetInteger(i); + Config.delay_host_max = i; /* ditto, per-host pool */ + } + + static void + parseDelayChildMaxLine() + { + char *token; + int i; + GetInteger(i); + Config.delay_child_max = i; /* ditto, per-host pool */ + } + #endif + static void parseVisibleHostnameLine(void) { *************** *** 1039,1046 **** aclDestroyAccessList(&HTTPAccessList); aclDestroyAccessList(&MISSAccessList); aclDestroyAccessList(&ICPAccessList); ! #if DELAY_HACK aclDestroyAccessList(&DelayAccessList); #endif aclDestroyRegexList(Config.cache_stop_relist); Config.cache_stop_relist = NULL; --- 1116,1124 ---- aclDestroyAccessList(&HTTPAccessList); aclDestroyAccessList(&MISSAccessList); aclDestroyAccessList(&ICPAccessList); ! #ifdef DELAY_HACK aclDestroyAccessList(&DelayAccessList); + aclDestroyAccessList(&DelayChildAccessList); #endif aclDestroyRegexList(Config.cache_stop_relist); Config.cache_stop_relist = NULL; *************** *** 1164,1172 **** else if (!strcmp(token, "cache_stoplist_pattern/i")) aclParseRegexList(&Config.cache_stop_relist, 1); ! #if DELAY_HACK else if (!strcmp(token, "delay_access")) aclParseAccessLine(&DelayAccessList); #endif else if (!strcmp(token, "refresh_pattern")) --- 1242,1271 ---- else if (!strcmp(token, "cache_stoplist_pattern/i")) aclParseRegexList(&Config.cache_stop_relist, 1); ! #ifdef DELAY_HACK else if (!strcmp(token, "delay_access")) aclParseAccessLine(&DelayAccessList); + + else if (!strcmp(token, "delay_child_access")) + aclParseAccessLine(&DelayChildAccessList); + + else if (!strcmp(token, "delay_max")) + parseDelayMaxLine(); + + else if (!strcmp(token, "delay_restore")) + parseDelayRestoreLine(); + + else if (!strcmp(token, "delay_host_max")) + parseDelayHostMaxLine(); + + else if (!strcmp(token, "delay_host_restore")) + parseDelayHostRestoreLine(); + + else if (!strcmp(token, "delay_child_max")) + parseDelayChildMaxLine(); + + else if (!strcmp(token, "delay_child_restore")) + parseDelayChildRestoreLine(); #endif else if (!strcmp(token, "refresh_pattern")) *************** *** 1555,1560 **** --- 1654,1667 ---- Config.proxyAuthIgnoreDomain = safe_xstrdup(DefaultProxyAuthIgnoreDomain); #endif /* USE_PROXY_AUTH */ Config.ftpUser = safe_xstrdup(DefaultFtpUser); + #ifdef DELAY_HACK + Config.delay_max = DefaultDelayMaxBytes; + Config.delay_restore = DefaultDelayRestoreBytes; + Config.delay_host_max = DefaultDelayHostMaxBytes; + Config.delay_host_restore = DefaultDelayHostRestoreBytes; + Config.delay_child_max = DefaultDelayChildMaxBytes; + Config.delay_child_restore = DefaultDelayChildRestoreBytes; + #endif Config.Announce.host = safe_xstrdup(DefaultAnnounceHost); Config.Announce.port = DefaultAnnouncePort; Config.Announce.file = safe_xstrdup(DefaultAnnounceFile); diff --context --recursive squid-1.1.6/src/cache_cf.h squid-1.1.6.ucs/src/cache_cf.h *** squid-1.1.6/src/cache_cf.h Tue Feb 11 12:47:56 1997 --- squid-1.1.6.ucs/src/cache_cf.h Tue Feb 11 12:40:14 1997 *************** *** 202,207 **** --- 202,215 ---- int neighborTimeout; int stallDelay; int singleParentBypass; + #ifdef DELAY_HACK + int delay_restore; + int delay_max; + int delay_host_restore; + int delay_host_max; + int delay_child_restore; + int delay_child_max; + #endif struct { char *host; char *prefix; diff --context --recursive squid-1.1.6/src/cachemgr.c squid-1.1.6.ucs/src/cachemgr.c *** squid-1.1.6/src/cachemgr.c Tue Feb 11 12:47:39 1997 --- squid-1.1.6.ucs/src/cachemgr.c Tue Feb 11 12:35:06 1997 *************** *** 227,232 **** --- 227,235 ---- STATS_VM, STATS_U, STATS_IO, + #ifdef DELAY_HACK + STATS_DH, + #endif STATS_HDRS, STATS_FDS, STATS_NETDB, *************** *** 254,259 **** --- 257,265 ---- "stats/vm_objects", "stats/utilization", "stats/io", + #ifdef DELAY_HACK + "stats/delay", + #endif "stats/reply_headers", "stats/filedescriptors", "stats/netdb", *************** *** 281,286 **** --- 287,295 ---- "VM Objects", "Utilization", "I/O", + #ifdef DELAY_HACK + "Delay Pool Statistics", + #endif "HTTP Reply Headers", "Filedescriptor Usage", "Network Probe Database", *************** *** 367,372 **** --- 376,384 ---- #endif print_option(op, STATS_U); print_option(op, STATS_IO); + #ifdef DELAY_HACK + print_option(op, STATS_DH); + #endif print_option(op, STATS_HDRS); print_option(op, STATS_FDS); print_option(op, STATS_NETDB); *************** *** 738,743 **** --- 750,758 ---- case STATS_VM: case STATS_U: case STATS_IO: + #ifdef DELAY_HACK + case STATS_DH: + #endif case STATS_HDRS: case STATS_FDS: case STATS_NETDB: *************** *** 777,782 **** --- 792,800 ---- #endif print_option(op, STATS_U); print_option(op, STATS_IO); + #ifdef DELAY_HACK + print_option(op, STATS_DH); + #endif print_option(op, STATS_HDRS); print_option(op, STATS_FDS); print_option(op, STATS_NETDB); *************** *** 833,838 **** --- 851,859 ---- case STATS_O: case STATS_VM: case STATS_IO: + #ifdef DELAY_HACK + case STATS_DH: + #endif case STATS_HDRS: case STATS_FDS: case STATS_NETDB: *************** *** 919,924 **** --- 940,948 ---- case STATS_D: case STATS_R: case STATS_IO: + #ifdef DELAY_HACK + case STATS_DH: + #endif case STATS_HDRS: case STATS_FDS: case STATS_NETDB: diff --context --recursive squid-1.1.6/src/comm.c squid-1.1.6.ucs/src/comm.c *** squid-1.1.6/src/comm.c Tue Feb 11 12:47:56 1997 --- squid-1.1.6.ucs/src/comm.c Tue Feb 11 12:40:14 1997 *************** *** 130,135 **** --- 130,142 ---- void (*free) (void *); }; + #ifdef DELAY_HACK + struct _delay_data delay_data; + unsigned char delay_nets[256]; + unsigned char delay_hosts[255][256]; + long delay_matrix[65279]; + #endif + /* GLOBAL */ FD_ENTRY *fd_table = NULL; /* also used in disk.c */ *************** *** 930,935 **** --- 937,947 ---- static time_t last_timeout = 0; struct timeval poll_time; time_t timeout; + #ifdef DELAY_HACK + long maxbyte, restbyte; + int net, host, mpos; + int time_diff; + #endif /* assume all process are very fast (less than 1 second). Call * time() only once */ *************** *** 937,942 **** --- 949,993 ---- /* use only 1 second granularity */ timeout = squid_curtime + sec; + #ifdef DELAY_HACK + if (squid_curtime > delay_data.last_update) { + time_diff = squid_curtime - delay_data.last_update; + delay_data.last_update = squid_curtime; + delay_data.bytes += (restbyte = (Config.delay_restore * time_diff)); + debug(5, 2, "comm_select: DELAY %d bytes incremented, now = %d\n", restbyte, delay_data.bytes); + maxbyte = Config.delay_max; + if (delay_data.bytes > maxbyte) { + delay_data.bytes = maxbyte; + debug(5, 5, "comm_select: DELAY bytes set to max %d\n", maxbyte); + } + delay_data.child_bytes += (restbyte = (Config.delay_child_restore * time_diff)); + debug(5, 2, "comm_select: DELAY CHILD %d bytes incremented, now = %d\n", restbyte, delay_data.child_bytes); + maxbyte = Config.delay_child_max; + if (delay_data.child_bytes > maxbyte) { + delay_data.child_bytes = maxbyte; + debug(5, 5, "comm_select: DELAY CHILD bytes set to max %d\n", maxbyte); + } + maxbyte = Config.delay_host_max; + restbyte = Config.delay_host_restore; + for(net=0;;net++) { + if(delay_nets[net] == 255) + break; + debug(5, 2, "comm_select: DELAY incrementing net %d\n", net); + for(host=0;;host++) { + if(delay_hosts[net][host] == 255) + break; + debug(5, 2, "comm_select: DELAY incrementing host %d\n", host); + mpos = (net << 8) + host; + if(delay_matrix[mpos] != maxbyte) { + delay_matrix[mpos] += restbyte; + if(delay_matrix[mpos] > maxbyte) + delay_matrix[mpos] = maxbyte; + } + } + } + } + #endif + do { if (sec > 60) fatal_dump(NULL); *************** *** 1270,1275 **** --- 1321,1335 ---- meta_data.misc += Squid_MaxFD * sizeof(int); zero_tv.tv_sec = 0; zero_tv.tv_usec = 0; + + #ifdef DELAY_HACK + /* this bit sets up the structure that holds the delay_data info. */ + + delay_data.bytes = Config.delay_restore; + delay_data.child_bytes = Config.delay_child_restore; + delay_data.last_update = getCurrentTime(); + delay_nets[0] = 255; + #endif return 0; } diff --context --recursive squid-1.1.6/src/comm.h squid-1.1.6.ucs/src/comm.h *** squid-1.1.6/src/comm.h Tue Feb 11 12:47:47 1997 --- squid-1.1.6.ucs/src/comm.h Tue Feb 11 12:38:30 1997 *************** *** 130,135 **** --- 130,148 ---- #define FD_ASCII_NOTE_SZ 64 + #ifdef DELAY_HACK + struct _delay_data { + time_t last_update; + long bytes; + long child_bytes; + }; + + extern struct _delay_data delay_data; + extern unsigned char delay_nets[256]; + extern unsigned char delay_hosts[255][256]; + extern long delay_matrix[65279]; + #endif + struct close_handler { PF handler; void *data; diff --context --recursive squid-1.1.6/src/ftp.c squid-1.1.6.ucs/src/ftp.c *** squid-1.1.6/src/ftp.c Tue Feb 11 12:47:40 1997 --- squid-1.1.6.ucs/src/ftp.c Tue Feb 11 12:35:07 1997 *************** *** 277,282 **** --- 277,285 ---- int clen; int off; int bin; + #ifdef DELAY_HACK + int bufsize, d_m_p; + #endif StoreEntry *entry = NULL; entry = data->entry; *************** *** 289,300 **** --- 292,317 ---- /* check if we want to defer reading */ clen = entry->mem_obj->e_current_len; off = storeGetLowestReaderOffset(entry); + #ifdef DELAY_HACK + d_m_p = data->request->delay_matrix_pos; + if (((clen - off) > FTP_DELETE_GAP) || + (!d_m_p && !data->request->delay && delay_data.child_bytes < 0) || + (data->request->delay && + ((d_m_p != 65535 && delay_matrix[d_m_p] < 0) || + delay_data.bytes < 0))) { + #else if ((clen - off) > FTP_DELETE_GAP) { + #endif if (entry->flag & CLIENT_ABORT_REQUEST) { squid_error_entry(entry, ERR_CLIENT_ABORT, NULL); comm_close(fd); } IOStats.Ftp.reads_deferred++; + #ifdef DELAY_HACK + if (data->request->delay || !d_m_p) { + debug(11, 2, "ftpReadReply: DELAY Read deferred for Object: %s\n", entry->url); + } + #endif debug(11, 3, "ftpReadReply: Read deferred for Object: %s\n", entry->url); debug(11, 3, " Current Gap: %d bytes\n", clen - off); *************** *** 315,321 **** --- 332,389 ---- BIT_RESET(entry->flag, READ_DEFERRED); } errno = 0; + #ifdef DELAY_HACK + if (data->request->delay) { + bufsize = delay_data.bytes / 16; + if (bufsize < (SQUID_TCP_SO_RCVBUF / 64)) + bufsize = SQUID_TCP_SO_RCVBUF / 64; + } else if (!d_m_p) { + bufsize = delay_data.child_bytes / 16; + if (bufsize < (SQUID_TCP_SO_RCVBUF / 64)) + bufsize = SQUID_TCP_SO_RCVBUF / 64; + } else + bufsize = SQUID_TCP_SO_RCVBUF; + len = read(fd, buf, bufsize); + if (data->request->delay) { + delay_data.bytes -= len; + if(d_m_p == 65535) { + unsigned int host, net, Host, Net; + + Host = data->request->delay & 0xff; + Net = data->request->delay >> 8; + for(net = 0;; net++) { + if(delay_nets[net] == Net) + break; + if(delay_nets[net] == 255) { + delay_nets[net] = Net; + delay_nets[net + 1] = 255; + delay_hosts[net][0] = 255; + break; + } + } + for(host = 0;; host++) { + if(delay_hosts[net][host] == Host) + break; + if(delay_hosts[net][host] == 255) { + delay_hosts[net][host] = Host; + delay_hosts[net][host + 1] = 255; + delay_matrix[(net << 8) + host] = Config.delay_host_restore; + break; + } + } + d_m_p = data->request->delay_matrix_pos = (net << 8) + host; + delay_matrix[d_m_p] -= len; + } else + delay_matrix[d_m_p] -= len; + debug(11, 2, "ftpReadReply: DELAY %d bytes read. Pool = %d\n", len, delay_data.bytes); + debug(11, 2, "ftpReadReply: DELAY %d bytes read. Host pool = %d\n", len, delay_matrix[d_m_p]); + } else if(!d_m_p) { + delay_data.child_bytes -= len; + debug(11, 2, "ftpReadReply: DELAY CHILD %d bytes read. Pool = %d\n", len, delay_data.child_bytes); + } + #else len = read(fd, buf, SQUID_TCP_SO_RCVBUF); + #endif debug(9, 5, "ftpReadReply: FD %d, Read %d bytes\n", fd, len); if (len > 0) { IOStats.Ftp.reads++; diff --context --recursive squid-1.1.6/src/http.c squid-1.1.6.ucs/src/http.c *** squid-1.1.6/src/http.c Tue Feb 11 12:47:58 1997 --- squid-1.1.6.ucs/src/http.c Tue Feb 11 12:40:14 1997 *************** *** 110,115 **** --- 110,116 ---- #include "squid.h" + #define HTTP_DELETE_GAP (1<<18) static const char *const w_space = " \t\n\r"; *************** *** 546,551 **** --- 547,555 ---- int bin; int clen; int off; + #ifdef DELAY_HACK + int bufsize, d_m_p; + #endif StoreEntry *entry = NULL; entry = httpState->entry; *************** *** 558,570 **** --- 562,589 ---- /* check if we want to defer reading */ clen = entry->mem_obj->e_current_len; off = storeGetLowestReaderOffset(entry); + #ifdef DELAY_HACK + d_m_p = httpState->request->delay_matrix_pos; + if (((clen - off) > HTTP_DELETE_GAP) || + (!d_m_p && !httpState->request->delay && delay_data.child_bytes < 0) || + (httpState->request->delay && + ((d_m_p != 65535 && delay_matrix[d_m_p] < 0) || + delay_data.bytes < 0))) { + #else if ((clen - off) > HTTP_DELETE_GAP) { + #endif if (entry->flag & CLIENT_ABORT_REQUEST) { squid_error_entry(entry, ERR_CLIENT_ABORT, NULL); comm_close(fd); return; } IOStats.Http.reads_deferred++; + #ifdef DELAY_HACK + if (httpState->request->delay) { + debug(11, 2, "httpReadReply: DELAY Read deferred for Object: %s\n", entry->url); + } + #endif + debug(11, 3, "httpReadReply: Read deferred for Object: %s\n", entry->url); debug(11, 3, " Current Gap: %d bytes\n", clen - off); *************** *** 591,598 **** --- 610,671 ---- BIT_RESET(entry->flag, READ_DEFERRED); } errno = 0; + #ifdef DELAY_HACK + if (httpState->request->delay != 0) { + bufsize = delay_data.bytes / 16; + if(d_m_p != 65535 && bufsize > delay_matrix[d_m_p]) + bufsize = delay_matrix[d_m_p]; + if (bufsize < (SQUID_TCP_SO_RCVBUF / 64)) + bufsize = SQUID_TCP_SO_RCVBUF / 64; + } else if (!d_m_p) { + bufsize = delay_data.child_bytes / 16; + if (bufsize < (SQUID_TCP_SO_RCVBUF / 64)) + bufsize = SQUID_TCP_SO_RCVBUF / 64; + } else + bufsize = SQUID_TCP_SO_RCVBUF; + len = read(fd, buf, bufsize); + if (httpState->request->delay != 0) { + delay_data.bytes -= len; + if(d_m_p == 65535) { + unsigned int host, net, Host, Net; + + Host = httpState->request->delay & 0xff; + Net = httpState->request->delay >> 8; + for(net = 0;; net++) { + if(delay_nets[net] == Net) + break; + if(delay_nets[net] == 255) { + delay_nets[net] = Net; + delay_nets[net + 1] = 255; + delay_hosts[net][0] = 255; + break; + } + } + for(host = 0;; host++) { + if(delay_hosts[net][host] == Host) + break; + if(delay_hosts[net][host] == 255) { + delay_hosts[net][host] = Host; + delay_hosts[net][host + 1] = 255; + delay_matrix[(net << 8) + host] = Config.delay_host_restore; + break; + } + } + d_m_p = httpState->request->delay_matrix_pos = (net << 8) + host; + delay_matrix[d_m_p] -= len; + } else + delay_matrix[d_m_p] -= len; + debug(11, 2, "httpReadReply: DELAY %d bytes read. Host pool = %d\n", len, delay_matrix[d_m_p]); + debug(11, 2, "httpReadReply: DELAY %d bytes read. Pool = %d\n", len, delay_data.bytes); + } else if (!d_m_p) { + delay_data.child_bytes -= len; + debug(11, 2, "httpReadReply: DELAY CHILD %d bytes read. Pool = %d\n", len, delay_data.child_bytes); + } + #else len = read(fd, buf, SQUID_TCP_SO_RCVBUF); + #endif debug(11, 5, "httpReadReply: FD %d: len %d.\n", fd, len); + comm_set_fd_lifetime(fd, 86400); /* extend after good read */ if (len > 0) { IOStats.Http.reads++; *************** *** 900,905 **** --- 973,985 ---- if (e->options & NEIGHBOR_PROXY_ONLY) storeStartDeleteBehind(entry); + #ifdef DELAY_HACK + if (e->options & NEIGHBOR_NO_DELAY) { + orig_request->delay = 0; + orig_request->delay_matrix_pos = 65535; + } + #endif + /* Create socket. */ sock = comm_open(SOCK_STREAM, 0, *************** *** 917,922 **** --- 997,1006 ---- httpState->req_hdr = entry->mem_obj->mime_hdr; httpState->req_hdr_sz = entry->mem_obj->mime_hdr_sz; request = get_free_request_t(); + #ifdef DELAY_HACK + request->delay = orig_request->delay; + request->delay_matrix_pos = orig_request->delay_matrix_pos; + #endif httpState->request = requestLink(request); httpState->neighbor = e; httpState->orig_request = requestLink(orig_request); diff --context --recursive squid-1.1.6/src/icp.c squid-1.1.6.ucs/src/icp.c *** squid-1.1.6/src/icp.c Tue Feb 11 12:47:58 1997 --- squid-1.1.6.ucs/src/icp.c Tue Feb 11 12:51:55 1997 *************** *** 121,132 **** --- 121,134 ---- "TCP_IMS_MISS", "TCP_SWAPFAIL", "TCP_DENIED", + #ifndef NO_LOG_UDP "UDP_HIT", "UDP_HIT_OBJ", "UDP_MISS", "UDP_DENIED", "UDP_INVALID", "UDP_RELOADING", + #endif "ERR_READ_TIMEOUT", "ERR_LIFETIME_EXP", "ERR_NO_CLIENTS_BIG_OBJ", *************** *** 147,156 **** "ERR_PROXY_DENIED" }; - #if DELAY_HACK - int _delay_fetch; - - #endif static icpUdpData *UdpQueueHead = NULL; static icpUdpData *UdpQueueTail = NULL; --- 149,154 ---- *************** *** 176,182 **** --- 174,182 ---- static void icpHandleStoreIMS _PARAMS((int, StoreEntry *, void *)); static void icpHandleIMSComplete _PARAMS((int, char *, int, int, void *icpState)); static void icpHitObjHandler _PARAMS((int, void *)); + #ifndef NO_LOG_UDP static void icpLogIcp _PARAMS((icpUdpData *)); + #endif static void icpHandleIcpV2 _PARAMS((int, struct sockaddr_in, char *, int)); static void icpHandleIcpV3 _PARAMS((int, struct sockaddr_in, char *, int)); static void icpHandleAbort _PARAMS((int fd, StoreEntry *, void *)); *************** *** 850,855 **** --- 850,859 ---- icpState->method, icpState->url, fd_table[fd].ipaddr); + #ifdef DELAY_HACK + icpState->request->delay = 0; + icpState->request->delay_matrix_pos = 65535; + #endif icpSendERROR(fd, LOG_TCP_DENIED, buf, icpState, icpState->http_code); return 0; } *************** *** 872,887 **** icpState->out_offset = 0; /* Register with storage manager to receive updates when data comes in. */ storeRegister(entry, fd, icpHandleStore, (void *) icpState); ! #if DELAY_HACK ch.src_addr = icpState->peer.sin_addr; ch.request = icpState->request; ! _delay_fetch = 0; ! if (aclCheck(DelayAccessList, &ch)) ! _delay_fetch = 1; #endif return (protoDispatch(fd, url, icpState->entry, icpState->request)); } static void icpLogIcp(icpUdpData * queue) { --- 876,903 ---- icpState->out_offset = 0; /* Register with storage manager to receive updates when data comes in. */ storeRegister(entry, fd, icpHandleStore, (void *) icpState); ! #ifdef DELAY_HACK ch.src_addr = icpState->peer.sin_addr; ch.request = icpState->request; ! icpState->request->delay = 0; /* no delay until determined */ ! icpState->request->delay_matrix_pos = 65535; /* not located */ ! if (aclCheck(DelayAccessList, &ch)) { ! icpState->request->delay = ntohl(ch.src_addr.s_addr) & 0xffff; ! /* set delay for this request */ ! debug(12, 5, "icpProcessMISS: delay set %s (%d)\n", inet_ntoa(ch.src_addr), ! icpState->request->delay); ! } ! if(aclCheck(DelayChildAccessList, &ch)) { ! icpState->request->delay_matrix_pos = 0; /* not in the normal delay pool */ ! icpState->request->delay = 0; /* special value pair for delay children */ ! debug(12, 5, "icpProcessMISS: delay child set %s (%d)\n", inet_ntoa(ch.src_addr), ! icpState->request->delay); ! } #endif return (protoDispatch(fd, url, icpState->entry, icpState->request)); } + #ifndef NO_LOG_UDP static void icpLogIcp(icpUdpData * queue) { *************** *** 915,920 **** --- 931,937 ---- #endif /* LOG_FULL_HEADERS */ NULL); /* content-type */ } + #endif int icpUdpReply(int fd, icpUdpData * queue) *************** *** 946,953 **** --- 963,972 ---- result = COMM_ERROR; } UdpQueueHead = queue->next; + #ifndef NO_LOG_UDP if (queue->logcode) icpLogIcp(queue); + #endif safe_free(queue->msg); safe_free(queue); } *************** *** 1043,1049 **** --- 1062,1070 ---- icpUdpSend(int fd, const struct sockaddr_in *to, icp_common_t * msg, + #ifndef NO_LOG_UDP log_type logcode, + #endif protocol_t proto) { icpUdpData *data = xcalloc(1, sizeof(icpUdpData)); *************** *** 1055,1061 **** --- 1076,1084 ---- data->msg = msg; data->len = (int) ntohs(msg->length); data->start = current_time; /* wrong for HIT_OBJ */ + #ifndef NO_LOG_UDP data->logcode = logcode; + #endif data->proto = proto; AppendUdp(data); commSetSelect(fd, *************** *** 1088,1094 **** --- 1111,1119 ---- icpUdpSend(icpHitObjState->fd, &icpHitObjState->to, reply, + #ifndef NO_LOG_UDP LOG_UDP_HIT_OBJ, + #endif urlParseProtocol(entry->url)); } storeUnlockObject(entry); *************** *** 1158,1164 **** --- 1183,1193 ---- url = buf + sizeof(header) + sizeof(u_num32); if ((icp_request = urlParse(METHOD_GET, url)) == NULL) { reply = icpCreateMessage(ICP_OP_ERR, 0, url, header.reqnum, 0); + #ifdef NO_LOG_UDP + icpUdpSend(fd, &from, reply, PROTO_NONE); + #else icpUdpSend(fd, &from, reply, LOG_UDP_INVALID, PROTO_NONE); + #endif break; } checklist.src_addr = from.sin_addr; *************** *** 1169,1175 **** --- 1198,1208 ---- inet_ntoa(from.sin_addr), AclMatchedName); if (clientdbDeniedPercent(from.sin_addr) < 95) { reply = icpCreateMessage(ICP_OP_DENIED, 0, url, header.reqnum, 0); + #ifdef NO_LOG_UDP + icpUdpSend(fd, &from, reply, icp_request->protocol); + #else icpUdpSend(fd, &from, reply, LOG_UDP_DENIED, icp_request->protocol); + #endif } break; } *************** *** 1199,1218 **** --- 1232,1267 ---- safe_free(icpHitObjState); } else { reply = icpCreateMessage(ICP_OP_HIT, flags, url, header.reqnum, netdb_gunk); + #ifdef NO_LOG_UDP + icpUdpSend(fd, &from, reply, icp_request->protocol); + #else icpUdpSend(fd, &from, reply, LOG_UDP_HIT, icp_request->protocol); + #endif break; } } /* if store is rebuilding, return a UDP_HIT, but not a MISS */ if (store_rebuilding == STORE_REBUILDING_FAST && opt_reload_hit_only) { reply = icpCreateMessage(ICP_OP_RELOADING, flags, url, header.reqnum, netdb_gunk); + #ifdef NO_LOG_UDP + icpUdpSend(fd, &from, reply, icp_request->protocol); + #else icpUdpSend(fd, &from, reply, LOG_UDP_RELOADING, icp_request->protocol); + #endif } else if (hit_only_mode_until > squid_curtime) { reply = icpCreateMessage(ICP_OP_RELOADING, flags, url, header.reqnum, netdb_gunk); + #ifdef NO_LOG_UDP + icpUdpSend(fd, &from, reply, icp_request->protocol); + #else icpUdpSend(fd, &from, reply, LOG_UDP_RELOADING, icp_request->protocol); + #endif } else { reply = icpCreateMessage(ICP_OP_MISS, flags, url, header.reqnum, netdb_gunk); + #ifdef NO_LOG_UDP + icpUdpSend(fd, &from, reply, icp_request->protocol); + #else icpUdpSend(fd, &from, reply, LOG_UDP_MISS, icp_request->protocol); + #endif } break; *************** *** 1309,1315 **** --- 1358,1368 ---- url = buf + sizeof(header) + sizeof(u_num32); if ((icp_request = urlParse(METHOD_GET, url)) == NULL) { reply = icpCreateMessage(ICP_OP_ERR, 0, url, header.reqnum, 0); + #ifdef NO_LOG_UDP + icpUdpSend(fd, &from, reply, PROTO_NONE); + #else icpUdpSend(fd, &from, reply, LOG_UDP_INVALID, PROTO_NONE); + #endif break; } checklist.src_addr = from.sin_addr; *************** *** 1320,1326 **** --- 1373,1383 ---- inet_ntoa(from.sin_addr), AclMatchedName); if (clientdbDeniedPercent(from.sin_addr) < 95) { reply = icpCreateMessage(ICP_OP_DENIED, 0, url, header.reqnum, 0); + #ifdef NO_LOG_UDP + icpUdpSend(fd, &from, reply, icp_request->protocol); + #else icpUdpSend(fd, &from, reply, LOG_UDP_DENIED, icp_request->protocol); + #endif } break; } *************** *** 1330,1348 **** --- 1387,1421 ---- IcpOpcodeStr[header.opcode]); if (icpCheckUdpHit(entry, icp_request)) { reply = icpCreateMessage(ICP_OP_HIT, 0, url, header.reqnum, 0); + #ifdef NO_LOG_UDP + icpUdpSend(fd, &from, reply, icp_request->protocol); + #else icpUdpSend(fd, &from, reply, LOG_UDP_HIT, icp_request->protocol); + #endif break; } /* if store is rebuilding, return a UDP_HIT, but not a MISS */ if (opt_reload_hit_only && store_rebuilding == STORE_REBUILDING_FAST) { reply = icpCreateMessage(ICP_OP_RELOADING, 0, url, header.reqnum, 0); + #ifdef NO_LOG_UDP + icpUdpSend(fd, &from, reply, icp_request->protocol); + #else icpUdpSend(fd, &from, reply, LOG_UDP_RELOADING, icp_request->protocol); + #endif } else if (hit_only_mode_until > squid_curtime) { reply = icpCreateMessage(ICP_OP_RELOADING, 0, url, header.reqnum, 0); + #ifdef NO_LOG_UDP + icpUdpSend(fd, &from, reply, icp_request->protocol); + #else icpUdpSend(fd, &from, reply, LOG_UDP_RELOADING, icp_request->protocol); + #endif } else { reply = icpCreateMessage(ICP_OP_MISS, 0, url, header.reqnum, 0); + #ifdef NO_LOG_UDP + icpUdpSend(fd, &from, reply, icp_request->protocol); + #else icpUdpSend(fd, &from, reply, LOG_UDP_MISS, icp_request->protocol); + #endif } break; diff --context --recursive squid-1.1.6/src/icp.h squid-1.1.6.ucs/src/icp.h *** squid-1.1.6/src/icp.h Tue Feb 11 12:47:58 1997 --- squid-1.1.6.ucs/src/icp.h Tue Feb 11 12:40:15 1997 *************** *** 118,129 **** --- 118,131 ---- LOG_TCP_IMS_MISS, /* 8 */ LOG_TCP_SWAPIN_FAIL, /* 9 */ LOG_TCP_DENIED, /* 10 */ + #ifndef NO_LOG_UDP LOG_UDP_HIT, /* 11 */ LOG_UDP_HIT_OBJ, /* 12 */ LOG_UDP_MISS, /* 13 */ LOG_UDP_DENIED, /* 14 */ LOG_UDP_INVALID, /* 15 */ LOG_UDP_RELOADING, /* 16 */ + #endif ERR_READ_TIMEOUT, /* 17 */ ERR_LIFETIME_EXP, /* 18 */ ERR_NO_CLIENTS_BIG_OBJ, /* 19 */ *************** *** 153,159 **** --- 155,163 ---- size_t len; struct wwd *next; struct timeval start; + #ifndef NO_LOG_UDP log_type logcode; + #endif protocol_t proto; } icpUdpData; *************** *** 204,214 **** --- 208,225 ---- const char *url, int reqnum, int pad)); + #ifndef NO_LOG_UDP extern void icpUdpSend _PARAMS((int fd, const struct sockaddr_in *, icp_common_t * msg, log_type, protocol_t)); + #else + extern void icpUdpSend _PARAMS((int fd, + const struct sockaddr_in *, + icp_common_t * msg, + protocol_t)); + #endif extern void icpHandleUdp _PARAMS((int sock, void *data)); extern void asciiHandleConn _PARAMS((int sock, void *data)); extern void icpSendERROR _PARAMS((int fd, diff --context --recursive squid-1.1.6/src/neighbors.c squid-1.1.6.ucs/src/neighbors.c *** squid-1.1.6/src/neighbors.c Tue Feb 11 12:47:58 1997 --- squid-1.1.6.ucs/src/neighbors.c Tue Feb 11 12:57:23 1997 *************** *** 521,527 **** --- 521,529 ---- icpUdpSend(theOutIcpConnection, &e->in_addr, query, + #ifndef NO_LOG_UDP LOG_TAG_NONE, + #endif PROTO_NONE); ICP_queries_sent++; } else { *************** *** 535,541 **** --- 537,545 ---- icpUdpSend(theOutIcpConnection, &e->in_addr, query, + #ifndef NO_LOG_UDP LOG_TAG_NONE, + #endif PROTO_NONE); ICP_queries_sent++; } *************** *** 581,587 **** --- 585,593 ---- icpUdpSend(theOutIcpConnection, &to_addr, query, + #ifndef NO_LOG_UDP LOG_TAG_NONE, + #endif PROTO_NONE); ICP_queries_sent++; } diff --context --recursive squid-1.1.6/src/neighbors.h squid-1.1.6.ucs/src/neighbors.h *** squid-1.1.6/src/neighbors.h Tue Feb 11 12:47:58 1997 --- squid-1.1.6.ucs/src/neighbors.h Tue Feb 11 12:45:13 1997 *************** *** 159,164 **** --- 159,167 ---- #define NEIGHBOR_DEFAULT_PARENT 0x04 #define NEIGHBOR_ROUNDROBIN 0x08 #define NEIGHBOR_MCAST_RESPONDER 0x10 + #ifdef DELAY_HACK + #define NEIGHBOR_NO_DELAY 0x20 + #endif #define PEER_MAX_ADDRESSES 10 #define RTT_AV_FACTOR 1000 diff --context --recursive squid-1.1.6/src/objcache.c squid-1.1.6.ucs/src/objcache.c *** squid-1.1.6/src/objcache.c Tue Feb 11 12:47:29 1997 --- squid-1.1.6.ucs/src/objcache.c Tue Feb 11 12:30:14 1997 *************** *** 165,170 **** --- 165,174 ---- op = MGR_REDIRECTORS; else if (!strcmp(buf, "stats/io")) op = MGR_IO; + #ifdef DELAY_HACK + else if (!strcmp(buf, "stats/delay")) + op = MGR_DELAY; + #endif else if (!strcmp(buf, "stats/reply_headers")) op = MGR_REPLY_HDRS; else if (!strcmp(buf, "stats/filedescriptors")) *************** *** 292,297 **** --- 296,306 ---- case MGR_IO: HTTPCacheInfo->stat_get(HTTPCacheInfo, "io", entry); break; + #ifdef DELAY_HACK + case MGR_DELAY: + HTTPCacheInfo->stat_get(HTTPCacheInfo, "delay", entry); + break; + #endif case MGR_REPLY_HDRS: HTTPCacheInfo->stat_get(HTTPCacheInfo, "reply_headers", entry); break; diff --context --recursive squid-1.1.6/src/objcache_opcodes.h squid-1.1.6.ucs/src/objcache_opcodes.h *** squid-1.1.6/src/objcache_opcodes.h Tue Feb 11 12:47:19 1997 --- squid-1.1.6.ucs/src/objcache_opcodes.h Tue Feb 11 12:29:25 1997 *************** *** 38,43 **** --- 38,46 ---- MGR_FQDNCACHE, MGR_INFO, MGR_IO, + #ifdef DELAY_HACK + MGR_DELAY, + #endif MGR_IPCACHE, MGR_LOG_CLEAR, MGR_LOG_DISABLE, *************** *** 68,73 **** --- 71,79 ---- "fqdncache", "info", "io", + #ifdef DELAY_HACK + "delay", + #endif "ipcache", "log/clear", "log/disable", diff --context --recursive squid-1.1.6/src/proto.c squid-1.1.6.ucs/src/proto.c *** squid-1.1.6/src/proto.c Tue Feb 11 12:47:58 1997 --- squid-1.1.6.ucs/src/proto.c Tue Feb 11 12:41:43 1997 *************** *** 155,164 **** "ICP_END" }; - #if DELAY_HACK - extern int _delay_fetch; - #endif - static void protoDataFree(int fdunused, protodispatch_data * protoData) { --- 155,160 ---- *************** *** 256,265 **** (PF) getFromDefaultSource, (void *) entry, Config.neighborTimeout); - #ifdef DELAY_HACK - if (protoData->delay_fetch && entry->mem_obj) - entry->mem_obj->e_pings_n_pings++; - #endif return; } if ((e = protoData->default_parent)) { --- 252,257 ---- *************** *** 313,321 **** protoData->single_parent = getSingleParent(request); protoData->default_parent = getDefaultParent(request); protoData->n_peers = neighborsCount(request); - #ifdef DELAY_HACK - protoData->delay_fetch = _delay_fetch; - #endif debug(17, 2, "protoDispatch: inside_firewall = %d (%s)\n", protoData->inside_firewall, --- 305,310 ---- diff --context --recursive squid-1.1.6/src/proto.h squid-1.1.6.ucs/src/proto.h *** squid-1.1.6/src/proto.h Tue Feb 11 12:47:58 1997 --- squid-1.1.6.ucs/src/proto.h Tue Feb 11 12:41:16 1997 *************** *** 287,295 **** int n_peers; struct _peer *single_parent; struct _peer *default_parent; - #if DELAY_HACK - int delay_fetch; - #endif } protodispatch_data; extern int protoDispatch _PARAMS((int, char *, StoreEntry *, request_t *)); --- 287,292 ---- diff --context --recursive squid-1.1.6/src/squid.conf.pre.in squid-1.1.6.ucs/src/squid.conf.pre.in *** squid-1.1.6/src/squid.conf.pre.in Tue Feb 11 12:47:59 1997 --- squid-1.1.6.ucs/src/squid.conf.pre.in Tue Feb 11 12:40:15 1997 *************** *** 90,95 **** --- 90,96 ---- # weight=n # ttl=n # no-query + # no-delay # default # round-robin # mulsticast-responder *************** *** 111,116 **** --- 112,120 ---- # use 'no-query' to NOT send ICP queries to this # neighbor. # + # use 'no-delay' to prevent access to this neighbor infuencing + # the delay pools. + # # use 'default' if this is a parent cache which can # be used as a "last-resort." You should probably # only use 'default' in situations where you cannot *************** *** 793,798 **** --- 797,843 ---- # By default, allow all clients who passed the http_access rules # to fetch MISSES from us. miss_access allow all + + # TAG: delay_access + # + # Set this for hosts to be in the unified and per-host delay pools. + delay_access deny all + + # TAG: delay_child_access + # + # Set this for hosts to use the child delay pool. This removes + # them from the unified or per-host delay pools if they were in them. + delay_child_access deny all + + # TAG: delay_max + # + # The maximum bytes in the unified delay pool. + #delay_max 102400 + + # TAG: delay_restore + # + # The bytes per second added to the unified delay pool. + #delay_restore 3584 + + # TAG: delay_host_max + # + # The maximum bytes per host in the per-host delay pool. + #delay_host_max 10240 + + # TAG: delay_host_restore + # + # The bytes per second added to each host in the unified delay pool. + #delay_host_restore 384 + + # TAG: delay_child_max + # + # The maximum bytes in the child delay pool. + #delay_child_max 204800 + + # TAG: delay_child_restore + # + # The bytes per second added to the child delay pool. + #delay_child_restore 8192 # TAG: cache_host_acl # Just like 'cache_host_domain' but provides more flexibility by diff --context --recursive squid-1.1.6/src/stat.c squid-1.1.6.ucs/src/stat.c *** squid-1.1.6/src/stat.c Tue Feb 11 12:47:59 1997 --- squid-1.1.6.ucs/src/stat.c Tue Feb 11 12:40:16 1997 *************** *** 292,297 **** --- 292,318 ---- storeAppendPrintf(sentry, close_bracket); } + #ifdef DELAY_HACK + void stat_delay_get(sentry) + StoreEntry *sentry; + { + int i, j; + + storeAppendPrintf(sentry, open_bracket); + storeAppendPrintf(sentry, "{Delay Statistics}\n"); + storeAppendPrintf(sentry, "{unified delay pool: %d}\n", delay_data.bytes); + storeAppendPrintf(sentry, "{children delay pool: %d}\n", delay_data.child_bytes); + storeAppendPrintf(sentry, "{}\n"); + for (i = 0; delay_nets[i] != 255; i++) { + storeAppendPrintf(sentry, "{Network %d:", delay_nets[i]); + for (j = 0; delay_hosts[i][j] != 255; j++) + storeAppendPrintf(sentry, " %d: %d", delay_hosts[i][j], delay_matrix[(i<<8)+j]); + storeAppendPrintf(sentry, "}\n"); + } + storeAppendPrintf(sentry, close_bracket); + } + #endif + /* return total bytes of all registered and known objects. * may not reflect the retrieving object.... *************** *** 429,434 **** --- 450,459 ---- stat_utilization_get(ICPCacheInfo, sentry, "ICP"); } else if (strcmp(req, "io") == 0) { stat_io_get(sentry); + #ifdef DELAY_HACK + } else if (strcmp(req, "delay") == 0) { + stat_delay_get(sentry); + #endif } else if (strcmp(req, "reply_headers") == 0) { httpReplyHeaderStats(sentry); } else if (strcmp(req, "filedescriptors") == 0) { *************** *** 1245,1252 **** --- 1270,1279 ---- case LOG_TCP_IMS_HIT: case LOG_TCP_REFRESH_HIT: case LOG_TCP_REFRESH_FAIL_HIT: + #ifndef NO_LOG_UDP case LOG_UDP_HIT: case LOG_UDP_HIT_OBJ: + #endif obj->proto_stat_data[proto_id].hit++; break; default: diff --context --recursive squid-1.1.6/src/url.h squid-1.1.6.ucs/src/url.h *** squid-1.1.6/src/url.h Tue Feb 11 12:48:00 1997 --- squid-1.1.6.ucs/src/url.h Tue Feb 11 12:40:16 1997 *************** *** 72,77 **** --- 72,80 ---- time_t ims; int imslen; int max_forwards; + #ifdef DELAY_HACK + unsigned int delay, delay_matrix_pos; + #endif }; extern char *url_convert_hex _PARAMS((char *org_url, int allocate));