diff -cr squid-1.0.beta3/ChangeLog squid-1.0.beta4/ChangeLog *** squid-1.0.beta3/ChangeLog Wed Apr 24 08:29:52 1996 --- squid-1.0.beta4/ChangeLog Thu Apr 25 16:31:16 1996 *************** *** 97,99 **** --- 97,118 ---- - Fixed ERR_INVALID_URL bug for URLs with a password field. - Added to Release-Notes info about converting 'cache/log' and difference between stoplists and ttl_pattern. + + Changes to squid-1.0.beta4: + + - Added a handler to restart the ftpget server. + - Fixed access checks for ICP by parsing the requested URL. + - Added "magic marker" to ftpget-generated errors so they can + be negative-cached. + - Added a small run-time check to configure to see if signal + handlers should be restarted after invocation (ala SYSV). + - Determine Maximum filedescriptors in configure and change + FD_SETSIZE if needed. + - Changed read stall algorithm for HTTP. No don't wait until + the object is in DELETE_BEHIND mode to stall the server read + and wait for the client to catch up. Also changed from 4k to + 16k read buffer. + - Fixed HTTP request parsing to check for blank line at the + end of all requests. Symptoms were "connection reset" + messages. + diff -cr squid-1.0.beta3/acconfig.h squid-1.0.beta4/acconfig.h *** squid-1.0.beta3/acconfig.h Mon Apr 15 11:00:25 1996 --- squid-1.0.beta4/acconfig.h Thu Apr 25 09:37:08 1996 *************** *** 1,8 **** ! /* $Id: acconfig.h,v 1.2 1996/04/15 18:00:25 wessels Exp $ */ ! /* Define struct tm has tm_gmtoff member */ #undef HAVE_TM_GMTOFF ! /* Define struct mallinfo has mxfast member */ #undef HAVE_EXT_MALLINFO --- 1,13 ---- ! /* $Id: acconfig.h,v 1.2.2.2 1996/04/25 16:37:08 wessels Exp $ */ ! /* Define if struct tm has tm_gmtoff member */ #undef HAVE_TM_GMTOFF ! /* Define if struct mallinfo has mxfast member */ #undef HAVE_EXT_MALLINFO + /* Define if signal handlers must be reset after invocation */ + #undef RESET_SIGNAL_HANDLER + + /* Maximum number of open filedescriptors */ + #undef SQUID_FD_SETSIZE diff -cr squid-1.0.beta3/configure squid-1.0.beta4/configure *** squid-1.0.beta3/configure Tue Apr 23 12:51:48 1996 --- squid-1.0.beta4/configure Thu Apr 25 09:37:08 1996 *************** *** 517,523 **** ! # From configure.in Revision: 1.18.2.1 ac_aux_dir= for ac_dir in aux $srcdir/aux; do if test -f $ac_dir/install-sh; then --- 517,523 ---- ! # From configure.in Revision: 1.18.2.3 ac_aux_dir= for ac_dir in aux $srcdir/aux; do if test -f $ac_dir/install-sh; then *************** *** 1362,1367 **** --- 1362,1394 ---- rm -f conftest* + echo $ac_n "checking if signal handlers need to be reset""... $ac_c" 1>&6 + if test "$cross_compiling" = yes; then + cat >> confdefs.h <<\EOF + #define RESET_SIGNAL_HANDLER 1 + EOF + + echo "$ac_t""yes" 1>&6 + else + cat > conftest.$ac_ext </dev/null; then + echo "$ac_t""no" 1>&6 + else + cat >> confdefs.h <<\EOF + #define RESET_SIGNAL_HANDLER 1 + EOF + + echo "$ac_t""yes" 1>&6 + fi + fi + rm -fr conftest* + echo $ac_n "checking size of int""... $ac_c" 1>&6 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 *************** *** 1370,1376 **** { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() --- 1397,1403 ---- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() *************** *** 1404,1410 **** { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() --- 1431,1437 ---- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() *************** *** 1438,1444 **** echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { return 0; } --- 1465,1471 ---- echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { return 0; } *************** *** 1470,1476 **** echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 else cat > conftest.$ac_ext <&6 else cat > conftest.$ac_ext <&6 else cat > conftest.$ac_ext <&6 else cat > conftest.$ac_ext <&6 else cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <&6 else cat > conftest.$ac_ext <&6 else cat > conftest.$ac_ext <&6 fi done + + + echo $ac_n "checking Maximum number of filedescriptors we can open""... $ac_c" 1>&6 + if test "$cross_compiling" = yes; then + SQUID_FD_SETSIZE=256 + else + cat > conftest.$ac_ext < + #include + #include + main() { + int i,j; + #if HAVE_SETRLIMIT + struct rlimit rl; + #if defined(RLIMIT_NOFILE) + if (getrlimit(RLIMIT_NOFILE, &rl) < 0) { + perror("getrlimit: RLIMIT_NOFILE"); + } else { + rl.rlim_cur = rl.rlim_max; /* set it to the max */ + if (setrlimit(RLIMIT_NOFILE, &rl) < 0) { + perror("setrlimit: RLIMIT_NOFILE"); + } + } + #elif defined(RLIMIT_OFILE) + if (getrlimit(RLIMIT_OFILE, &rl) < 0) { + perror("getrlimit: RLIMIT_OFILE"); + } else { + rl.rlim_cur = rl.rlim_max; /* set it to the max */ + if (setrlimit(RLIMIT_OFILE, &rl) < 0) { + perror("setrlimit: RLIMIT_OFILE"); + } + } + #endif /* RLIMIT_NOFILE */ + #endif /* HAVE_SETRLIMIT */ + #if HAVE_SYSCONF && defined(_SC_OPEN_MAX) + i = sysconf(_SC_OPEN_MAX); + #elif HAVE_GETDTABLESIZE + i = getdtablesize(); + #elif defined(OPEN_MAX) + i = OPEN_MAX; + #elif defined(NOFILE) + i = NOFILE; + #elif defined(_NFILE) + i = _NFILE; + #else + while((j=open("/dev/null", 0)) > 0) i=j; + #endif + fprintf (fopen("conftestval", "w"), "%d\n", i); + exit(0); + } + + EOF + eval $ac_link + if test -s conftest && (./conftest; exit) 2>/dev/null; then + SQUID_FD_SETSIZE=`cat conftestval` + else + SQUID_FD_SETSIZE=256 + fi + fi + rm -fr conftest* + echo "$ac_t""$SQUID_FD_SETSIZE" 1>&6 + cat >> confdefs.h < + #include + #include + main() { + int i,j; + #if HAVE_SETRLIMIT + struct rlimit rl; + #if defined(RLIMIT_NOFILE) + if (getrlimit(RLIMIT_NOFILE, &rl) < 0) { + perror("getrlimit: RLIMIT_NOFILE"); + } else { + rl.rlim_cur = rl.rlim_max; /* set it to the max */ + if (setrlimit(RLIMIT_NOFILE, &rl) < 0) { + perror("setrlimit: RLIMIT_NOFILE"); + } + } + #elif defined(RLIMIT_OFILE) + if (getrlimit(RLIMIT_OFILE, &rl) < 0) { + perror("getrlimit: RLIMIT_OFILE"); + } else { + rl.rlim_cur = rl.rlim_max; /* set it to the max */ + if (setrlimit(RLIMIT_OFILE, &rl) < 0) { + perror("setrlimit: RLIMIT_OFILE"); + } + } + #endif /* RLIMIT_NOFILE */ + #endif /* HAVE_SETRLIMIT */ + #if HAVE_SYSCONF && defined(_SC_OPEN_MAX) + i = sysconf(_SC_OPEN_MAX); + #elif HAVE_GETDTABLESIZE + i = getdtablesize(); + #elif defined(OPEN_MAX) + i = OPEN_MAX; + #elif defined(NOFILE) + i = NOFILE; + #elif defined(_NFILE) + i = _NFILE; + #else + while((j=open("/dev/null", 0)) > 0) i=j; + #endif + fprintf (fopen("conftestval", "w"), "%d\n", i); + exit(0); + } + ], + SQUID_FD_SETSIZE=`cat conftestval`, + SQUID_FD_SETSIZE=256, + SQUID_FD_SETSIZE=256) + AC_MSG_RESULT($SQUID_FD_SETSIZE) + AC_DEFINE_UNQUOTED(SQUID_FD_SETSIZE, $SQUID_FD_SETSIZE) dnl Need the debugging version of malloc if available XTRA_OBJS='' diff -cr squid-1.0.beta3/include/autoconf.h.in squid-1.0.beta4/include/autoconf.h.in *** squid-1.0.beta3/include/autoconf.h.in Tue Apr 23 12:51:49 1996 --- squid-1.0.beta4/include/autoconf.h.in Thu Apr 25 09:37:09 1996 *************** *** 25,35 **** /* Define if you have the ANSI C header files. */ #undef STDC_HEADERS ! /* Define struct tm has tm_gmtoff member */ #undef HAVE_TM_GMTOFF ! /* Define struct mallinfo has mxfast member */ #undef HAVE_EXT_MALLINFO /* The number of bytes in a int. */ #undef SIZEOF_INT --- 25,41 ---- /* Define if you have the ANSI C header files. */ #undef STDC_HEADERS ! /* Define if struct tm has tm_gmtoff member */ #undef HAVE_TM_GMTOFF ! /* Define if struct mallinfo has mxfast member */ #undef HAVE_EXT_MALLINFO + + /* Define if signal handlers must be reset after invocation */ + #undef RESET_SIGNAL_HANDLER + + /* Maximum number of open filedescriptors */ + #undef SQUID_FD_SETSIZE /* The number of bytes in a int. */ #undef SIZEOF_INT diff -cr squid-1.0.beta3/include/version.h squid-1.0.beta4/include/version.h *** squid-1.0.beta3/include/version.h Mon Apr 22 14:23:28 1996 --- squid-1.0.beta4/include/version.h Thu Apr 25 16:31:29 1996 *************** *** 1,7 **** ! /* $Id: version.h,v 1.19.4.2 1996/04/22 21:23:28 wessels Exp $ * * SQUID_VERSION - String for version id of this distribution */ #ifndef SQUID_VERSION ! #define SQUID_VERSION "1.0.beta3" #endif --- 1,7 ---- ! /* $Id: version.h,v 1.19.4.3 1996/04/25 23:31:29 wessels Exp $ * * SQUID_VERSION - String for version id of this distribution */ #ifndef SQUID_VERSION ! #define SQUID_VERSION "1.0.beta4" #endif diff -cr squid-1.0.beta3/src/cache_cf.c squid-1.0.beta4/src/cache_cf.c *** squid-1.0.beta3/src/cache_cf.c Fri Apr 19 14:38:27 1996 --- squid-1.0.beta4/src/cache_cf.c Thu Apr 25 15:05:38 1996 *************** *** 1,4 **** ! /* $Id: cache_cf.c,v 1.53.4.3 1996/04/19 21:38:27 wessels Exp $ */ /* DEBUG: Section 3 cache_cf: Configuration file parsing */ --- 1,4 ---- ! /* $Id: cache_cf.c,v 1.53.4.6 1996/04/25 22:05:38 wessels Exp $ */ /* DEBUG: Section 3 cache_cf: Configuration file parsing */ *************** *** 141,147 **** #define DefaultCommonLogFormat 1 /* default on */ #define DefaultQuickAbort 0 /* default off */ #define DefaultNeighborTimeout 2 /* 2 seconds */ ! #define DefaultStallDelay 3 /* 3 seconds */ #define DefaultSingleParentBypass 0 /* default off */ #define DefaultPidFilename (char *)NULL /* default NONE */ #define DefaultVisibleHostname (char *)NULL /* default NONE */ --- 141,147 ---- #define DefaultCommonLogFormat 1 /* default on */ #define DefaultQuickAbort 0 /* default off */ #define DefaultNeighborTimeout 2 /* 2 seconds */ ! #define DefaultStallDelay 1 /* 1 seconds */ #define DefaultSingleParentBypass 0 /* default off */ #define DefaultPidFilename (char *)NULL /* default NONE */ #define DefaultVisibleHostname (char *)NULL /* default NONE */ *************** *** 1086,1092 **** aclDestroyAccessList(&ICPAccessList); if ((fp = fopen(file_name, "r")) == NULL) { ! sprintf(fatal_str, "Unable to open configuration file: %s", file_name); fatal(fatal_str); } cfg_filename = file_name; --- 1086,1093 ---- aclDestroyAccessList(&ICPAccessList); if ((fp = fopen(file_name, "r")) == NULL) { ! sprintf(fatal_str, "Unable to open configuration file: %s: %s", ! file_name, xstrerror()); fatal(fatal_str); } cfg_filename = file_name; diff -cr squid-1.0.beta3/src/comm.c squid-1.0.beta4/src/comm.c *** squid-1.0.beta3/src/comm.c Thu Apr 18 11:03:43 1996 --- squid-1.0.beta4/src/comm.c Thu Apr 25 15:11:28 1996 *************** *** 1,5 **** ! /* $Id: comm.c,v 1.30.2.1 1996/04/18 18:03:43 wessels Exp $ */ /* DEBUG: Section 5 comm: socket level functions */ --- 1,5 ---- ! /* $Id: comm.c,v 1.30.4.2 1996/04/25 22:11:28 wessels Exp $ */ /* DEBUG: Section 5 comm: socket level functions */ *************** *** 568,573 **** --- 568,575 ---- if (!fdstat_are_n_free_fd(RESERVED_FD)) { FD_CLR(theAsciiConnection, &readfds); } + if (shutdown_pending || reread_pending) + debug(5, 1, "comm_select: Still waiting on %d FDs\n", nfds); if (nfds == 0) return COMM_SHUTDOWN; while (1) { *************** *** 903,908 **** --- 905,911 ---- fd_set read_x; fd_set write_x; fd_set except_x; + int num; int maxfd = getMaxFD(); struct timeval tv; FD_ENTRY *f = NULL; *************** *** 909,961 **** debug(5, 0, "examine_select: Examining open file descriptors...\n"); for (fd = 0; fd < maxfd; fd++) { - if (!FD_ISSET(fd, readfds) && !FD_ISSET(fd, writefds) && !FD_ISSET(fd, exceptfds)) - continue; FD_ZERO(&read_x); FD_ZERO(&write_x); FD_ZERO(&except_x); tv.tv_sec = tv.tv_usec = 0; ! FD_SET(fd, &read_x); ! if (select(FD_SETSIZE, &read_x, &read_x, &read_x, &tv) >= 0) ! continue; ! debug(5, 0, "examine_select: FD %d: select: %s\n", fd, ! xstrerror()); ! if (errno != EBADF) ! continue; ! f = &fd_table[fd]; ! debug(5, 0, "WARNING: FD %d has handlers, but it's invalid.\n", ! fd); ! debug(5, 0, "lifetm:%p tmout:%p read:%p write:%p expt:%p\n", ! f->lifetime_handler, ! f->timeout_handler, ! f->read_handler, ! f->write_handler, ! f->except_handler); ! if (f->close_handler) { ! debug(5, 0, "examine_select: Calling Close Handler\n"); ! f->close_handler(fd, f->close_data); ! } else if (f->lifetime_handler) { ! debug(5, 0, "examine_select: Calling Lifetime Handler\n"); ! f->lifetime_handler(fd, f->lifetime_data); ! } else if (f->timeout_handler) { ! debug(5, 0, "examine_select: Calling Timeout Handler\n"); ! f->timeout_handler(fd, f->timeout_data); ! } else if (f->read_handler) { ! debug(5, 0, "examine_select: Calling Read Handler\n"); ! f->read_handler(fd, f->read_data); ! } else if (f->write_handler) { ! debug(5, 0, "examine_select: Calling Write Handler\n"); ! f->write_handler(fd, f->write_data); } - f->close_handler = NULL; - f->lifetime_handler = NULL; - f->timeout_handler = NULL; - f->read_handler = NULL; - f->write_handler = NULL; - f->except_handler = NULL; - FD_CLR(fd, readfds); - FD_CLR(fd, writefds); - FD_CLR(fd, exceptfds); } debug(5, 0, "examine_select: Finished examining open file descriptors.\n"); return 0; --- 912,956 ---- debug(5, 0, "examine_select: Examining open file descriptors...\n"); for (fd = 0; fd < maxfd; fd++) { FD_ZERO(&read_x); FD_ZERO(&write_x); FD_ZERO(&except_x); tv.tv_sec = tv.tv_usec = 0; ! if ((FD_ISSET(fd, readfds)) || ! (FD_ISSET(fd, writefds)) || ! (FD_ISSET(fd, exceptfds))) { ! FD_SET(fd, &read_x); ! num = select(FD_SETSIZE, &read_x, &read_x, &read_x, &tv); ! if (num < 0) { ! f = &fd_table[fd]; ! debug(5, 0, "WARNING: FD %d has handlers, but it's invalid.\n", fd); ! debug(5, 0, "lifetm:%p tmout:%p read:%p write:%p expt:%p\n", ! f->lifetime_handler, ! f->timeout_handler, ! f->read_handler, ! f->write_handler, ! f->except_handler); ! if (f->close_handler) { ! debug(5, 0, "examine_select: Calling Close Handler\n"); ! f->close_handler(fd, f->close_data); ! } else if (f->lifetime_handler) { ! debug(5, 0, "examine_select: Calling Lifetime Handler\n"); ! f->lifetime_handler(fd, f->lifetime_data); ! } else if (f->timeout_handler) { ! debug(5, 0, "examine_select: Calling Timeout Handler\n"); ! f->timeout_handler(fd, f->timeout_data); ! } ! f->close_handler = 0; ! f->lifetime_handler = 0; ! f->timeout_handler = 0; ! f->read_handler = 0; ! f->write_handler = 0; ! f->except_handler = 0; ! FD_CLR(fd, readfds); ! FD_CLR(fd, writefds); ! FD_CLR(fd, exceptfds); ! } } } debug(5, 0, "examine_select: Finished examining open file descriptors.\n"); return 0; *************** *** 1023,1037 **** } if (tmp_local) { if (use_lifetime_handler) { ! debug(5, 2, "comm_select: FD %d lifetime expire: %d < %d (Lifetime handler %p)\n", fd, lft, squid_curtime, tmp_local); } else { ! debug(5, 2, "comm_select: FD %d lifetime expire: %d < %d (%s handler %p)\n", fd, lft, squid_curtime, use_read ? "read" : "write", tmp_local); } } else { ! debug(5, 1, "comm_select: FD %d lifetime expire: %d < %d (handler not available.)\n", fd, lft, squid_curtime); } --- 1018,1032 ---- } if (tmp_local) { if (use_lifetime_handler) { ! debug(5, 2, "checkLifetimes: FD %d lifetime expire: %d < %d (Lifetime handler %p)\n", fd, lft, squid_curtime, tmp_local); } else { ! debug(5, 2, "checkLifetimes: FD %d lifetime expire: %d < %d (%s handler %p)\n", fd, lft, squid_curtime, use_read ? "read" : "write", tmp_local); } } else { ! debug(5, 1, "checkLifetimes: FD %d lifetime expire: %d < %d (handler not available.)\n", fd, lft, squid_curtime); } *************** *** 1044,1061 **** * deallocates the structure. */ (void) close(fd); tmp_local(fd, use_read ? fd_table[fd].read_data : fd_table[fd].write_data); } if (fd_table[fd].openned) { /* hmm.. still openned. do full comm_close */ ! debug(5, 5, "comm_select: FD %d lifetime expire: %d < %d : Handler did not close the socket.\n comm_select will do.\n", fd, lft, squid_curtime); comm_close(fd); } else { /* seems like handle closed it. * clean up fd_table just to make sure */ ! debug(5, 5, "comm_select: FD %d lifetime expire: %d : Handler closed the socket.\n", fd, lft); /* just to make sure here */ comm_cleanup_fd_entry(fd); --- 1039,1057 ---- * deallocates the structure. */ (void) close(fd); + debug(5, 0, "checkLifetimes: Forcing close on FD %d\n", fd); tmp_local(fd, use_read ? fd_table[fd].read_data : fd_table[fd].write_data); } if (fd_table[fd].openned) { /* hmm.. still openned. do full comm_close */ ! debug(5, 5, "checkLifetimes: FD %d lifetime expire: %d < %d : Handler did not close the socket.\n comm_select will do.\n", fd, lft, squid_curtime); comm_close(fd); } else { /* seems like handle closed it. * clean up fd_table just to make sure */ ! debug(5, 5, "checkLifetimes: FD %d lifetime expire: %d : Handler closed the socket.\n", fd, lft); /* just to make sure here */ comm_cleanup_fd_entry(fd); *************** *** 1062,1068 **** } } else { /* no handle. do full comm_close */ ! debug(5, 5, "comm_select: FD %d lifetime expire: %d < %d : No handler to close the socket.\n comm_select will do.\n", fd, lft, squid_curtime); comm_close(fd); } --- 1058,1064 ---- } } else { /* no handle. do full comm_close */ ! debug(5, 5, "checkLifetimes: FD %d lifetime expire: %d < %d : No handler to close the socket.\n comm_select will do.\n", fd, lft, squid_curtime); comm_close(fd); } diff -cr squid-1.0.beta3/src/connect.c squid-1.0.beta4/src/connect.c *** squid-1.0.beta3/src/connect.c Fri Apr 19 09:37:17 1996 --- squid-1.0.beta4/src/connect.c Thu Apr 25 16:25:24 1996 *************** *** 1,5 **** /* ! * $Id: connect.c,v 1.11.4.1 1996/04/19 16:37:17 wessels Exp $ * * DEBUG: Section 26 connect */ --- 1,5 ---- /* ! * $Id: connect.c,v 1.11.4.3 1996/04/25 23:25:24 wessels Exp $ * * DEBUG: Section 26 connect */ *************** *** 77,83 **** debug(26, 5, "connectReadRemote FD %d read len:%d\n", fd, len); if (len < 0) { ! debug(26, 1, "connectReadRemote: FD %d: read failure: %s.\n", xstrerror()); if (errno == EAGAIN || errno == EWOULDBLOCK) { /* reinstall handlers */ /* XXX This may loop forever */ --- 77,83 ---- debug(26, 5, "connectReadRemote FD %d read len:%d\n", fd, len); if (len < 0) { ! debug(26, 1, "connectReadRemote: FD %d: read failure: %s.\n", fd, xstrerror()); if (errno == EAGAIN || errno == EWOULDBLOCK) { /* reinstall handlers */ /* XXX This may loop forever */ *************** *** 89,95 **** COMM_SELECT_TIMEOUT, (PF) connectReadTimeout, (void *) data, ! getReadTimeout()); } else { BIT_RESET(entry->flag, CACHABLE); storeReleaseRequest(entry); --- 89,95 ---- COMM_SELECT_TIMEOUT, (PF) connectReadTimeout, (void *) data, ! data->timeout); } else { BIT_RESET(entry->flag, CACHABLE); storeReleaseRequest(entry); *************** *** 238,244 **** debug(26, 5, "connectConnInProgress: FD %d data=%p\n", fd, data); if (comm_connect(fd, req->host, req->port) != COMM_OK) { ! debug(26, 5, "connectConnInProgress: FD %d errno=%d", fd, errno); switch (errno) { #if EINPROGRESS != EALREADY case EINPROGRESS: --- 238,244 ---- debug(26, 5, "connectConnInProgress: FD %d data=%p\n", fd, data); if (comm_connect(fd, req->host, req->port) != COMM_OK) { ! debug(26, 5, "connectConnInProgress: FD %d: %s", fd, xstrerror()); switch (errno) { #if EINPROGRESS != EALREADY case EINPROGRESS: diff -cr squid-1.0.beta3/src/disk.c squid-1.0.beta4/src/disk.c *** squid-1.0.beta3/src/disk.c Wed Apr 17 10:15:23 1996 --- squid-1.0.beta4/src/disk.c Thu Apr 25 15:09:19 1996 *************** *** 1,4 **** ! /* $Id: disk.c,v 1.11 1996/04/17 17:15:23 wessels Exp $ */ /* DEBUG: Section 6 disk: disk I/O routines */ --- 1,4 ---- ! /* $Id: disk.c,v 1.11.4.1 1996/04/25 22:09:19 wessels Exp $ */ /* DEBUG: Section 6 disk: disk I/O routines */ *************** *** 474,480 **** /* reschedule if need more data. */ if (ctrl_dat->cur_len < ctrl_dat->req_len) { ! comm_set_select_handler(fd, COMM_SELECT_READ, (PF) diskHandleRead, (void *) ctrl_dat); return DISK_OK; } else { --- 474,482 ---- /* reschedule if need more data. */ if (ctrl_dat->cur_len < ctrl_dat->req_len) { ! comm_set_select_handler(fd, ! COMM_SELECT_READ, ! (PF) diskHandleRead, (void *) ctrl_dat); return DISK_OK; } else { *************** *** 513,519 **** ctrl_dat->handler = handler; ctrl_dat->client_data = client_data; ! comm_set_select_handler(fd, COMM_SELECT_READ, (PF) diskHandleRead, (void *) ctrl_dat); return DISK_OK; --- 515,523 ---- ctrl_dat->handler = handler; ctrl_dat->client_data = client_data; ! comm_set_select_handler(fd, ! COMM_SELECT_READ, ! (PF) diskHandleRead, (void *) ctrl_dat); return DISK_OK; diff -cr squid-1.0.beta3/src/fdstat.c squid-1.0.beta4/src/fdstat.c *** squid-1.0.beta3/src/fdstat.c Wed Apr 17 08:07:28 1996 --- squid-1.0.beta4/src/fdstat.c Thu Apr 25 15:08:30 1996 *************** *** 1,5 **** ! /* $Id: fdstat.c,v 1.13 1996/04/17 15:07:28 wessels Exp $ */ /* DEBUG: Section 7 fdstat: */ --- 1,5 ---- ! /* $Id: fdstat.c,v 1.13.4.1 1996/04/25 22:08:30 wessels Exp $ */ /* DEBUG: Section 7 fdstat: */ *************** *** 172,177 **** --- 172,178 ---- { int fd; int n_free_fd = 0; + int maxfd = getMaxFD(); #if FD_TEST int lowest_avail_fd; *************** *** 199,205 **** #endif if (n == 0) { ! for (fd = 0; fd < getMaxFD(); ++fd) if (fd_stat_tab[fd].status == CLOSE) ++n; return (n); --- 200,206 ---- #endif if (n == 0) { ! for (fd = 0; fd < maxfd; ++fd) if (fd_stat_tab[fd].status == CLOSE) ++n; return (n); *************** *** 207,213 **** if ((getMaxFD() - Biggest_FD) > n) return 1; else { ! for (fd = (getMaxFD() - 1); ((fd > 0) && (n_free_fd < n)); --fd) { if (fd_stat_tab[fd].status == CLOSE) { ++n_free_fd; } --- 208,214 ---- if ((getMaxFD() - Biggest_FD) > n) return 1; else { ! for (fd = maxfd - 1; ((fd > 0) && (n_free_fd < n)); --fd) { if (fd_stat_tab[fd].status == CLOSE) { ++n_free_fd; } diff -cr squid-1.0.beta3/src/fdstat.h squid-1.0.beta4/src/fdstat.h *** squid-1.0.beta3/src/fdstat.h Tue Apr 16 13:30:00 1996 --- squid-1.0.beta4/src/fdstat.h Wed Apr 24 20:43:55 1996 *************** *** 1,4 **** ! /* $Id: fdstat.h,v 1.3 1996/04/16 20:30:00 wessels Exp $ */ #ifndef FDSTAT_H #define FDSTAT_H --- 1,4 ---- ! /* $Id: fdstat.h,v 1.3.2.1 1996/04/25 03:43:55 wessels Exp $ */ #ifndef FDSTAT_H #define FDSTAT_H *************** *** 6,12 **** #define PREOPEN_FD 3 /* number of preopened fd when process start */ typedef enum { ! LOG, File, Socket, Pipe, Unknown } File_Desc_Type; extern File_Desc_Type fdstat_type _PARAMS((int fd)); --- 6,16 ---- #define PREOPEN_FD 3 /* number of preopened fd when process start */ typedef enum { ! LOG, ! File, ! Socket, ! Pipe, ! Unknown } File_Desc_Type; extern File_Desc_Type fdstat_type _PARAMS((int fd)); diff -cr squid-1.0.beta3/src/ftp.c squid-1.0.beta4/src/ftp.c *** squid-1.0.beta3/src/ftp.c Tue Apr 23 22:52:49 1996 --- squid-1.0.beta4/src/ftp.c Thu Apr 25 15:11:29 1996 *************** *** 1,4 **** ! /* $Id: ftp.c,v 1.37.2.4 1996/04/24 05:52:49 wessels Exp $ */ /* * DEBUG: Section 9 ftp: FTP --- 1,4 ---- ! /* $Id: ftp.c,v 1.37.2.8 1996/04/25 22:11:29 wessels Exp $ */ /* * DEBUG: Section 9 ftp: FTP *************** *** 14,19 **** --- 14,20 ---- static char ftpASCII[] = "A"; static char ftpBinary[] = "I"; static char localhost[] = "localhost"; + static int ftpget_server_pipe = -1; typedef struct _Ftpdata { StoreEntry *entry; *************** *** 628,633 **** --- 629,665 ---- return COMM_OK; } + static void ftpServerClosed(fd, nodata) + int fd; + void *nodata; + { + static time_t last_restart = 0; + comm_close(fd); + if (squid_curtime - last_restart < 2) { + debug(9, 0, "ftpget server failing too rapidly\n"); + debug(9, 0, "WARNING: FTP access is disabled!\n"); + return; + } + last_restart = squid_curtime; + debug(9, 1, "Restarting ftpget server...\n"); + (void) ftpInitialize(); + } + + void ftpServerClose() + { + if (ftpget_server_pipe < 0) + return; + + comm_set_select_handler(ftpget_server_pipe, + COMM_SELECT_EXCEPT, + (PF) NULL, + (void *) NULL); + fdstat_close(ftpget_server_pipe); + close(ftpget_server_pipe); + ftpget_server_pipe = -1; + } + + int ftpInitialize() { int pid; *************** *** 649,654 **** --- 681,692 ---- fdstat_open(p[1], Pipe); fd_note(p[1], "ftpget -S"); fcntl(p[1], F_SETFD, 1); /* set close-on-exec */ + /* if ftpget -S goes away, this handler should get called */ + comm_set_select_handler(p[1], + COMM_SELECT_EXCEPT, + (PF) ftpServerClosed, + (void *) NULL); + ftpget_server_pipe = p[1]; return 0; } /* child */ diff -cr squid-1.0.beta3/src/ftpget.c squid-1.0.beta4/src/ftpget.c *** squid-1.0.beta3/src/ftpget.c Mon Apr 22 21:16:39 1996 --- squid-1.0.beta4/src/ftpget.c Thu Apr 25 09:37:31 1996 *************** *** 1,4 **** ! /* $Id: ftpget.c,v 1.23.2.5 1996/04/23 04:16:39 wessels Exp $ */ /* * NOTES --- 1,4 ---- ! /* $Id: ftpget.c,v 1.23.2.9 1996/04/25 16:37:31 wessels Exp $ */ /* * NOTES *************** *** 244,249 **** --- 244,250 ---- list_t *cmd_msg = NULL; static int process_request _PARAMS((request_t *)); + static int write_with_timeout _PARAMS((int fd, char *buf, int len)); static char *state_str[] = { *************** *** 380,386 **** fprintf(fp, "MIME-Version: 1.0\r\n"); fprintf(fp, "Server: Squid %s\r\n", SQUID_VERSION); fprintf(fp, "Content-Type: text/html\r\n"); ! fprintf(fp, "Content-Length: %d\r\n", (int) strlen(htmlbuf)); fprintf(fp, "\r\n"); } fputs(htmlbuf, fp); --- 381,387 ---- fprintf(fp, "MIME-Version: 1.0\r\n"); fprintf(fp, "Server: Squid %s\r\n", SQUID_VERSION); fprintf(fp, "Content-Type: text/html\r\n"); ! /*fprintf(fp, "Content-Length: %d\r\n", (int) strlen(htmlbuf)); */ fprintf(fp, "\r\n"); } fputs(htmlbuf, fp); *************** *** 399,404 **** --- 400,409 ---- } fputs(html_trailer(), fp); fclose(fp); + if (r->flags & F_HTTPIFY) { + Debug(26, 9, ("Writing Marker to FD %d\n", r->cfd)); + write_with_timeout(r->cfd, MAGIC_MARKER, MAGIC_MARKER_SZ); + } } else if (r->errmsg) { errorlog("%s\n\t\n", r->errmsg, r->url); } *************** *** 442,448 **** if ((pid = waitpid(0, &status, WNOHANG)) > 0) Debug(26, 5, ("sigchld_handler: Ate pid %d\n", pid)); ! #if defined(_SQUID_SYSV_SIGNALS_) signal(sig, sigchld_handler); #endif } --- 447,453 ---- if ((pid = waitpid(0, &status, WNOHANG)) > 0) Debug(26, 5, ("sigchld_handler: Ate pid %d\n", pid)); ! #if RESET_SIGNAL_HANDLER signal(sig, sigchld_handler); #endif } *************** *** 2050,2055 **** --- 2055,2061 ---- ntohs(S.sin_port))); if (bind(sock, (struct sockaddr *) &S, sizeof(S)) < 0) { log_errno2(__FILE__, __LINE__, "bind"); + sleep(5); /* sleep here so that the cache will restart us */ exit(1); } if (listen(sock, 50) < 0) { diff -cr squid-1.0.beta3/src/http.c squid-1.0.beta4/src/http.c *** squid-1.0.beta3/src/http.c Tue Apr 23 22:52:50 1996 --- squid-1.0.beta4/src/http.c Thu Apr 25 15:05:15 1996 *************** *** 1,4 **** ! /* $Id: http.c,v 1.56.2.2 1996/04/24 05:52:50 wessels Exp $ */ /* * DEBUG: Section 11 http: HTTP --- 1,4 ---- ! /* $Id: http.c,v 1.56.2.4 1996/04/25 22:05:15 wessels Exp $ */ /* * DEBUG: Section 11 http: HTTP *************** *** 6,13 **** #include "squid.h" ! #define HTTP_DELETE_GAP (64*1024) ! #define READBUFSIZ 4096 typedef struct _httpdata { StoreEntry *entry; --- 6,13 ---- #include "squid.h" ! #define READBUFSIZ (1<<14) ! #define HTTP_DELETE_GAP (1<<18) typedef struct _httpdata { StoreEntry *entry; *************** *** 237,274 **** StoreEntry *entry = NULL; entry = data->entry; ! if (entry->flag & DELETE_BEHIND) { ! if (storeClientWaiting(entry)) { ! /* check if we want to defer reading */ ! clen = entry->mem_obj->e_current_len; ! off = entry->mem_obj->e_lowest_offset; ! if ((clen - off) > HTTP_DELETE_GAP) { ! debug(11, 3, "httpReadReply: Read deferred for Object: %s\n", ! entry->url); ! debug(11, 3, " Current Gap: %d bytes\n", clen - off); ! /* reschedule, so it will be automatically reactivated ! * when Gap is big enough. */ ! comm_set_select_handler(fd, ! COMM_SELECT_READ, ! (PF) httpReadReply, ! (void *) data); ! /* don't install read timeout until we are below the GAP */ ! comm_set_select_handler_plus_timeout(fd, ! COMM_SELECT_TIMEOUT, ! (PF) NULL, ! (void *) NULL, ! (time_t) 0); ! /* dont try reading again for a while */ ! comm_set_stall(fd, getStallDelay()); ! return; ! } ! } else { ! /* we can terminate connection right now */ ! squid_error_entry(entry, ERR_NO_CLIENTS_BIG_OBJ, NULL); ! comm_close(fd); ! return; ! } } errno = 0; len = read(fd, buf, READBUFSIZ); debug(11, 5, "httpReadReply: FD %d: len %d.\n", fd, len); --- 237,271 ---- StoreEntry *entry = NULL; entry = data->entry; ! if (entry->flag & DELETE_BEHIND && !storeClientWaiting(entry)) { ! /* we can terminate connection right now */ ! squid_error_entry(entry, ERR_NO_CLIENTS_BIG_OBJ, NULL); ! comm_close(fd); ! return; } + /* check if we want to defer reading */ + clen = entry->mem_obj->e_current_len; + off = storeGetLowestReaderOffset(entry); + if ((clen - off) > HTTP_DELETE_GAP) { + debug(11, 3, "httpReadReply: Read deferred for Object: %s\n", + entry->url); + debug(11, 3, " Current Gap: %d bytes\n", clen - off); + /* reschedule, so it will be automatically reactivated + * when Gap is big enough. */ + comm_set_select_handler(fd, + COMM_SELECT_READ, + (PF) httpReadReply, + (void *) data); + /* don't install read timeout until we are below the GAP */ + comm_set_select_handler_plus_timeout(fd, + COMM_SELECT_TIMEOUT, + (PF) NULL, + (void *) NULL, + (time_t) 0); + /* dont try reading again for a while */ + comm_set_stall(fd, getStallDelay()); + return; + } errno = 0; len = read(fd, buf, READBUFSIZ); debug(11, 5, "httpReadReply: FD %d: len %d.\n", fd, len); *************** *** 310,317 **** comm_set_select_handler_plus_timeout(fd, COMM_SELECT_TIMEOUT, (PF) httpReadReplyTimeout, ! (void *) data, ! getReadTimeout()); } else if (entry->flag & CLIENT_ABORT_REQUEST) { /* append the last bit of info we get */ storeAppend(entry, buf, len); --- 307,313 ---- comm_set_select_handler_plus_timeout(fd, COMM_SELECT_TIMEOUT, (PF) httpReadReplyTimeout, ! (void *) data, getReadTimeout()); } else if (entry->flag & CLIENT_ABORT_REQUEST) { /* append the last bit of info we get */ storeAppend(entry, buf, len); *************** *** 385,391 **** char *t = NULL; char *post_buf = NULL; static char *crlf = "\r\n"; ! static char *VIA_PROXY_TEXT = "via Sqiud Cache version"; int len = 0; int buflen; int cfd = -1; --- 381,387 ---- char *t = NULL; char *post_buf = NULL; static char *crlf = "\r\n"; ! static char *VIA_PROXY_TEXT = "via Squid Cache version"; int len = 0; int buflen; int cfd = -1; diff -cr squid-1.0.beta3/src/icp.c squid-1.0.beta4/src/icp.c *** squid-1.0.beta3/src/icp.c Wed Apr 24 07:46:27 1996 --- squid-1.0.beta4/src/icp.c Thu Apr 25 16:25:04 1996 *************** *** 1,6 **** ! /* $Id: icp.c,v 1.61.2.11 1996/04/24 14:46:27 wessels Exp $ */ /* * DEBUG: Section 12 icp: --- 1,6 ---- ! /* $Id: icp.c,v 1.61.2.15 1996/04/25 23:25:04 wessels Exp $ */ /* * DEBUG: Section 12 icp: *************** *** 23,28 **** --- 23,29 ---- "UDP_HIT", "UDP_MISS", "UDP_DENIED", + "UDP_INVALID", "ERR_READ_TIMEOUT", "ERR_LIFETIME_EXP", "ERR_NO_CLIENTS_BIG_OBJ", *************** *** 90,99 **** { if (icpState->ptr_to_4k_page && icpState->buf) fatal_dump("icpFreeBufOrPage: Shouldn't have both a 4k ptr and a string"); ! if (icpState->ptr_to_4k_page) put_free_4k_page(icpState->ptr_to_4k_page); ! else safe_free(icpState->buf); icpState->ptr_to_4k_page = icpState->buf = NULL; } --- 91,101 ---- { if (icpState->ptr_to_4k_page && icpState->buf) fatal_dump("icpFreeBufOrPage: Shouldn't have both a 4k ptr and a string"); ! if (icpState->ptr_to_4k_page) { put_free_4k_page(icpState->ptr_to_4k_page); ! } else { safe_free(icpState->buf); + } icpState->ptr_to_4k_page = icpState->buf = NULL; } *************** *** 579,588 **** } else if (state->offset < entry->mem_obj->e_current_len) { /* More data available locally; write it now */ icpSendMoreData(fd, state); ! } else ! /* We're finished case */ ! if (state->offset == entry->object_len && entry->store_status != STORE_PENDING) { CacheInfo->proto_touchobject(CacheInfo, CacheInfo->proto_id(entry->url), state->offset); --- 581,589 ---- } else if (state->offset < entry->mem_obj->e_current_len) { /* More data available locally; write it now */ icpSendMoreData(fd, state); ! } else if (state->offset == entry->object_len && entry->store_status != STORE_PENDING) { + /* We're finished case */ CacheInfo->proto_touchobject(CacheInfo, CacheInfo->proto_id(entry->url), state->offset); *************** *** 596,601 **** --- 597,603 ---- } } + #ifdef OLD_CODE int icpDoQuery(fd, state) int fd; icpStateData *state; *************** *** 608,613 **** --- 610,616 ---- state); return COMM_OK; } + #endif /* * Below, we check whether the object is a hit or a miss. If it's a hit, *************** *** 656,668 **** if (!storeEntryValidToSend(entry)) { storeRelease(entry); usm->log_type = LOG_TCP_EXPIRED; - } else if (BIT_TEST(usm->flags, REQ_NOCACHE)) { - storeRelease(entry); - usm->log_type = LOG_TCP_USER_REFRESH; } else if (BIT_TEST(usm->flags, REQ_IMS)) { /* no storeRelease() here because this request will always * start private (IMS clears HIERARCHICAL) */ usm->log_type = LOG_TCP_IFMODSINCE; } else if ((lock = storeLockObject(entry)) < 0) { storeRelease(entry); usm->log_type = LOG_TCP_SWAPIN_FAIL; --- 659,672 ---- if (!storeEntryValidToSend(entry)) { storeRelease(entry); usm->log_type = LOG_TCP_EXPIRED; } else if (BIT_TEST(usm->flags, REQ_IMS)) { /* no storeRelease() here because this request will always * start private (IMS clears HIERARCHICAL) */ + /* check IMS before nocache so IMS+NOCACHE won't eject valid object */ usm->log_type = LOG_TCP_IFMODSINCE; + } else if (BIT_TEST(usm->flags, REQ_NOCACHE)) { + storeRelease(entry); + usm->log_type = LOG_TCP_USER_REFRESH; } else if ((lock = storeLockObject(entry)) < 0) { storeRelease(entry); usm->log_type = LOG_TCP_SWAPIN_FAIL; *************** *** 869,874 **** --- 873,880 ---- StoreEntry *entry = NULL; char *url = NULL; char *key = NULL; + request_t *icp_request = NULL; + int allow = 0; from_len = sizeof(from); memset(&from, 0, from_len); *************** *** 906,918 **** case ICP_OP_QUERY: /* We have a valid packet */ url = buf + sizeof(header) + sizeof(u_num32); ! if (!aclCheck(ICPAccessList, ! from.sin_addr, ! METHOD_GET, ! PROTO_NONE, /* XXX need work here */ ! NULL, /* host */ ! 0, /* port */ ! NULL)) { /* request */ debug(12, 2, "icpHandleUdp: Access Denied for %s.\n", inet_ntoa(from.sin_addr)); CacheInfo->log_append(CacheInfo, /* UDP_DENIED */ --- 912,938 ---- case ICP_OP_QUERY: /* We have a valid packet */ url = buf + sizeof(header) + sizeof(u_num32); ! if ((icp_request = urlParse(METHOD_GET, url)) == NULL) { ! debug(12, 2, "icpHandleUdp: Invalid URL '%s'.\n", url); ! CacheInfo->log_append(CacheInfo, /* UDP_INVALID */ ! url, ! inet_ntoa(from.sin_addr), ! len, ! log_tags[LOG_UDP_INVALID], ! IcpOpcodeStr[header.opcode], ! 0, ! 0); ! break; ! } ! allow = aclCheck(ICPAccessList, ! from.sin_addr, ! icp_request->method, ! icp_request->protocol, ! icp_request->host, ! icp_request->port, ! icp_request->urlpath); ! safe_free(icp_request); ! if (!allow) { debug(12, 2, "icpHandleUdp: Access Denied for %s.\n", inet_ntoa(from.sin_addr)); CacheInfo->log_append(CacheInfo, /* UDP_DENIED */ *************** *** 975,984 **** IcpOpcodeStr[header.opcode], inet_ntoa(from.sin_addr), url); ! if (neighbors_do_private_keys && header.reqnum) key = storeGeneratePrivateKey(url, METHOD_GET, header.reqnum); ! else key = storeGeneratePublicKey(url, METHOD_GET); debug(12, 3, "icpHandleUdp: Looking for key '%s'\n", key); if ((entry = storeGet(key)) == NULL) { debug(12, 3, "icpHandleUdp: Ignoring %s for NULL Entry.\n", --- 995,1005 ---- IcpOpcodeStr[header.opcode], inet_ntoa(from.sin_addr), url); ! if (neighbors_do_private_keys && header.reqnum) { key = storeGeneratePrivateKey(url, METHOD_GET, header.reqnum); ! } else { key = storeGeneratePublicKey(url, METHOD_GET); + } debug(12, 3, "icpHandleUdp: Looking for key '%s'\n", key); if ((entry = storeGet(key)) == NULL) { debug(12, 3, "icpHandleUdp: Ignoring %s for NULL Entry.\n", *************** *** 1055,1061 **** char *method = NULL; char *request = NULL; char *req_hdr = NULL; ! char *http_ver = NULL; char *token = NULL; char *t = NULL; char *ad = NULL; --- 1076,1082 ---- char *method = NULL; char *request = NULL; char *req_hdr = NULL; ! static char http_ver[32]; char *token = NULL; char *t = NULL; char *ad = NULL; *************** *** 1064,1069 **** --- 1085,1091 ---- int content_length; int req_hdr_sz; int post_sz; + int len; /* Use xmalloc/memcpy instead of xstrdup because inbuf might * contain NULL bytes; especially for POST data */ *************** *** 1086,1120 **** BIT_SET(icpState->flags, REQ_HTML); ! if ((request = strtok(NULL, "\n\r\t ")) == NULL) { debug(12, 1, "parseHttpRequest: Missing URL\n"); xfree(inbuf); return -1; } debug(12, 5, "parseHttpRequest: Request is '%s'\n", request); - if ((http_ver = strtok(NULL, "\n\r\t ")) == NULL) - debug(12, 3, "parseHttpRequest: Missing HTTP identifier\n"); - else - debug(12, 5, "parseHttpRequest: HTTP version is '%s'\n", http_ver); ! if ((token = (char *) strtok(NULL, ""))) { ! req_hdr = token; ! while (*req_hdr == '\r' || *req_hdr == '\n') ! req_hdr++; ! req_hdr_sz = icpState->offset - (req_hdr - inbuf); ! icpState->request_hdr = (char *) xmalloc(req_hdr_sz + 1); ! memcpy(icpState->request_hdr, req_hdr, req_hdr_sz); ! *(icpState->request_hdr + req_hdr_sz) = '\0'; ! } else if (icpState->method == METHOD_POST) { ! debug(12, 3, "parseHttpRequest: Partial POST request\n"); ! xfree(inbuf); ! return 0; /* reschedule us after next read */ } ! if (icpState->request_hdr) debug(12, 5, "parseHttpRequest: Request Header is\n---\n%s\n---\n", icpState->request_hdr); ! else debug(12, 5, "parseHttpRequest: No Request Header present\n"); if (icpState->method == METHOD_POST) { /* Expect Content-Length: and POST data after the headers */ --- 1108,1143 ---- BIT_SET(icpState->flags, REQ_HTML); ! if ((request = strtok(NULL, "\r\n\t ")) == NULL) { debug(12, 1, "parseHttpRequest: Missing URL\n"); xfree(inbuf); return -1; } debug(12, 5, "parseHttpRequest: Request is '%s'\n", request); ! token = strtok(NULL, ""); ! for (t = token; t && *t && *t != '\n' && *t != '\r'; t++); ! if (t == NULL || *t == '\0' || t == token) { ! debug(12, 3, "parseHttpRequest: Missing HTTP identifier\n"); ! return -1; } ! len = (int) (t - token); ! memset(http_ver, '\0', 32); ! strncpy(http_ver, token, len < 31 ? len : 31); ! debug(12, 5, "parseHttpRequest: HTTP version is '%s'\n", http_ver); ! ! req_hdr = t; ! req_hdr_sz = icpState->offset - (req_hdr - inbuf); ! icpState->request_hdr = (char *) xmalloc(req_hdr_sz + 1); ! memcpy(icpState->request_hdr, req_hdr, req_hdr_sz); ! *(icpState->request_hdr + req_hdr_sz) = '\0'; ! ! if (icpState->request_hdr) { debug(12, 5, "parseHttpRequest: Request Header is\n---\n%s\n---\n", icpState->request_hdr); ! } else { debug(12, 5, "parseHttpRequest: No Request Header present\n"); + } if (icpState->method == METHOD_POST) { /* Expect Content-Length: and POST data after the headers */ *************** *** 1140,1145 **** --- 1163,1171 ---- xfree(inbuf); return 0; } + } else if (!strstr(req_hdr, "\r\n\r\n") && !strstr(req_hdr, "\n\n")) { + xfree(inbuf); + return 0; /* not a complete request */ } /* Assign icpState->url */ if ((t = strchr(request, '\n'))) /* remove NL */ diff -cr squid-1.0.beta3/src/icp.h squid-1.0.beta4/src/icp.h *** squid-1.0.beta3/src/icp.h Tue Apr 23 22:52:51 1996 --- squid-1.0.beta4/src/icp.h Wed Apr 24 20:45:56 1996 *************** *** 1,4 **** ! /* $Id: icp.h,v 1.13.2.2 1996/04/24 05:52:51 wessels Exp $ */ #ifndef ICP_H #define ICP_H --- 1,4 ---- ! /* $Id: icp.h,v 1.13.2.3 1996/04/25 03:45:56 wessels Exp $ */ #ifndef ICP_H #define ICP_H *************** *** 15,35 **** LOG_UDP_HIT, /* 8 */ LOG_UDP_MISS, /* 9 */ LOG_UDP_DENIED, /* 10 */ ! ERR_READ_TIMEOUT, /* 11 */ ! ERR_LIFETIME_EXP, /* 12 */ ! ERR_NO_CLIENTS_BIG_OBJ, /* 13 */ ! ERR_READ_ERROR, /* 14 */ ! ERR_CLIENT_ABORT, /* 15 */ ! ERR_CONNECT_FAIL, /* 16 */ ! ERR_INVALID_REQ, /* 17 */ ! ERR_INVALID_URL, /* 18 */ ! ERR_NO_FDS, /* 19 */ ! ERR_DNS_FAIL, /* 20 */ ! ERR_NOT_IMPLEMENTED, /* 21 */ ! ERR_CANNOT_FETCH, /* 22 */ ! ERR_NO_RELAY, /* 23 */ ! ERR_DISK_IO, /* 24 */ ! ERR_ZERO_SIZE_OBJECT /* 25 */ } log_type; #define ERR_MIN ERR_READ_TIMEOUT --- 15,36 ---- LOG_UDP_HIT, /* 8 */ LOG_UDP_MISS, /* 9 */ LOG_UDP_DENIED, /* 10 */ ! LOG_UDP_INVALID, /* 11 */ ! ERR_READ_TIMEOUT, /* 12 */ ! ERR_LIFETIME_EXP, /* 13 */ ! ERR_NO_CLIENTS_BIG_OBJ, /* 14 */ ! ERR_READ_ERROR, /* 15 */ ! ERR_CLIENT_ABORT, /* 16 */ ! ERR_CONNECT_FAIL, /* 17 */ ! ERR_INVALID_REQ, /* 18 */ ! ERR_INVALID_URL, /* 19 */ ! ERR_NO_FDS, /* 20 */ ! ERR_DNS_FAIL, /* 21 */ ! ERR_NOT_IMPLEMENTED, /* 22 */ ! ERR_CANNOT_FETCH, /* 23 */ ! ERR_NO_RELAY, /* 24 */ ! ERR_DISK_IO, /* 25 */ ! ERR_ZERO_SIZE_OBJECT /* 26 */ } log_type; #define ERR_MIN ERR_READ_TIMEOUT diff -cr squid-1.0.beta3/src/ipcache.c squid-1.0.beta4/src/ipcache.c *** squid-1.0.beta3/src/ipcache.c Tue Apr 23 12:54:38 1996 --- squid-1.0.beta4/src/ipcache.c Thu Apr 25 09:34:59 1996 *************** *** 1,4 **** ! /* $Id: ipcache.c,v 1.26.2.1 1996/04/23 19:54:38 wessels Exp $ */ /* * DEBUG: Section 14 ipcache: IP Cache --- 1,4 ---- ! /* $Id: ipcache.c,v 1.26.2.2 1996/04/25 16:34:59 wessels Exp $ */ /* * DEBUG: Section 14 ipcache: IP Cache *************** *** 169,175 **** } execlp(command, "(dnsserver)", "-p", socketname, NULL); ! perror(command); _exit(1); return (0); /* NOTREACHED */ } --- 169,175 ---- } execlp(command, "(dnsserver)", "-p", socketname, NULL); ! debug(14, 0, "ipcache_create_dnsserver: %s: %s\n", command, xstrerror()); _exit(1); return (0); /* NOTREACHED */ } diff -cr squid-1.0.beta3/src/main.c squid-1.0.beta4/src/main.c *** squid-1.0.beta3/src/main.c Wed Apr 24 08:05:07 1996 --- squid-1.0.beta4/src/main.c Thu Apr 25 15:06:54 1996 *************** *** 1,4 **** ! /* $Id: main.c,v 1.44.4.6 1996/04/24 15:05:07 wessels Exp $ */ /* DEBUG: Section 1 main: startup and main loop */ --- 1,4 ---- ! /* $Id: main.c,v 1.44.4.10 1996/04/25 22:06:54 wessels Exp $ */ /* DEBUG: Section 1 main: startup and main loop */ *************** *** 185,190 **** --- 185,191 ---- neighbors_init(); ipcacheOpenServers(); serverConnectionsOpen(); + (void) ftpInitialize(); if (theUdpConnection >= 0 && (!httpd_accel_mode || getAccelWithProxy())) neighbors_open(theUdpConnection); debug(1, 0, "Ready to serve requests.\n"); *************** *** 215,220 **** --- 216,222 ---- fd_note(fileno(debug_log), getCacheLogFile()); debug(1, 0, "Starting Squid Cache (version %s)...\n", version_string); + debug(1, 1, "With %d file descriptors available\n", getMaxFD()); if (first_time) { disk_init(); /* disk_init must go before ipcache_init() */ *************** *** 222,228 **** } ipcache_init(); neighbors_init(); ! ftpInitialize(); #if defined(MALLOC_DBG) malloc_debug(0, malloc_debug_level); --- 224,230 ---- } ipcache_init(); neighbors_init(); ! (void) ftpInitialize(); #if defined(MALLOC_DBG) malloc_debug(0, malloc_debug_level); *************** *** 332,338 **** loop_delay = (time_t) 0; switch (comm_select(loop_delay, next_cleaning)) { case COMM_OK: ! /* do nothing */ break; case COMM_ERROR: errcount++; --- 334,340 ---- loop_delay = (time_t) 0; switch (comm_select(loop_delay, next_cleaning)) { case COMM_OK: ! errcount = 0; /* reset if successful */ break; case COMM_ERROR: errcount++; diff -cr squid-1.0.beta3/src/squid.h squid-1.0.beta4/src/squid.h *** squid-1.0.beta3/src/squid.h Sat Apr 20 12:56:41 1996 --- squid-1.0.beta4/src/squid.h Thu Apr 25 15:06:35 1996 *************** *** 1,8 **** ! /* $Id: squid.h,v 1.19.4.1 1996/04/20 19:56:41 wessels Exp $ */ #include "config.h" #include "autoconf.h" #include #include --- 1,12 ---- ! /* $Id: squid.h,v 1.19.4.3 1996/04/25 22:06:35 wessels Exp $ */ #include "config.h" #include "autoconf.h" + + #if SQUID_FD_SETSIZE > 256 + #define FD_SETSIZE SQUID_FD_SETSIZE + #endif #include #include diff -cr squid-1.0.beta3/src/store.c squid-1.0.beta4/src/store.c *** squid-1.0.beta3/src/store.c Tue Apr 23 22:52:54 1996 --- squid-1.0.beta4/src/store.c Thu Apr 25 15:05:16 1996 *************** *** 1,5 **** ! /* $Id: store.c,v 1.61.4.7 1996/04/24 05:52:54 wessels Exp $ */ /* * DEBUG: Section 20 store --- 1,5 ---- ! /* $Id: store.c,v 1.61.4.8 1996/04/25 22:05:16 wessels Exp $ */ /* * DEBUG: Section 20 store *************** *** 796,842 **** return freed; } /* Call to delete behind upto "target lowest offset" ! * also, it update e_lowest_offset. ! */ void storeDeleteBehind(e) StoreEntry *e; { int free_up_to; int target_offset; - int n_client = 0; - int i; debug(20, 3, "storeDeleteBehind: Object: %s\n", e->key); ! debug(20, 3, "storeDeleteBehind:\tOriginal Lowest Offset: %d \n", e->mem_obj->e_lowest_offset); ! free_up_to = e->mem_obj->e_lowest_offset; ! target_offset = 0; ! for (i = 0; i < e->mem_obj->client_list_size; ++i) { ! if (e->mem_obj->client_list[i] == NULL) ! continue; ! if (((e->mem_obj->client_list[i]->last_offset < target_offset) || ! (target_offset == 0))) { ! n_client++; ! target_offset = e->mem_obj->client_list[i]->last_offset; ! } ! } ! ! if (n_client == 0) { ! debug(20, 3, "storeDeleteBehind:\tThere is no client in the list.\n"); ! debug(20, 3, "\t\tTry to delete as fast as possible.\n"); ! target_offset = e->mem_obj->e_current_len; ! } ! debug(20, 3, "storeDeleteBehind:\tThe target offset is : %d\n", target_offset); if (target_offset) { ! free_up_to = (int) e->mem_obj->data->mem_free_data_upto(e->mem_obj->data, ! target_offset); ! debug(20, 3, " Object is freed upto : %d\n", free_up_to); ! store_mem_size -= free_up_to - e->mem_obj->e_lowest_offset; } ! debug(20, 3, "storeDeleteBehind:\tOutgoing Lowest Offset : %d\n", free_up_to); ! e->mem_obj->e_lowest_offset = free_up_to; } /* Call handlers waiting for data to be appended to E. */ --- 796,841 ---- return freed; } + int storeGetLowestReaderOffset(entry) + StoreEntry *entry; + { + MemObject *m = entry->mem_obj; + int lowest = m->e_current_len; + int i; + for (i = 0; i < m->client_list_size; i++) { + if (m->client_list[i] == NULL) + continue; + if (m->client_list[i]->last_offset < lowest) + lowest = m->client_list[i]->last_offset; + } + return lowest; + } + + /* Call to delete behind upto "target lowest offset" ! * also, update e_lowest_offset */ void storeDeleteBehind(e) StoreEntry *e; { + MemObject *m = e->mem_obj; int free_up_to; int target_offset; debug(20, 3, "storeDeleteBehind: Object: %s\n", e->key); ! debug(20, 3, "storeDeleteBehind: Original Lowest Offset: %d\n", ! m->e_lowest_offset); ! free_up_to = m->e_lowest_offset; ! target_offset = storeGetLowestReaderOffset(e); ! debug(20, 3, "storeDeleteBehind: target offset: %d\n", target_offset); if (target_offset) { ! free_up_to = (int) m->data->mem_free_data_upto(m->data, target_offset); ! debug(20, 3, "--> Object is freed upto : %d\n", free_up_to); ! store_mem_size -= free_up_to - m->e_lowest_offset; } ! debug(20, 3, "storeDeleteBehind: New lowest offset: %d\n", free_up_to); ! m->e_lowest_offset = free_up_to; } /* Call handlers waiting for data to be appended to E. */ diff -cr squid-1.0.beta3/src/store.h squid-1.0.beta4/src/store.h *** squid-1.0.beta3/src/store.h Tue Apr 23 22:52:54 1996 --- squid-1.0.beta4/src/store.h Thu Apr 25 15:06:13 1996 *************** *** 1,5 **** ! /* $Id: store.h,v 1.26.2.2 1996/04/24 05:52:54 wessels Exp $ */ #ifndef _STORE_H_ #define _STORE_H_ --- 1,5 ---- ! /* $Id: store.h,v 1.26.2.3 1996/04/25 22:06:13 wessels Exp $ */ #ifndef _STORE_H_ #define _STORE_H_ *************** *** 204,208 **** --- 204,209 ---- extern void storeReleaseRequest _PARAMS((StoreEntry *)); extern void storeRotateLog _PARAMS((void)); extern unsigned int getKeyCounter _PARAMS((void)); + extern int storeGetLowestReaderOffset _PARAMS((StoreEntry *)); #endif diff -cr squid-1.0.beta3/src/tools.c squid-1.0.beta4/src/tools.c *** squid-1.0.beta3/src/tools.c Tue Apr 23 16:22:57 1996 --- squid-1.0.beta4/src/tools.c Thu Apr 25 15:06:07 1996 *************** *** 1,5 **** ! /* $Id: tools.c,v 1.40.2.8 1996/04/23 23:22:57 wessels Exp $ */ /* * DEBUG: Section 21 tools --- 1,5 ---- ! /* $Id: tools.c,v 1.40.2.11 1996/04/25 22:06:07 wessels Exp $ */ /* * DEBUG: Section 21 tools *************** *** 146,152 **** neighbors_rotate_log(); stat_rotate_log(); _db_rotate_log(); ! #if defined(_SQUID_SYSV_SIGNALS_) signal(sig, rotate_logs); #endif } --- 146,152 ---- neighbors_rotate_log(); stat_rotate_log(); _db_rotate_log(); ! #if RESET_SIGNAL_HANDLER signal(sig, rotate_logs); #endif } *************** *** 175,180 **** --- 175,181 ---- ntcpconn + nudpconn); serverConnectionsClose(); ipcacheShutdownServers(); + ftpServerClose(); for (i = fdstat_biggest_fd(); i >= 0; i--) { f = &fd_table[i]; if (f->read_handler || f->write_handler || f->except_handler) *************** *** 241,251 **** if ((pid = waitpid(-1, &status, WNOHANG)) > 0) debug(21, 3, "sig_child: Ate pid %d\n", pid); ! #if defined(_SQUID_SYSV_SIGNALS_) signal(sig, sig_child); #endif } /* * getMaxFD - returns the file descriptor table size */ --- 242,253 ---- if ((pid = waitpid(-1, &status, WNOHANG)) > 0) debug(21, 3, "sig_child: Ate pid %d\n", pid); ! #if RESET_SIGNAL_HANDLER signal(sig, sig_child); #endif } + #ifdef OLD_CODE /* * getMaxFD - returns the file descriptor table size */ *************** *** 271,276 **** --- 273,284 ---- } return (i); } + #else + int getMaxFD() + { + return FD_SETSIZE; + } + #endif char *getMyHostname() { *************** *** 405,428 **** struct rlimit rl; #if defined(RLIMIT_NOFILE) if (getrlimit(RLIMIT_NOFILE, &rl) < 0) { ! perror("getrlimit: RLIMIT_NOFILE"); } else { ! rl.rlim_cur = rl.rlim_max; /* set it to the max */ if (setrlimit(RLIMIT_NOFILE, &rl) < 0) { ! perror("setrlimit: RLIMIT_NOFILE"); } } #elif defined(RLIMIT_OFILE) if (getrlimit(RLIMIT_OFILE, &rl) < 0) { ! perror("getrlimit: RLIMIT_OFILE"); } else { ! rl.rlim_cur = rl.rlim_max; /* set it to the max */ if (setrlimit(RLIMIT_OFILE, &rl) < 0) { ! perror("setrlimit: RLIMIT_OFILE"); } } #endif - debug(21, 1, "setMaxFD: Using %d file descriptors\n", rl.rlim_max); #else /* HAVE_SETRLIMIT */ debug(21, 1, "setMaxFD: Cannot increase: setrlimit() not supported on this system"); #endif --- 413,437 ---- struct rlimit rl; #if defined(RLIMIT_NOFILE) if (getrlimit(RLIMIT_NOFILE, &rl) < 0) { ! debug(21, 0, "setrlimit: RLIMIT_NOFILE: %s", xstrerror()); } else { ! rl.rlim_cur = FD_SETSIZE; if (setrlimit(RLIMIT_NOFILE, &rl) < 0) { ! sprintf(tmp_error_buf, "setrlimit: RLIMIT_NOFILE: %s", xstrerror()); ! fatal_dump(tmp_error_buf); } } #elif defined(RLIMIT_OFILE) if (getrlimit(RLIMIT_OFILE, &rl) < 0) { ! debug(21, 0, "setrlimit: RLIMIT_NOFILE: %s", xstrerror()); } else { ! rl.rlim_cur = FD_SETSIZE; if (setrlimit(RLIMIT_OFILE, &rl) < 0) { ! sprintf(tmp_error_buf, "setrlimit: RLIMIT_OFILE: %s", xstrerror()); ! fatal_dump(tmp_error_buf); } } #endif #else /* HAVE_SETRLIMIT */ debug(21, 1, "setMaxFD: Cannot increase: setrlimit() not supported on this system"); #endif *************** *** 444,449 **** --- 453,459 ---- debug(21, 1, "reconfigure: SIGHUP received.\n"); serverConnectionsClose(); ipcacheShutdownServers(); + ftpServerClose(); reread_pending = 1; for (i = fdstat_biggest_fd(); i >= 0; i--) { f = &fd_table[i]; *************** *** 451,457 **** if (fdstatGetType(i) == Socket) comm_set_fd_lifetime(i, lft); } ! #if defined(_SQUID_SYSV_SIGNALS_) signal(sig, reconfigure); #endif } --- 461,467 ---- if (fdstatGetType(i) == Socket) comm_set_fd_lifetime(i, lft); } ! #if RESET_SIGNAL_HANDLER signal(sig, reconfigure); #endif }