diff --context --recursive squid-1.1.1/src/Makefile.in squid-1.1.1.ucs.cns/src/Makefile.in *** squid-1.1.1/src/Makefile.in Sat Dec 7 01:53:57 1996 --- squid-1.1.1.ucs.cns/src/Makefile.in Mon Dec 16 19:20:53 1996 *************** *** 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.1/src/acl.c squid-1.1.1.ucs.cns/src/acl.c *** squid-1.1.1/src/acl.c Wed Dec 4 04:26:47 1996 --- squid-1.1.1.ucs.cns/src/acl.c Mon Dec 16 19:20:53 1996 *************** *** 42,48 **** struct _acl_access *HTTPAccessList = NULL; struct _acl_access *ICPAccessList = NULL; struct _acl_access *MISSAccessList = NULL; ! #if DELAY_HACK struct _acl_access *DelayAccessList = NULL; #endif --- 42,48 ---- struct _acl_access *HTTPAccessList = NULL; struct _acl_access *ICPAccessList = NULL; struct _acl_access *MISSAccessList = NULL; ! #ifdef DELAY_HACK struct _acl_access *DelayAccessList = NULL; #endif diff --context --recursive squid-1.1.1/src/acl.h squid-1.1.1.ucs.cns/src/acl.h *** squid-1.1.1/src/acl.h Fri Nov 15 08:36:13 1996 --- squid-1.1.1.ucs.cns/src/acl.h Mon Dec 16 19:20:53 1996 *************** *** 147,152 **** extern struct _acl_deny_info_list *DenyInfoList; extern const char *AclMatchedName; ! #if DELAY_HACK extern struct _acl_access *DelayAccessList; #endif --- 147,152 ---- extern struct _acl_deny_info_list *DenyInfoList; extern const char *AclMatchedName; ! #ifdef DELAY_HACK extern struct _acl_access *DelayAccessList; #endif diff --context --recursive squid-1.1.1/src/cache_cf.c squid-1.1.1.ucs.cns/src/cache_cf.c *** squid-1.1.1/src/cache_cf.c Mon Dec 16 19:24:52 1996 --- squid-1.1.1.ucs.cns/src/cache_cf.c Mon Dec 16 19:20:53 1996 *************** *** 116,121 **** --- 116,128 ---- #define DefaultNetdbHigh 1000 /* counts, not percents */ #define DefaultNetdbLow 900 + #ifdef DELAY_HACK + #define DefaultDelayMaxBytes 100000 + #define DefaultDelayRestoreBytes 10000 + #define DefaultDelayHostMaxBytes 20000 + #define DefaultDelayHostRestoreBytes 2000 + #endif + #define DefaultWaisRelayHost (char *)NULL #define DefaultWaisRelayPort 0 *************** *** 228,233 **** --- 235,246 ---- 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 parseDelayMaxLine _PARAMS((void)); + static void parseDelayHostMaxLine _PARAMS((void)); + #endif static void parseEffectiveUserLine _PARAMS((void)); static void parseErrHtmlLine _PARAMS((void)); static void parseFtpOptionsLine _PARAMS((void)); *************** *** 489,494 **** --- 502,511 ---- options |= NEIGHBOR_PROXY_ONLY; } else if (!strcasecmp(token, "no-query")) { options |= NEIGHBOR_NO_QUERY; + #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)) { *************** *** 878,883 **** --- 895,938 ---- 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 + 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 */ + } + #endif + static void parseVisibleHostnameLine(void) { *************** *** 1041,1047 **** aclDestroyAccessList(&HTTPAccessList); aclDestroyAccessList(&MISSAccessList); aclDestroyAccessList(&ICPAccessList); ! #if DELAY_HACK aclDestroyAccessList(&DelayAccessList); #endif aclDestroyRegexList(Config.cache_stop_relist); --- 1096,1102 ---- aclDestroyAccessList(&HTTPAccessList); aclDestroyAccessList(&MISSAccessList); aclDestroyAccessList(&ICPAccessList); ! #ifdef DELAY_HACK aclDestroyAccessList(&DelayAccessList); #endif aclDestroyRegexList(Config.cache_stop_relist); *************** *** 1166,1174 **** else if (!strcmp(token, "cache_stoplist_pattern/i")) parseStoplistPattern(1); ! #if DELAY_HACK else if (!strcmp(token, "delay_access")) aclParseAccessLine(&DelayAccessList); #endif else if (!strcmp(token, "refresh_pattern")) --- 1221,1241 ---- else if (!strcmp(token, "cache_stoplist_pattern/i")) parseStoplistPattern(1); ! #ifdef DELAY_HACK else if (!strcmp(token, "delay_access")) aclParseAccessLine(&DelayAccessList); + + 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(); #endif else if (!strcmp(token, "refresh_pattern")) *************** *** 1548,1553 **** --- 1615,1626 ---- 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; + #endif Config.Announce.host = safe_xstrdup(DefaultAnnounceHost); Config.Announce.port = DefaultAnnouncePort; Config.Announce.file = safe_xstrdup(DefaultAnnounceFile); diff --context --recursive squid-1.1.1/src/cache_cf.h squid-1.1.1.ucs.cns/src/cache_cf.h *** squid-1.1.1/src/cache_cf.h Fri Dec 6 06:47:13 1996 --- squid-1.1.1.ucs.cns/src/cache_cf.h Mon Dec 16 19:20:54 1996 *************** *** 202,207 **** --- 202,213 ---- int neighborTimeout; int stallDelay; int singleParentBypass; + #ifdef DELAY_HACK + int delay_restore; + int delay_max; + int delay_host_restore; + int delay_host_max; + #endif struct { char *host; char *prefix; diff --context --recursive squid-1.1.1/src/cachemgr.c squid-1.1.1.ucs.cns/src/cachemgr.c *** squid-1.1.1/src/cachemgr.c Mon Dec 16 19:24:52 1996 --- squid-1.1.1.ucs.cns/src/cachemgr.c Mon Dec 16 19:20:54 1996 *************** *** 231,236 **** --- 231,239 ---- STATS_VM, STATS_U, STATS_IO, + #ifdef DELAY_HACK + STATS_DH, + #endif STATS_HDRS, STATS_FDS, STATS_NETDB, *************** *** 258,263 **** --- 261,269 ---- "stats/vm_objects", "stats/utilization", "stats/io", + #ifdef DELAY_HACK + "stats/delay", + #endif "stats/reply_headers", "stats/filedescriptors", "stats/netdb", *************** *** 285,290 **** --- 291,299 ---- "VM Objects", "Utilization", "I/O", + #ifdef DELAY_HACK + "Delay Pool Statistics", + #endif "HTTP Reply Headers", "Filedescriptor Usage", "Network Probe Database", *************** *** 370,375 **** --- 379,387 ---- #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.1/src/comm.c squid-1.1.1.ucs.cns/src/comm.c *** squid-1.1.1/src/comm.c Mon Dec 16 19:24:52 1996 --- squid-1.1.1.ucs.cns/src/comm.c Mon Dec 16 19:20:54 1996 *************** *** 131,136 **** --- 131,143 ---- 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 */ *************** *** 914,919 **** --- 921,931 ---- 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 */ *************** *** 921,926 **** --- 933,970 ---- /* 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 = 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); + } + 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); *************** *** 988,994 **** continue; /* scan each socket but the accept socket. Poll this ! * more frequently to minimiize losses due to the 5 connect * limit in SunOS */ for (fd = 0; fd < maxfd; fd++) { --- 1032,1038 ---- continue; /* scan each socket but the accept socket. Poll this ! * more frequently to minimize losses due to the 5 connect * limit in SunOS */ for (fd = 0; fd < maxfd; fd++) { *************** *** 1244,1249 **** --- 1288,1301 ---- 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.last_update = getCurrentTime(); + delay_nets[0] = 255; + #endif return 0; } diff --context --recursive squid-1.1.1/src/comm.h squid-1.1.1.ucs.cns/src/comm.h *** squid-1.1.1/src/comm.h Thu Nov 7 07:14:25 1996 --- squid-1.1.1.ucs.cns/src/comm.h Mon Dec 16 19:20:54 1996 *************** *** 130,135 **** --- 130,147 ---- #define FD_ASCII_NOTE_SZ 64 + #ifdef DELAY_HACK + struct _delay_data { + time_t last_update; + long 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.1/src/ftp.c squid-1.1.1.ucs.cns/src/ftp.c *** squid-1.1.1/src/ftp.c Wed Dec 4 07:30:47 1996 --- squid-1.1.1.ucs.cns/src/ftp.c Mon Dec 16 19:20:54 1996 *************** *** 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,314 ---- /* check if we want to defer reading */ clen = entry->mem_obj->e_current_len; off = storeGetLowestReaderOffset(entry); + #ifdef DELAY_HACK + if (((clen - off) > FTP_DELETE_GAP) || (data->request->delay && + (((d_m_p = data->request->delay_matrix_pos) != 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) { + 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 **** --- 329,378 ---- 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 + bufsize = SQUID_TCP_SO_RCVBUF; + len = read(fd, buf, bufsize); + if (data->request->delay) { + delay_data.bytes = 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); + } + #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.1/src/http.c squid-1.1.1.ucs.cns/src/http.c *** squid-1.1.1/src/http.c Mon Dec 16 19:24:52 1996 --- squid-1.1.1.ucs.cns/src/http.c Mon Dec 16 19:20:54 1996 *************** *** 110,115 **** --- 110,116 ---- #include "squid.h" + #define HTTP_DELETE_GAP (1<<18) static const char *const w_space = " \t\n\r"; *************** *** 528,533 **** --- 529,537 ---- int bin; int clen; int off; + #ifdef DELAY_HACK + int bufsize, d_m_p; + #endif StoreEntry *entry = NULL; entry = httpState->entry; *************** *** 540,552 **** --- 544,568 ---- /* check if we want to defer reading */ clen = entry->mem_obj->e_current_len; off = storeGetLowestReaderOffset(entry); + #ifdef DELAY_HACK + if (((clen - off) > HTTP_DELETE_GAP) || (httpState->request->delay && + (((d_m_p = httpState->request->delay_matrix_pos) != 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); *************** *** 573,580 **** --- 589,644 ---- 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 + 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 + debug(11, 2, "httpReadReply: No DELAY %d bytes read.\n", len); + #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++; *************** *** 871,876 **** --- 935,945 ---- if (e->options & NEIGHBOR_PROXY_ONLY) storeStartDeleteBehind(entry); + #ifdef DELAY_HACK + if (e->options & NEIGHBOR_NO_DELAY) + orig_request->delay = 0; + #endif + /* Create socket. */ sock = comm_open(SOCK_STREAM, 0, *************** *** 888,893 **** --- 957,966 ---- 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.1/src/icp.c squid-1.1.1.ucs.cns/src/icp.c *** squid-1.1.1/src/icp.c Mon Dec 16 19:24:52 1996 --- squid-1.1.1.ucs.cns/src/icp.c Mon Dec 16 19:20:54 1996 *************** *** 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,155 **** "ERR_PROXY_DENIED" }; - #if DELAY_HACK - int _delay_fetch; - #endif static icpUdpData *UdpQueueHead = NULL; static icpUdpData *UdpQueueTail = NULL; --- 149,154 ---- *************** *** 174,180 **** --- 173,181 ---- 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 icpSendERRORComplete _PARAMS((int, char *, int, int, void *)); *************** *** 830,835 **** --- 831,839 ---- icpState->method, icpState->url, fd_table[fd].ipaddr); + #ifdef DELAY_HACK + icpState->request->delay = 0; + #endif icpSendERROR(fd, LOG_TCP_DENIED, buf, icpState, icpState->http_code); return 0; } *************** *** 852,867 **** icpState->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) { --- 856,877 ---- icpState->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, "icpDelaySet: %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) { *************** *** 892,897 **** --- 902,908 ---- queue->logcode, CACHE_ICP_PORT); } + #endif int icpUdpReply(int fd, icpUdpData * queue) *************** *** 921,928 **** --- 932,941 ---- result = COMM_ERROR; } UdpQueueHead = queue->next; + #ifndef NO_LOG_UDP if (queue->logcode) icpLogIcp(queue); + #endif safe_free(queue->msg); safe_free(queue); } *************** *** 1018,1024 **** --- 1031,1039 ---- 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)); *************** *** 1029,1035 **** --- 1044,1052 ---- 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, *************** *** 1061,1067 **** --- 1078,1086 ---- icpUdpSend(icpHitObjState->fd, &icpHitObjState->to, reply, + #ifndef NO_LOG_UDP LOG_UDP_HIT_OBJ, + #endif urlParseProtocol(entry->url)); } storeUnlockObject(entry); *************** *** 1126,1132 **** --- 1145,1155 ---- 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; *************** *** 1137,1143 **** --- 1160,1170 ---- 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; } *************** *** 1166,1185 **** --- 1193,1228 ---- safe_free(icpHitObjState); } else { reply = icpCreateMessage(ICP_OP_HIT, 0, 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, 0, 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, 0, 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, 0, 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; *************** *** 1276,1282 **** --- 1319,1329 ---- 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; *************** *** 1287,1293 **** --- 1334,1344 ---- 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; } *************** *** 1297,1315 **** --- 1348,1382 ---- 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.1/src/icp.h squid-1.1.1.ucs.cns/src/icp.h *** squid-1.1.1/src/icp.h Thu Nov 28 15:26:27 1996 --- squid-1.1.1.ucs.cns/src/icp.h Mon Dec 16 19:20:21 1996 *************** *** 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.1/src/neighbors.c squid-1.1.1.ucs.cns/src/neighbors.c *** squid-1.1.1/src/neighbors.c Fri Dec 6 13:50:09 1996 --- squid-1.1.1.ucs.cns/src/neighbors.c Mon Dec 16 19:22:51 1996 *************** *** 468,474 **** --- 468,476 ---- icpUdpSend(theOutIcpConnection, &e->in_addr, query, + #ifndef NO_LOG_UDP LOG_TAG_NONE, + #endif PROTO_NONE); } else { flags = 0; *************** *** 481,487 **** --- 483,491 ---- icpUdpSend(theOutIcpConnection, &e->in_addr, query, + #ifndef NO_LOG_UDP LOG_TAG_NONE, + #endif PROTO_NONE); } *************** *** 502,508 **** } else { /* Neighbor is dead; ping it anyway, but don't expect a reply */ /* log it once at the threshold */ ! if ((e->stats.ack_deficit == HIER_MAX_DEFICIT)) { debug(15, 0, "Detected DEAD %s: %s/%d/%d\n", e->type == EDGE_SIBLING ? "SIBLING" : "PARENT", e->host, e->http_port, e->icp_port); --- 506,512 ---- } else { /* Neighbor is dead; ping it anyway, but don't expect a reply */ /* log it once at the threshold */ ! if ((e->stats.ack_deficit == HIER_MAX_DEFICIT) && !e->mcast_ttl) { debug(15, 0, "Detected DEAD %s: %s/%d/%d\n", e->type == EDGE_SIBLING ? "SIBLING" : "PARENT", e->host, e->http_port, e->icp_port); *************** *** 529,535 **** --- 533,541 ---- icpUdpSend(theOutIcpConnection, &to_addr, query, + #ifndef NO_LOG_UDP LOG_TAG_NONE, + #endif PROTO_NONE); } } else { *************** *** 692,698 **** } } else if (opcode == ICP_OP_MISS) { if (e == NULL) { ! debug(15, 1, "Ignoring MISS from non-neighbor %s\n", inet_ntoa(from->sin_addr)); } else if (ntype == EDGE_PARENT) { w_rtt = tvSubMsec(mem->start_ping, current_time) / e->weight; --- 698,704 ---- } } else if (opcode == ICP_OP_MISS) { if (e == NULL) { ! debug(15, 2, "Ignoring MISS from non-neighbor %s\n", inet_ntoa(from->sin_addr)); } else if (ntype == EDGE_PARENT) { w_rtt = tvSubMsec(mem->start_ping, current_time) / e->weight; diff --context --recursive squid-1.1.1/src/neighbors.h squid-1.1.1.ucs.cns/src/neighbors.h *** squid-1.1.1/src/neighbors.h Wed Nov 27 07:22:18 1996 --- squid-1.1.1.ucs.cns/src/neighbors.h Mon Dec 16 19:20:54 1996 *************** *** 153,158 **** --- 153,161 ---- #define NEIGHBOR_PROXY_ONLY 0x01 #define NEIGHBOR_NO_QUERY 0x02 #define NEIGHBOR_DEFAULT_PARENT 0x04 + #ifdef DELAY_HACK + #define NEIGHBOR_NO_DELAY 0x08 + #endif #define EDGE_MAX_ADDRESSES 10 #define RTT_AV_FACTOR 1000 diff --context --recursive squid-1.1.1/src/objcache.c squid-1.1.1.ucs.cns/src/objcache.c *** squid-1.1.1/src/objcache.c Thu Nov 28 15:28:25 1996 --- squid-1.1.1.ucs.cns/src/objcache.c Mon Dec 16 19:20:54 1996 *************** *** 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")) *************** *** 290,295 **** --- 294,304 ---- 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.1/src/objcache_opcodes.h squid-1.1.1.ucs.cns/src/objcache_opcodes.h *** squid-1.1.1/src/objcache_opcodes.h Mon Dec 16 19:24:52 1996 --- squid-1.1.1.ucs.cns/src/objcache_opcodes.h Mon Dec 16 19:20:54 1996 *************** *** 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.1/src/proto.c squid-1.1.1.ucs.cns/src/proto.c *** squid-1.1.1/src/proto.c Wed Nov 27 03:07:28 1996 --- squid-1.1.1.ucs.cns/src/proto.c Mon Dec 16 19:20:54 1996 *************** *** 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 ---- *************** *** 310,318 **** protoData->single_parent = getSingleParent(request); protoData->default_parent = getDefaultParent(request); protoData->n_edges = neighborsCount(request); - #ifdef DELAY_HACK - protoData->delay_fetch = _delay_fetch; - #endif debug(17, 2, "protoDispatch: inside_firewall = %d (%s)\n", protoData->inside_firewall, --- 302,307 ---- diff --context --recursive squid-1.1.1/src/proto.h squid-1.1.1.ucs.cns/src/proto.h *** squid-1.1.1/src/proto.h Wed Nov 27 03:07:29 1996 --- squid-1.1.1.ucs.cns/src/proto.h Mon Dec 16 19:20:54 1996 *************** *** 287,295 **** int n_edges; struct _edge *single_parent; struct _edge *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.1/src/stat.c squid-1.1.1.ucs.cns/src/stat.c *** squid-1.1.1/src/stat.c Mon Dec 16 19:24:52 1996 --- squid-1.1.1.ucs.cns/src/stat.c Mon Dec 16 19:20:54 1996 *************** *** 292,297 **** --- 292,317 ---- 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, "{}\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 **** --- 449,458 ---- 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) { *************** *** 1096,1108 **** hier_timeout = hierData->timeout; } if (Config.commonLogFormat) ! sprintf(tmp, "%s %s - [%s] \"%s %s\" %s %d\n", client, ident, mkhttpdlogtime(&squid_curtime), method, url, action, size); else sprintf(tmp, "%9d.%03d %6d %s %s/%03d %d %s %s %s %s%s/%s %s\n", --- 1120,1134 ---- hier_timeout = hierData->timeout; } if (Config.commonLogFormat) ! sprintf(tmp, "%s %s - [%s] \"%s %s\" %s:%s%s %d\n", client, ident, mkhttpdlogtime(&squid_curtime), method, url, action, + hier_timeout ? "TIMEOUT_" : null_string, + hier_strings[hier_code], size); else sprintf(tmp, "%9d.%03d %6d %s %s/%03d %d %s %s %s %s%s/%s %s\n", *************** *** 1245,1252 **** --- 1271,1280 ---- 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.1/src/url.h squid-1.1.1.ucs.cns/src/url.h *** squid-1.1.1/src/url.h Mon Dec 16 19:24:52 1996 --- squid-1.1.1.ucs.cns/src/url.h Mon Dec 16 19:21:42 1996 *************** *** 69,74 **** --- 69,77 ---- float http_ver; time_t ims; int imslen; + #ifdef DELAY_HACK + unsigned int delay, delay_matrix_pos; + #endif }; extern char *url_convert_hex _PARAMS((char *org_url, int allocate));