You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2013/03/31 03:14:20 UTC

[01/51] TS-1748: Add jtest to the build

Updated Branches:
  refs/heads/3.3.x 8f6cbad67 -> bc1b9d351


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e8ad2978/tools/jtest/jtest.cc
----------------------------------------------------------------------
diff --git a/tools/jtest/jtest.cc b/tools/jtest/jtest.cc
index da7236a..d7e5408 100644
--- a/tools/jtest/jtest.cc
+++ b/tools/jtest/jtest.cc
@@ -54,9 +54,6 @@
 
 typedef int64_t ink_hrtime;
 
-#define bool int
-#define false 0
-#define true 1
 #define SIZE(x) (sizeof(x)/sizeof((x)[0]))
 
 /*
@@ -115,6 +112,10 @@ extern "C" int gethostname(char *name, int namelen);
 #define MAX_DEFERED_URLS      10000
 #define DEFERED_URLS_BLOCK    2000
 
+static const char * hexdigits = "0123456789ABCDEFabcdef";
+static const char * dontunescapify = "#;/?+=&:@%";
+static const char * dontescapify = "#;/?+=&:@~.-_%";
+
 enum FTP_MODE {
   FTP_NULL,
   FTP_PORT,
@@ -126,13 +127,16 @@ typedef int (*poll_cb)(int);
 struct ArgumentDescription;
 typedef void ArgumentFunction(
   ArgumentDescription * argument_descriptions, int n_argument_descriptions,
-  char * arg);
+  const char * arg);
+
+static void jtest_usage(ArgumentDescription * argument_descriptions, 
+                 int n_argument_descriptions, const char * arg);
 
 static int read_request(int sock);
 static int write_request(int sock);
 static int make_client (unsigned int addr, int port);
 static void make_bfc_client (unsigned int addr, int port);
-static int make_url_client(char * url,char * base_url = 0, bool seen = false,
+static int make_url_client(const char * url,const char * base_url = 0, bool seen = false,
                            bool unthrottled = false);
 static int write_ftp_response(int sock);
 static void interval_report();
@@ -231,7 +235,6 @@ uint64_t total_server_response_header_bytes = 0;
 uint64_t total_proxy_response_body_bytes = 0;
 uint64_t total_proxy_response_header_bytes = 0;
 ink_hrtime now = 0, start_time = 0;
-ArgumentFunction jtest_usage;
 int extra_headers = 0;
 int alternates = 0;
 int abort_retry_speed = 0;
@@ -248,12 +251,12 @@ double zipf = 0.0;
 int zipf_bucket_size = 1;
 
 struct ArgumentDescription {
-  char * name;
+  const char * name;
   char   key;
-  char * description;
-  char * type;
-  void * location;
-  char * env;
+  const char * description;
+  const char * type;
+  const void * location;
+  const char * env;
   ArgumentFunction * pfn;       
 };
 
@@ -532,4182 +535,7 @@ class           ParseRules
                         ParseRules & operator = (const ParseRules &);
 };
 
-extern const unsigned int parseRulesCType[];
-extern const char parseRulesCTypeToUpper[];
-extern const char parseRulesCTypeToLower[];
-
-inline int ParseRules::is_char(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 0)) ? (1) : (0));
-}
-inline int ParseRules::is_upalpha(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 1)) ? (1) : (0));
-}
-inline int ParseRules::is_loalpha(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 2)) ? (1) : (0));
-}
-inline int ParseRules::is_alpha(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 3)) ? (1) : (0));
-}
-inline int ParseRules::is_digit(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 4)) ? (1) : (0));
-}
-inline int ParseRules::is_alnum(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 26)) ? (1) : (0));
-}
-inline int ParseRules::is_ctl(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 5)) ? (1) : (0));
-}
-inline int ParseRules::is_ws(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 6)) ? (1) : (0));
-}
-inline int ParseRules::is_hex(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 7)) ? (1) : (0));
-}
-inline int ParseRules::is_cr(char c) {
-  return (c == CHAR_CR);
-}
-inline int ParseRules::is_lf(char c) {
-  return (c == CHAR_LF);
-}
-inline int ParseRules::is_splf(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 19)) ? (1) : (0));
-}
-inline int ParseRules::is_spcr(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 18)) ? (1) : (0));
-}
-inline int ParseRules::is_wslfcr(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 20)) ? (1) : (0));
-}
-inline int ParseRules::is_extra(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 9)) ? (1) : (0));
-}
-inline int ParseRules::is_safe(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 10)) ? (1) : (0));
-}
-inline int ParseRules::is_unsafe(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 11)) ? (1) : (0));
-}
-inline int ParseRules::is_reserved(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 13)) ? (1) : (0));
-}
-inline int ParseRules::is_national(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 12)) ? (1) : (0));
-}
-inline int ParseRules::is_unreserved(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 14)) ? (1) : (0));
-}
-inline int ParseRules::is_punct(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 15)) ? (1) : (0));
-}
-inline int ParseRules::is_end_of_url(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 16)) ? (1) : (0));
-}
-inline int ParseRules::is_escape(const char *seq) {
-  return (seq[0] == '%' && is_hex(seq[1]) && is_hex(seq[2]));
-}
-inline int ParseRules::is_uchar(const char *seq) {
-  return (is_unreserved(seq[0]) || is_escape(seq));
-}
-inline int ParseRules::is_pchar(const char *seq) {
-  if (*seq != '%')
-    return ((parseRulesCType[*seq] & (1 << 8)) ? (1) : (0));
-  else
-    return is_hex(seq[1]) && is_hex(seq[2]);
-}
-inline int ParseRules::is_tspecials(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 17)) ? (1) : (0));
-}
-inline int ParseRules::is_token(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 22)) ? (1) : (0));
-}
-inline char ParseRules::ink_toupper(char c) {
-  return parseRulesCTypeToUpper[(unsigned char) c];
-}
-inline char ParseRules::ink_tolower(char c) {
-  return parseRulesCTypeToLower[(unsigned char) c];
-}
-inline int ParseRules::is_eow(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 21)) ? (1) : (0));
-}
-inline int ParseRules::is_wildmat(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 23)) ? (1) : (0));
-}
-inline int ParseRules::is_sep(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 24)) ? (1) : (0));
-}
-inline int ParseRules::is_empty(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 25)) ? (1) : (0));
-}
-inline int ParseRules::is_space(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 27)) ? (1) : (0));
-}
-inline int ParseRules::is_control(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 28)) ? (1) : (0));
-}
-inline int ParseRules::is_mime_sep(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 29)) ? (1) : (0));
-}
-inline int ParseRules::is_http_field_name(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (1 << 30)) ? (1) : (0));
-}
-inline int ParseRules::is_http_field_value(char c) {
-  return ((parseRulesCType[(unsigned char) c] & (((unsigned int)1) << 31)) ? (1) : (0));
-}
-inline int ParseRules::strncasecmp_eow(
-  const char *s1, const char *s2, int count)
-{
-  for (int i = 0; i < count; i++) {
-    const char &a = s1[i];
-    const char &b = s2[i];
-    if (ink_tolower(a) != ink_tolower(b))
-      return (is_eow(a) && is_eow(b));
-  }
-  return (1);
-}
-inline int ParseRules::strlen_eow(const char *s){
-  for (int i = 0; 1; i++) {
-    if (is_eow(s[i]))
-      return (i);
-  }
-}
-inline const char *ParseRules::strstr_eow(const char *s1, const char *s2) {
-  int i1;
-  int s2_len = strlen_eow(s2);
-  for (i1 = 0; !is_eow(s1[i1]); i1++)
-    if (ink_tolower(s1[i1]) == ink_tolower(s2[0]))
-      if (strncasecmp_eow(&s1[i1], &s2[0], s2_len))
-        return (&s1[i1]);
-  return (0);
-}
-inline const char *ParseRules::
-strcasestr(const char *s1, const char *s2) {
-  int i1;
-  int s2_len = strlen(s2);
-  for (i1 = 0; s1[i1] != '\0'; i1++)
-    if (ink_tolower(s1[i1]) == ink_tolower(s2[0]))
-      if (strncasecmp_eow(&s1[i1], &s2[0], s2_len))
-        return (&s1[i1]);
-  return (0);
-}
-inline const char *ParseRules::memchr(const char *s, char c, int max_length) {
-  for (int i = 0; i < max_length; i++)
-    if (s[i] == c)
-      return (&s[i]);
-  return (0);
-}
-inline const char *ParseRules::strchr(const char *s, char c) {
-  for (int i = 0; s[i] != '\0'; i++)
-    if (s[i] == c)
-      return (&s[i]);
-  return (0);
-}
-inline int
-ink_atoi(const char *str) {
-  int num = 0;
-  int negative = 0;
-  while (*str && ParseRules::is_wslfcr(*str))
-    str += 1;
-  if (*str == '-') {
-    negative = 1;
-    str += 1;
-  }
-  while (*str && ParseRules::is_digit(*str))
-    num = (num * 10) - (*str++ - '0');
-  if (!negative)
-    num = -num;
-  return num;
-}
-inline unsigned int
-ink_atoui(const char *str) {
-  unsigned int num = 0;
-  while (*str && ParseRules::is_wslfcr(*str))
-    str += 1;
-  while (*str && ParseRules::is_digit(*str))
-    num = (num * 10) + (*str++ - '0');
-  return num;
-}
-inline int64_t
-ink_atoll(const char *str) {
-  int64_t num = 0;
-  int negative = 0;
-  while (*str && ParseRules::is_wslfcr(*str))
-    str += 1;
-  if (*str == '-') {
-    negative = 1;
-    str += 1;
-  }
-  while (*str && ParseRules::is_digit(*str))
-    num = (num * 10) - (*str++ - '0');
-  if (!negative)
-    num = -num;
-  return num;
-}
-
-#define HRTIME_FOREVER  (10*HRTIME_DECADE)
-#define HRTIME_DECADE   (10*HRTIME_YEAR)
-#define HRTIME_YEAR     (365*HRTIME_DAY+HRTIME_DAY/4)
-#define HRTIME_WEEK     (7*HRTIME_DAY)
-#define HRTIME_DAY      (24*HRTIME_HOUR)
-#define HRTIME_HOUR     (60*HRTIME_MINUTE)
-#define HRTIME_MINUTE   (60*HRTIME_SECOND)
-#define HRTIME_SECOND   (1000*HRTIME_MSECOND)
-#define HRTIME_MSECOND  (1000*HRTIME_USECOND)
-#define HRTIME_USECOND  (1000*HRTIME_NSECOND)
-#define HRTIME_NSECOND  (1LL)
-#define MAX_FILE_ARGUMENTS 100
-
-char * file_arguments[MAX_FILE_ARGUMENTS] = { 0 };
-char * program_name = (char *)"inktomi";
-int n_file_arguments = 0;
-
-static char * argument_types_keys = (char *)"ISDfFTL";
-static char * argument_types_descriptions[] = {
-  (char *)"int  ",
-  (char *)"str  ",
-  (char *)"dbl  ",
-  (char *)"off  ",
-  (char *)"on   ",
-  (char *)"tog  ",
-  (char *)"i64  ",
-  (char *)"     "
-};
-
-void show_argument_configuration(ArgumentDescription * argument_descriptions,
-                                 int n_argument_descriptions);
-
-void usage(ArgumentDescription * argument_descriptions,
-           int n_argument_descriptions,
-           char * arg_unused);
-
-void process_args(ArgumentDescription * argument_descriptions,
-                  int n_argument_descriptions,
-                  char **argv);
-
-#ifdef RELEASE
-#define ink_assert(EX) (void)(EX)
-#define ink_debug_assert(EX)
-#else
-#define ink_assert(EX) (\
-            void)((EX) || (_ink_assert(#EX, __FILE__, __LINE__)))
-#define ink_debug_assert(EX) \
-            (void)((EX) || (_ink_assert(#EX, __FILE__, __LINE__)))
-#endif
-
-#define ink_release_assert(EX) \
-            (void)((EX) || (_ink_assert(#EX, __FILE__, __LINE__)))
-
-int _ink_assert(const char * a, const char * f, int l);
-void ink_fatal(int return_code, const char *message_format, ...);
-void ink_warning(const char *message_format, ...);
-#define min(_a,_b) ((_a)<(_b)?(_a):(_b))
-
-inline ink_hrtime ink_get_hrtime()
-{
-#    if defined(FreeBSD)
-      timespec ts;
-      clock_gettime(CLOCK_REALTIME, &ts);
-      return (ts.tv_sec * HRTIME_SECOND + ts.tv_nsec * HRTIME_NSECOND);
-#    else
-      timeval tv;
-      gettimeofday(&tv,NULL);
-      return (tv.tv_sec * HRTIME_SECOND + tv.tv_usec * HRTIME_USECOND);
-#    endif
-}
-
-typedef struct {
-  char sche[MAX_URL_LEN + 1];
-  char host[MAX_URL_LEN + 1];
-  char port[MAX_URL_LEN + 1];
-  char path[MAX_URL_LEN + 1];
-  char frag[MAX_URL_LEN + 1];
-  char quer[MAX_URL_LEN + 1];
-  char para[MAX_URL_LEN + 1];
-
-  int sche_exists;
-  int host_exists;
-  int port_exists;
-  int path_exists;
-  int frag_exists;
-  int quer_exists;
-  int para_exists;
-
-  int rel_url;
-  int leading_slash;
-  int is_path_name;
-} InkWebURLComponents;
-
-static  int ink_web_remove_dots(
-  char *src, char *dest, int *leadingslash, int max_dest_len);
-
-static int ink_web_unescapify_string(
-  char *dest_in, char *src_in, int max_dest_len);
-
-int ink_web_escapify_string(char *dest_in, char *src_in, int max_dest_len);
-
-static void ink_web_decompose_url(
-  char *src_url,
-  char *sche, char *host, char *port, char *path,
-  char *frag, char *quer, char *para,
-  int *real_sche_exists, int *real_host_exists,
-  int *real_port_exists, int *real_path_exists, 
-  int *real_frag_exists, int *real_quer_exists,
-  int *real_para_exists,
-  int *real_relative_url, int *real_leading_slash);
-
-static void ink_web_canonicalize_url(char *base_url, char *emb_url, 
-                                     char *dest_url, int max_dest_url_len);
-
-static void ink_web_decompose_url_into_structure(char *url, 
-                                                 InkWebURLComponents *c);
-
-static void remove_last_seg(char *src, char *dest)
-{ 
-  char *ptr;
-  for (ptr = src + strlen(src) - 1; ptr >= src; ptr--)
-    if (*ptr == '/') break;
-  while (src <= ptr) *dest++ = *src++;
-  *dest = '\0';
-}
-
-static inline void remove_multiple_slash(char *src, char *dest)
-{ 
-  char *ptr=NULL;
-  
-  for (ptr = src; *ptr;) {
-      *(dest++) = *ptr;
-      if (*ptr == '/')  {
-        while ((*ptr== '/') && *ptr) {
-          ptr++;
-        }
-      } else {
-        ptr++;
-      }
-    }
-  *dest = '\0';
-}
-
-static inline void append_string(char *dest, char *src, int *offset_ptr, 
-                                 int max_len)
-{
-  int num = strlen(src);
-  if (*offset_ptr + num > max_len)
-    num = max_len-*offset_ptr;
-  strncpy(dest+*offset_ptr, src, num+1);
-  (*offset_ptr) += num;
-}
-
-// End Library functions
-
-void show_version() {
-  char b[] = VERSION_NUM;
-  char * v = strchr(b,':');
-  v += 2;
-  *strchr(v,'$') = 0;
-  printf(VERSION, v);
-}
-
-void jtest_usage(ArgumentDescription * argument_descriptions, 
-                 int n_argument_descriptions, char * arg) 
-{
-  show_version();
-  usage(argument_descriptions, n_argument_descriptions, arg);
-}
-
-static void panic(char * s) {
-  fputs(s, stderr);
-  exit(1);
-}
-
-static void panic_perror(char * s) {
-  perror(s);
-  exit(1);
-}
-
-int max_limit_fd() {
-  struct rlimit rl;
-  if (getrlimit(RLIMIT_NOFILE,&rl) >= 0) {
-#ifdef OPEN_MAX
-    // Darwin
-    rl.rlim_cur = min(OPEN_MAX, rl.rlim_max);
-#else
-    rl.rlim_cur = rl.rlim_max;
-#endif
-    if (setrlimit(RLIMIT_NOFILE,&rl) >= 0) {
-      if (getrlimit(RLIMIT_NOFILE,&rl) >= 0) {
-        return rl.rlim_cur;
-      }
-    }
-  }
-  panic_perror("couldn't set RLIMIT_NOFILE\n");
-  return -1;
-}
-
-int read_ready(int fd) {
-  struct pollfd p;
-  p.events = POLLIN;
-  p.fd = fd;
-  int r = poll(&p,1,0);
-  if (r<=0) return r;
-  if (p.revents & (POLLERR|POLLNVAL)) return -1;
-  if (p.revents & (POLLIN|POLLHUP)) return 1;
-  return 0;
-}
-
-static void poll_init(int sock) { 
-  if (!fd[sock].req_header) 
-    fd[sock].req_header = (char*)malloc(HEADER_SIZE * pipeline);
-  if (!fd[sock].response_header)
-    fd[sock].response_header = (char*)malloc(HEADER_SIZE);
-  if (!fd[sock].base_url)
-    fd[sock].base_url = (char*)malloc(HEADER_SIZE);
-  fd[sock].reset(); 
-}
-
-static void poll_set(int sock, poll_cb read_cb, poll_cb write_cb = NULL) {
-  if (verbose) printf("adding poll %d\n", sock);
-  fd[sock].fd = sock;
-  fd[sock].read_cb = read_cb;
-  fd[sock].write_cb = write_cb;
-  if (last_fd < sock)
-    last_fd = sock;
-}
-
-static void poll_init_set(int sock, poll_cb read_cb, poll_cb write_cb = NULL) {
-  poll_init(sock);
-  poll_set(sock, read_cb, write_cb);
-}
-
-static int fast(int sock, int speed, int d) {
-  if (!speed) return 0;
-  int64_t t = now - fd[sock].start + 1;
-  int target = (int)(((t / HRTIME_MSECOND) * speed) / 1000);
-  int delta = d - target;
-  if (delta > 0) {
-    int mwait = (delta * 1000) / speed;
-    fd[sock].ready = now + (mwait * HRTIME_MSECOND);
-    return 1;
-  } else
-    fd[sock].ready = now;
-  return 0;
-}
-
-static int faster_than(int sock, int speed, int d) {
-  if (!speed) return 1;
-  int64_t t = now - fd[sock].start + 1;
-  int target = (int)(((t / HRTIME_MSECOND) * speed) / 1000);
-  int delta = d - target;
-  if (delta > 0)
-    return 1;
-  return 0;
-}
-
-static void get_path_from_req(char * buf,char ** purl_start, char ** purl_end)
-{
-  char * url_start = buf;
-  char * url_end = NULL;
-  if (!strncasecmp(url_start, "GET ", sizeof("GET ")-1)) {
-    url_start += sizeof("GET ")-1;
-    url_end = (char*)memchr(url_start,' ',70);
-  } else
-    url_end = (char*)memchr(url_start,0,70);
-  if (!url_end) panic("malformed request\n");
-  if (url_end - url_start > 10)
-    if (!strncasecmp(url_start, "http://", sizeof("http://")-1)) {
-      url_start += sizeof("http://")-1;
-      url_start = (char*)memchr(url_start,'/',70);
-    }
-  *purl_start = url_start;  
-  *purl_end = url_end;
-}
-
-static int send_response (int sock) {
-  int err, towrite;
-
-  if (fd[sock].req_pos >= 0) {
-    char header[1024], *url_end = NULL, *url_start = NULL;
-    int url_len = 0;
-    char* content_type;
-    switch (server_content_type) {
-    case 1: content_type = "text/html"; break;
-    case 2: content_type = "image/jpeg"; break;
-    default:
-      content_type = 
-        (char*)((compd_suite || alternates) ? "image/jpeg" : "text/html");
-      if (only_server && strstr(fd[sock].req_header, "Cookie:"))
-        content_type = "image/jpeg";
-    }
-    if (!ftp && embed_url && fd[sock].response_length > 16) {
-      get_path_from_req(fd[sock].req_header, &url_start, &url_end);
-      *url_end = 0;
-      url_len = url_end - url_start;
-    }
-    int print_len = 0;
-    if (!ftp) {
-      if (fd[sock].ims) {
-        print_len = sprintf(
-          header,"HTTP/1.0 304 Not-Modified\r\n"
-          "Content-Type: %s\r\n"
-          "Last-Modified: Mon, 05 Oct 2010 01:00:00 GMT\r\n"
-          "%s"
-          "\r\n",
-          content_type,
-          fd[sock].keepalive>0?"Connection: Keep-Alive\r\n":"");
-        url_len = 0;
-      } else
-        print_len = sprintf(
-          header,"HTTP/1.0 200 OK\r\n"
-          "Content-Type: %s\r\n"
-          "Cache-Control: max-age=630720000\r\n"
-          "Last-Modified: Mon, 05 Oct 2010 01:00:00 GMT\r\n"
-          "%s"
-          "Content-Length: %d\r\n"
-          "%s"
-          "\r\n%s",
-          content_type,
-          fd[sock].keepalive>0?"Connection: Keep-Alive\r\n":"",
-          fd[sock].response_length,
-          no_cache?"Pragma: no-cache\r\nCache-Control: no-cache\r\n":"",
-          url_start ? url_start : "");
-    } else
-      url_len = print_len = 
-        sprintf(header, "ftp://%s:%d/%12.10f/%d", 
-                local_host, server_port,
-                fd[sock].doc, fd[sock].length);
-    if (show_headers) printf("Response to Proxy: {\n%s}\n", header);
-    int len = print_len - fd[sock].req_pos;
-    ink_assert(len>0);
-    do {
-      err = write(sock, header + fd[sock].req_pos, len);
-    } while ((err == -1) && (errno == EINTR));
-    if (err <= 0) {
-      if (!err) return -1;
-      if (errno == EAGAIN || errno == ENOTCONN) return 0;
-      return -1;
-    }
-    if (verbose) printf("wrote %d %d\n", sock, err);
-    new_tbytes += err;
-    fd[sock].req_pos += err;
-    fd[sock].bytes += err;
-    if (fd[sock].req_pos >= len)
-      fd[sock].req_pos = -1;
-    else
-      return 0;
-    fd[sock].response += url_len;
-    fd[sock].length -= url_len;
-    total_server_response_header_bytes += print_len - url_len;
-    total_server_response_body_bytes += url_len;
-  }
-
-  /* then the response */
-  towrite = server_speed?server_speed:MAX_RESPONSE_LENGTH;
-  if (fd[sock].length < towrite)
-    towrite = fd[sock].length;
-  if (towrite > 0) {
-    if (fast(sock,server_speed,fd[sock].bytes)) 
-      return 0;
-    do {
-      err = write (sock, fd[sock].response, towrite);
-    } while ((err == -1) && (errno == EINTR));
-    if (err < 0) {
-      if (errno == EAGAIN || errno == ENOTCONN) return 0;
-      fprintf(stderr,"write errno %d length %d sock %d\n",errno,towrite,sock);
-      errors++;
-      return -1;
-    }
-    if (verbose) printf("wrote %d %d\n", sock, err);
-
-    new_tbytes += err;
-    total_server_response_body_bytes += err;
-    fd[sock].response += err;
-    fd[sock].length -= err;
-    fd[sock].bytes += err;
-  }
-  
-  if (fast(sock,server_speed,fd[sock].bytes)) 
-    return 0;
-  if (fd[sock].length <= 0 || !err) {
-    if (fd[sock].response) 
-      new_sops++;
-    if (verbose) printf("write %d done\n", sock);
-    if (fd[sock].keepalive > 0 && !ftp) {
-      poll_init_set(sock, read_request);
-      fd[sock].start = now;
-      fd[sock].ready = now + server_delay * HRTIME_MSECOND;
-      return 0;
-    }
-    return 1;
-  }
-    
-  return 0;
-}
-
-char * strncasestr (char *s, char * find, int len) {
-  int findlen = strlen(find);
-  char * e = s + len;
-  while (1) {
-    char * x = (char*)memchr(s,*find,e - s);
-    if (!x) { 
-      if (ParseRules::is_upalpha(*find))
-        x = (char*)memchr(s,ParseRules::ink_tolower(*find),e - s);
-      else
-        x = (char*)memchr(s,ParseRules::ink_toupper(*find),e - s);
-      if (!x) break;
-    }
-    if (!strncasecmp(find, x, findlen)) return x;
-    s = x + 1;
-  }
-  return NULL;
-}
-
-static char * check_keepalive(char * r, int length) {
-  char * ka = strncasestr(r,"Connection:", length);
-  if (ka) {
-    int l = length - (ka - r);
-    char * e = (char*)memchr(ka,'\n',l);
-    if (!e) e = (char*)memchr(ka,'\r',l);
-    if (strncasestr(ka,"close",e-ka)) 
-      return NULL;
-  }
-  return ka;
-}
-
-static int check_alt(char * r, int length) {
-  char * s = strncasestr(r, "Cookie:", length);
-  if (!s) {
-    s = strncasestr(r, "User-Agent:", length);
-    if (s) s += sizeof("User-Agent:");
-  } else
-    s += sizeof("Cookie:");
-  if (s) {
-    int l = length - (s - r);
-    char * e = (char*)memchr(s, '\n', l);
-    if (!e) e = (char*)memchr(s, '\r', l);
-    if (!(s = strncasestr(s, "jtest", e - s))) 
-      return 0;
-    s = (char*)memchr(s, '-', l);
-    if (!s)
-      return 0;
-    s = (char*)memchr(s + 1, '-', l);
-    if (!s)
-      return 0;
-    return ink_atoi(s + 1);
-  }
-  return 0;
-}
-
-static void make_response(int sock, int code) {
-  fd[sock].response = fd[sock].req_header;
-  fd[sock].length = sprintf( fd[sock].req_header, "%d\r\n", code);
-  fd[sock].req_pos = 0;
-  fd[sock].response_length = strlen(fd[sock].req_header);
-  poll_set(sock, NULL, write_ftp_response);
-}
-
-static void make_long_response(int sock) {
-  fd[sock].response = fd[sock].req_header;
-  fd[sock].req_pos = 0;
-  fd[sock].response_length = strlen(fd[sock].req_header);
-  poll_set(sock, NULL, write_ftp_response);
-}
-
-static int send_ftp_data_when_ready(int sock) {
-  if (fd[sock].state == STATE_FTP_DATA_READY && fd[sock].doc_length) {
-    fd[sock].response = fd[sock].req_header;
-    fd[sock].response_length = fd[sock].length = fd[sock].doc_length;
-    if (verbose) printf("ftp data %d >-< %d\n", sock, fd[sock].ftp_data_fd);
-    fd[sock].response = response_buffer + fd[sock].doc_length % 256;
-    fd[sock].req_pos = 0;
-    poll_set(sock, NULL, send_response);
-  }
-  return 0;
-}
-
-static int send_ftp_data(int sock, char * start, char * end) {
-  int data_fd = fd[sock].ftp_data_fd;
-  if (sscanf(start,"%d",&fd[data_fd].doc_length) != 1)
-    return -1;
-  fd[data_fd].doc = fd[sock].doc;
-  send_ftp_data_when_ready(data_fd);
-  return 0;
-}
-
-static int read_request(int sock) {
-  if (verbose) printf("read_request %d\n", sock);
-  int err = 0;
-  int i;
-
-  int maxleft = HEADER_SIZE - fd[sock].req_pos - 1;
-
-  do {
-    err = read (sock, &fd[sock].req_header[fd[sock].req_pos], 
-                maxleft);
-  } while ((err < 0) && (errno == EINTR));
-  
-  if (err < 0) {
-    if (errno == EAGAIN || errno == ENOTCONN) return 0;
-    if (fd[sock].req_pos || errno != ECONNRESET)
-      perror ("read");
-    return -1;
-  } else if (err == 0) {
-    if (verbose) printf("eof\n");
-    return -1;
-  } else {
-    if (verbose) printf("read %d got %d\n", sock, err);
-    total_proxy_request_bytes += err;
-    new_tbytes += err;
-    fd[sock].req_pos += err;
-    fd[sock].req_header[fd[sock].req_pos] = 0;
-    char *buffer = fd[sock].req_header;
-    for (i = fd[sock].req_pos - err; 
-         i < fd[sock].req_pos; i++) 
-    {
-      switch (fd[sock].state) {
-        case 0:
-          if (buffer[i] == '\r')
-            fd[sock].state = 1;
-          else if (buffer[i] == '\n')
-            fd[sock].state = 2;
-          break;
-        case 1:
-          if (buffer[i] == '\n')
-            fd[sock].state = 2;
-          else
-            fd[sock].state = 0;
-          break;
-        case 2:
-          if (buffer[i] == '\r')
-            fd[sock].state = 3;
-          else if (buffer[i] == '\n') {
-            fd[sock].state = 3;
-            goto L3;
-          } else
-            fd[sock].state = 0;
-          break;
-      L3:
-        case 3:
-          if (buffer[i] == '\n') {
-            if (show_headers)
-              printf("Request from Proxy: {\n%s}\n",buffer);
-            char host[80];
-            int port, length;
-            float r;
-            if (sscanf(buffer,"GET http://%[^:]:%d/%f/%d",
-                       host,&port,&r,&length) == 4) {
-            } else if (sscanf(buffer,"GET /%f/%d",&r,&length) == 2) {
-            } else {
-              if (verbose) printf("misscan: %s\n",buffer);
-              fd[sock].close();
-              return 0;
-            }
-            if (verbose) 
-              printf("read_request %d got request %d\n", sock, length);
-            char * ims = strncasestr(buffer,"If-Modified-Since:", i);
-            if (drand48() > ims_rate) ims = NULL;
-            fd[sock].ims = ims?1:0;
-            if (!ims) {
-              fd[sock].response_length = fd[sock].length = length;
-              fd[sock].nalternate = check_alt(fd[sock].req_header, 
-                                              strlen(fd[sock].req_header));
-              fd[sock].response = response_buffer + length % 256 +
-                fd[sock].nalternate;
-            } else {
-              fd[sock].nalternate = 0;
-              if (verbose)
-                printf("sending IMS 304: Not-Modified\n");
-              fd[sock].response = NULL;
-              fd[sock].response_length = fd[sock].length = 0;
-            }
-            fd[sock].req_pos = 0;
-            if (!check_keepalive(fd[sock].req_header, 
-                                 strlen(fd[sock].req_header)))
-              fd[sock].keepalive = 0;
-            else 
-              fd[sock].keepalive--;
-            if (fd[sock].length && drand48() < server_abort_rate) {
-              fd[sock].length = (int)(drand48() * (fd[sock].length -1));
-              fd[sock].keepalive = 0;
-            }
-            poll_set(sock,NULL,send_response);
-            return 0;
-          } else
-            fd[sock].state = 0;
-          break;
-      }
-    }
-  }
-  return 0;
-}
-
-static int send_compd_response(int sock) {
-  int err = 0;
-
-  struct {
-    unsigned int code;
-    unsigned int len;
-  } compd_header;
-  if (fd[sock].req_pos < sizeof(compd_header)) {
-    compd_header.code = 0;
-    compd_header.len = htonl((fd[sock].length * 2) / 3);
-    do {
-      err = write(sock, (char*)&compd_header + fd[sock].req_pos, 
-                  sizeof(compd_header) - fd[sock].req_pos);
-    } while ((err == -1) && (errno == EINTR));
-    if (err <= 0) {
-      if (!err) {
-        if (verbose_errors) printf("write %d closed early\n", sock);
-        goto Lerror;
-      }
-      if (errno == EAGAIN || errno == ENOTCONN) return 0;
-      perror("write");
-      goto Lerror;
-    }
-    if (verbose) printf("write %d %d\n", sock, err);
-
-    new_tbytes += err;
-    fd[sock].req_pos += err;
-    fd[sock].bytes += err;
-    fd[sock].response = response_buffer + (((fd[sock].length * 2) / 3) % 256);
-  }
- 
-  if (fd[sock].req_pos < ((fd[sock].length * 2) / 3) + sizeof(compd_header)) {
-    int towrite = cbuffersize;
-    int desired = ((fd[sock].length * 2) / 3) + sizeof (compd_header) - fd[sock].req_pos;
-    if (towrite > desired) {
-      towrite = desired;
-    }
-    if (fast(sock,client_speed,fd[sock].bytes)) return 0;
-    do {
-      err = write (sock, fd[sock].response + fd[sock].req_pos - sizeof(compd_header) , towrite);
-    } while ((err == -1) && (errno == EINTR));
-    if (err < 0) {
-      if (errno == EAGAIN || errno == ENOTCONN) return 0;
-      fprintf(stderr,"write errno %d length %d sock %d\n",errno,towrite,sock);
-      errors++;
-      return -1;
-    }
-    if (verbose) printf("wrote %d %d\n", sock, err);
-
-    new_tbytes += err;
-    total_server_response_body_bytes += err;
-    fd[sock].req_pos += err;
-    fd[sock].bytes += err;
-  }
-
-  if (fd[sock].req_pos >= ((fd[sock].length * 2) / 3) + 4) 
-    return -1;
-  
-  return 0;
-Lerror:
-  errors++;
-  return 1;
-}
-
-static int read_compd_request(int sock) {
-  if (verbose) printf("read_compd_request %d\n", sock);
-  int err = 0;
-  int i;
-
-  if (fd[sock].req_pos < 4) {
-    int maxleft = HEADER_SIZE - fd[sock].req_pos - 1;
-    do {
-      err = read (sock, &fd[sock].req_header[fd[sock].req_pos], 
-                  maxleft);
-    } while ((err < 0) && (errno == EINTR));
-  
-    if (err < 0) {
-      if (errno == EAGAIN || errno == ENOTCONN) return 0;
-      perror ("read");
-      return -1;
-    } else if (err == 0) {
-      if (verbose) printf("eof\n");
-      return -1;
-    } else {
-      if (verbose) printf("read %d got %d\n", sock, err);
-      total_proxy_request_bytes += err;
-      new_tbytes += err;
-      fd[sock].req_pos += err;
-      if (fd[sock].req_pos < 4)
-        return 0;
-      fd[sock].length = ntohl(*(unsigned int*)fd[sock].req_header);
-    }
-  }
-
-  if (fd[sock].req_pos >= fd[sock].length + 4) 
-    goto Lcont;
-  
-  {
-    char buf[MAX_BUFSIZE];
-    int toread = cbuffersize;
-    if (fast(sock,client_speed,fd[sock].bytes)) return 0;
-    do {
-      err = read(sock, buf, toread);
-    } while ((err == -1) && (errno == EINTR));
-    if (err < 0) {
-      if (errno == EAGAIN || errno == ENOTCONN) return 0;
-      if (errno == ECONNRESET) {
-        if (verbose || verbose_errors)
-          perror ("read");
-        errors++;
-        return -1;
-      }
-      panic_perror("read");
-    }
-    if (!err) {
-      if (verbose || verbose_errors)
-        perror ("read");
-      errors++;
-      return -1;
-    }
-    total_proxy_request_bytes += err;
-    new_tbytes += err;
-    fd[sock].req_pos += err;
-  }
-    
-  if (fd[sock].req_pos >= fd[sock].length + 4) 
-    goto Lcont;
-    
-  return 0;
-
-Lcont:
-  fd[sock].req_pos = 0;
-  fd[sock].keepalive = 0;
-  poll_set(sock,NULL,send_compd_response);
-  return 0;
-}
-
-static int read_ftp_request(int sock) {
-  if (verbose) printf("read_ftp_request %d\n", sock);
-  int err = 0;
-  int i;
-
-  int maxleft = HEADER_SIZE - fd[sock].req_pos - 1;
-
-  do {
-    err = read (sock, &fd[sock].req_header[fd[sock].req_pos], 
-                maxleft);
-  } while ((err < 0) && (errno == EINTR));
-  
-  if (err < 0) {
-    if (errno == EAGAIN || errno == ENOTCONN) return 0;
-    perror ("read");
-    return -1;
-  } else if (err == 0) {
-    if (verbose) printf("eof\n");
-    return -1;
-  } else {
-    if (verbose) printf("read %d got %d\n", sock, err);
-    new_tbytes += err;
-    fd[sock].req_pos += err;
-    fd[sock].req_header[fd[sock].req_pos] = 0;
-    char *buffer = fd[sock].req_header, *n;
-    int res = 0;
-    buffer[fd[sock].req_pos] = 0;
-    if (verbose) printf("buffer [%s]\n", buffer);
-#define STREQ(_x,_s) (!strncasecmp(_x,_s,sizeof(_s)-1))
-    if (STREQ(buffer,"USER")) {
-        res = 331; goto Lhere;
-    } else if (STREQ(buffer,"PASS")) {
-        res = 230; goto Lhere;
-    } else if (STREQ(buffer,"CWD")) {
-      // TS used to send "CWD 1.2110000000..."
-      // TS now sends "CWD /1.2110000000^M\n", so skip 5 instead of 4
-      fd[sock].doc = (buffer[4]=='/') ? atof(buffer + 5) : atof(buffer + 4);
-      res = 250; goto Lhere;
-    } else if (STREQ(buffer,"TYPE")) {
-        res = 200;
-    Lhere:
-        n = (char*)memchr(buffer,'\n',fd[sock].req_pos);
-        if (!n) return 0;
-        make_response(sock,res);
-        return 0;
-    } else if (STREQ(buffer,"SIZE")) {
-        fd[sock].length = 
-          sprintf(fd[sock].req_header, "213 %d\r\n", atoi(buffer + 5));
-        make_long_response(sock);
-        return 0;
-    } else if (STREQ(buffer,"MDTM")) {
-      double err_rand = 1.0;
-      if (ftp_mdtm_err_rate != 0.0) err_rand = drand48();
-      if (err_rand < ftp_mdtm_err_rate) {
-        fd[sock].length =
-          sprintf (fd[sock].req_header, "550 mdtm file not found\r\n");
-      } else {
-        if (ftp_mdtm_rate == 0) {
-          fd[sock].length =
-            sprintf (fd[sock].req_header, "213 19900615100045\r\n");
-        } else {
-          time_t mdtm_now;
-          time(&mdtm_now);
-          if (mdtm_now-ftp_mdtm_last_update > ftp_mdtm_rate) {
-            struct tm *mdtm_tm;
-            ftp_mdtm_last_update = mdtm_now;
-            mdtm_tm = localtime(&ftp_mdtm_last_update);
-            sprintf(ftp_mdtm_str, "213 %.4d%.2d%.2d%.2d%.2d%.2d",
-                    mdtm_tm->tm_year + 1900,
-                    mdtm_tm->tm_mon + 1,
-                    mdtm_tm->tm_mday,
-                    mdtm_tm->tm_hour,
-                    mdtm_tm->tm_min,
-                    mdtm_tm->tm_sec);
-          }
-          fd[sock].length =
-            sprintf (fd[sock].req_header, "%s\r\n", ftp_mdtm_str);
-        }
-      }
-      make_long_response(sock);
-      return 0;
-    } else if (STREQ(buffer,"PASV")) {
-        n = (char*)memchr(buffer,'\n',fd[sock].req_pos);
-        if (!n) return 0;
-        if ((fd[sock].ftp_data_fd = open_server(0, accept_ftp_data)) < 0)
-          panic("could not open ftp data PASV accept port\n");
-        fd[fd[sock].ftp_data_fd].ftp_data_fd = sock;
-        if (verbose) printf("ftp PASV %d <-> %d\n", sock,fd[sock].ftp_data_fd);
-        unsigned short p = fd[fd[sock].ftp_data_fd].name.sin_port;
-        fd[sock].length = 
-          sprintf(fd[sock].req_header, "227 (%u,%u,%u,%u,%u,%u)\r\n",
-                  ((unsigned char*)&local_addr)[0],
-                  ((unsigned char*)&local_addr)[1],
-                  ((unsigned char*)&local_addr)[2],
-                  ((unsigned char*)&local_addr)[3],
-                  ((unsigned char*)&p)[0],
-                  ((unsigned char*)&p)[1]);
-        if (verbose) puts(fd[sock].req_header);
-        make_long_response(sock);
-        fd[sock].ftp_mode = FTP_PASV;
-        return 0;
-    } else if (STREQ(buffer,"PORT")) {
-        // watch out for an endian problems !!!
-        char *start, *stop;
-        for (start = buffer; !ParseRules::is_digit(*start); start++);
-        for (stop = start; *stop != ','; stop++);
-        for (i = 0; i < 4; i++) {
-          ((unsigned char*)&(fd[sock].ftp_peer_addr))[i] =
-            strtol(start, &stop, 10);
-          for (start = ++stop; *stop != ','; stop++);
-        }
-        ((unsigned char*)&(fd[sock].ftp_peer_port))[0] =
-          strtol(start, &stop, 10);
-        start = ++stop;
-        ((unsigned char*)&(fd[sock].ftp_peer_port))[1] =
-          strtol(start, NULL, 10);
-        fd[sock].length = 
-          sprintf(fd[sock].req_header, "200 Okay\r\n");
-        if (verbose) puts(fd[sock].req_header);
-        make_long_response(sock);
-        fd[sock].ftp_mode = FTP_PORT;
-        return 0;
-    } else if (STREQ(buffer,"RETR")) {
-        if (fd[sock].ftp_mode == FTP_NULL) {
-          // default to PORT ftp
-          struct sockaddr_in ftp_peer;
-          int ftp_peer_addr_len = sizeof(ftp_peer);
-          if (getpeername(sock, (struct sockaddr*)&ftp_peer,
-#if 0
-                          &ftp_peer_addr_len
-#else
-                          (socklen_t*)&ftp_peer_addr_len
-#endif
-            ) < 0) {
-            perror("getsockname");
-            exit(EXIT_FAILURE);
-          }
-          fd[sock].ftp_peer_addr = ftp_peer.sin_addr.s_addr;
-          fd[sock].ftp_peer_port = ftp_peer.sin_port;
-          fd[sock].ftp_mode = FTP_PORT;
-        }
-        if (fd[sock].ftp_mode == FTP_PORT) {
-          if ((fd[sock].ftp_data_fd =
-               make_client(fd[sock].ftp_peer_addr,fd[sock].ftp_peer_port)) < 0)
-            panic("could not open ftp PORT data connection to client\n");
-          fd[fd[sock].ftp_data_fd].ftp_data_fd = sock;
-          fd[fd[sock].ftp_data_fd].state = STATE_FTP_DATA_READY;
-          if (verbose)
-            printf("ftp PORT %d <-> %d\n", sock, fd[sock].ftp_data_fd);
-        }
-        n = (char*)memchr(buffer,'\n',fd[sock].req_pos);
-        if (!n) return 0;
-        if (send_ftp_data(sock, buffer+5, n)<0) {
-          errors++;
-          *n = 0;
-          if (verbose)
-            printf("badly formed ftp request: %s\n", buffer);
-          return 1;
-        }
-        fd[sock].response = fd[sock].req_header;
-        fd[sock].length = sprintf( fd[sock].req_header, "150 %d bytes\r\n", 
-                                   fd[fd[sock].ftp_data_fd].length);
-        fd[sock].req_pos = 0;
-        fd[sock].response_length = strlen(fd[sock].req_header);
-        poll_set(sock, NULL, write_ftp_response);
-        buffer = n+1;
-        return 0;
-    } else {
-      if (verbose || verbose_errors) printf("ftp junk : %s\n", buffer);
-      fd[sock].req_pos = 0;
-      return 0;
-    }
-  }
-}
-
-static int accept_sock(int sock) {
-  struct sockaddr_in clientname;
-  int size = sizeof (clientname);
-  int new_fd = 0;
-  do {
-    new_fd = accept(sock, (struct sockaddr *) &clientname,
-#if 0
-                    &size
-#else
-                    (socklen_t*)&size
-#endif
-      );
-    if (new_fd < 0) {
-      if (errno == EAGAIN || errno == ENOTCONN) return 0;
-      if (errno == EINTR || errno == ECONNABORTED) continue;
-      printf("accept socket was %d\n",sock);
-      panic_perror("accept");
-    }
-  } while (new_fd < 0);
-
-  if (fcntl (new_fd, F_SETFL, O_NONBLOCK) < 0)
-    panic_perror("fcntl");
-
-#if 0
-#ifdef BUFSIZE                          //  make default
-  int bufsize = BUFSIZE;
-  if (setsockopt(new_fd,SOL_SOCKET,SO_SNDBUF,
-                 (const char *)&bufsize,sizeof(bufsize)) < 0) {
-    perror("setsockopt");
-  }
-  if (setsockopt(new_fd,SOL_SOCKET,SO_SNDBUF,
-                 (const char *)&bufsize,sizeof(bufsize)) < 0) {
-    perror("setsockopt");
-  }
-#endif
-#endif
-  int enable =1;
-  if (setsockopt(new_fd,IPPROTO_TCP,TCP_NODELAY,
-                 (const char *)&enable,sizeof(enable)) < 0) {
-    perror("setsockopt");
-  }
-#ifdef PRINT_LOCAL_PORT
-  struct sockaddr_in local_sa;
-  size = sizeof(local_sa);
-  getsockname(new_fd, (struct sockaddr*)&local_sa, &size);
-  printf("local_sa.sin_port = %d\n", local_sa.sin_port);
-#endif
-  return new_fd;
-}
-
-static int accept_compd (int sock) {
-  int new_fd = accept_sock(sock);
-  servers++;
-  new_servers++;
-  poll_init_set(new_fd, NULL, read_compd_request);
-  fd[new_fd].count = &servers;
-  fd[new_fd].start = now;
-  fd[new_fd].ready = now + server_delay * HRTIME_MSECOND;
-  fd[new_fd].keepalive = server_keepalive?server_keepalive:INT_MAX;
-
-  return 0;
-}
-
-static int accept_read (int sock) {
-  int new_fd = accept_sock(sock);
-  servers++;
-  new_servers++;
-  if (ftp) {
-    poll_init_set(new_fd, NULL, write_ftp_response);
-    make_response(new_fd, 220);
-  } else
-    poll_init_set(new_fd, read_request);
-  fd[new_fd].count = &servers;
-  fd[new_fd].start = now;
-  fd[new_fd].ready = now + server_delay * HRTIME_MSECOND;
-  fd[new_fd].keepalive = server_keepalive?server_keepalive:INT_MAX;
-
-  return 0;
-}
-
-static int accept_ftp_data (int sock) {
-  int new_fd = accept_sock(sock);
-  servers++;
-  new_servers++;
-  poll_init(new_fd);
-  fd[new_fd].ftp_data_fd = fd[sock].ftp_data_fd;
-  fd[fd[sock].ftp_data_fd].ftp_data_fd = new_fd;
-  fd[new_fd].state = STATE_FTP_DATA_READY;
-  fd[new_fd].count = &servers;
-  fd[new_fd].start = now;
-  fd[new_fd].ready = now + server_delay * HRTIME_MSECOND;
-  fd[new_fd].keepalive = server_keepalive?server_keepalive:INT_MAX;
-  fd[new_fd].state = STATE_FTP_DATA_READY;
-  fd[new_fd].doc = fd[sock].doc;
-  fd[new_fd].doc_length = fd[sock].doc_length;
-  if (verbose) 
-    printf("accept_ftp_data %d for %d\n", new_fd, sock);
-  send_ftp_data_when_ready(new_fd);
-  return 1;
-}
-
-static int open_server(unsigned short int port, accept_fn_t accept_fn) {
-  struct linger lngr;
-  int sock;
-  int one = 1;
-  int err = 0;
-
-  /* Create the socket. */
-  sock = socket (AF_INET, SOCK_STREAM, 0);
-  if (sock < 0) {
-    perror ("socket");
-    exit (EXIT_FAILURE);
-  }
-  struct sockaddr_in & name = fd[sock].name;
-
-  /* Give the socket a name. */
-  name.sin_family = AF_INET;
-  name.sin_port = htons (port);
-  name.sin_addr.s_addr = htonl (INADDR_ANY);
-  if (setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, (char *) &one,
-                  sizeof (one)) < 0) {
-    perror((char*)"setsockopt");
-    exit( EXIT_FAILURE);
-  }
-  if ((err=bind (sock, (struct sockaddr *) &name, sizeof (name))) < 0) {
-    if (errno == EADDRINUSE)
-      return -EADDRINUSE;
-    perror("bind");
-    exit( EXIT_FAILURE);
-  }
-
-  int addrlen = sizeof(name);
-  if ((err = getsockname(sock, (struct sockaddr *) &name, 
-#if 0
-                         &addrlen
-#else
-                         (socklen_t*)&addrlen
-#endif
-    )) < 0) {
-    perror("getsockname");
-    exit( EXIT_FAILURE);
-  }
-  ink_assert(addrlen);
-
-  /* Tell the socket not to linger on exit */
-  lngr.l_onoff = 0;
-  lngr.l_linger = 0;
-  if (setsockopt (sock, SOL_SOCKET, SO_LINGER, (char*) &lngr, 
-                  sizeof (struct linger)) < 0) {
-    perror ("setsockopt");
-    exit (EXIT_FAILURE);
-  }
-
-  if (listen (sock, 1024) < 0) {
-    perror ("listen");
-    exit (EXIT_FAILURE);
-  }
-
-  /* put the socket in non-blocking mode */
-  if (fcntl (sock, F_SETFL, O_NONBLOCK) < 0) {
-    perror ("fcntl");
-    exit (EXIT_FAILURE);
-  }
-
-  if (verbose) 
-    printf("opening server on %d port %d\n", sock, name.sin_port);
-
-  poll_init_set(sock, accept_fn);
-
-  return sock;
-}
-
-//   perform poll and invoke callbacks on active descriptors 
-int poll_loop() {
-  if (server_fd > 0) {
-    while (read_ready(server_fd) > 0)
-      accept_read(server_fd);
-  }
-  pollfd pfd[POLL_GROUP_SIZE];
-  int ip = 0;
-  int last_fd_in_block = 0;
-  now = ink_get_hrtime();
-  for (int i = 0 ; i <= last_fd ; i++) {
-    if (fd[i].fd > 0 && (!fd[i].ready || now >= fd[i].ready)) {
-      pfd[ip].fd = i;
-      pfd[ip].events = 0;
-      pfd[ip].revents = 0;
-      if (fd[i].read_cb)
-        pfd[ip].events |= POLLIN;
-      if (fd[i].write_cb)
-        pfd[ip].events |= POLLOUT;
-      ip++;
-    }
-    if (ip >= POLL_GROUP_SIZE || i == last_fd) {
-      int n = poll(pfd,ip,POLL_TIMEOUT);
-      if (n > 0) {
-        for (int j = 0; j < ip ; j++) {
-          if (pfd[j].revents & (POLLIN|POLLERR|POLLHUP|POLLNVAL)) {
-            if (verbose) printf("poll read %d %X\n",pfd[j].fd,pfd[j].revents);
-            if (fd[pfd[j].fd].read_cb && fd[pfd[j].fd].read_cb(pfd[j].fd)) {
-              fd[pfd[j].fd].close();
-              continue;
-            }
-          }
-          if (pfd[j].revents & (POLLOUT|POLLERR|POLLHUP|POLLNVAL)) {
-            if (verbose) printf("poll write %d %X\n",pfd[j].fd,pfd[j].revents);
-            if (fd[pfd[j].fd].write_cb && fd[pfd[j].fd].write_cb(pfd[j].fd)) {
-              fd[pfd[j].fd].close();
-              continue;
-            }
-          }
-        }
-      }
-      ip = 0;
-    }
-  }
-  return 0;
-}
-
-int gen_bfc_dist(double f = 10.0) {
-
-  if (docsize >= 0) return docsize;
-
-  double rand = 0.0;
-  double rand2 = 0.0;
-  bool f_given = f < 9.0;
-  if (!f_given) {
-    rand = drand48();
-    rand2 = drand48();
-  } else {
-    rand = f;
-    rand2 = (f * 13.0) - floor(f * 13.0);
-  }
-
-  int class_no;
-  int file_no;
-
-  if(rand < 0.35){
-    class_no = 0;
-  }else if(rand < 0.85){
-    class_no = 1;
-  }else if (rand < 0.99){
-    class_no = 2;
-  }else {
-    class_no = 3;
-    if (f_given) rand2 = (f * 113.0) - floor(f * 113.0);
-  }
-  
-  if(rand2 < 0.018){
-    file_no=0;
-  }else if(rand2 < 0.091){
-    file_no=1;
-  }else if(rand2 < 0.237){
-    file_no=2;
-  }else if(rand2 < 0.432){
-    file_no=3;
-  }else if(rand2 < 0.627){
-    file_no=4;
-  }else if(rand2 < 0.783){
-    file_no=5;
-  }else if(rand2 < 0.887){
-    file_no=6;
-  }else if(rand2 < 0.945){
-    file_no=7;
-  }else if(rand2 < 1.000){
-    file_no=8;
-  }
-  int size = 100;
-  int i;
-  for (i = 0; i < class_no; i++) {
-    size = size * 10;
-  }
-  int increment = size;
-  size = size * (file_no+1);
-  // vary about the mean doc size for
-  // that class/size
-  if (!f_given)
-    size += (int)((-increment * 0.5) + (increment * drand48()));
-  if (verbose) printf("gen_bfc_dist %d\n",size);
-  return size;
-}
-
-void build_response() {
-  int maxsize = docsize > MAX_RESPONSE_LENGTH ? docsize : MAX_RESPONSE_LENGTH;
-  response_buffer = (char*) malloc (maxsize + HEADER_SIZE);
-  for (int i = 0 ; i < maxsize + HEADER_SIZE; i++)
-    response_buffer[i] = i % 256;
-}
-
-static void put_ka(int sock) {
-  int i = 0;
-  for (; i < n_ka_cache; i++ ) 
-    if (!ka_cache_head[i] || fd[ka_cache_head[i]].ip == fd[sock].ip) 
-      goto Lpush;
-  i = n_ka_cache++;
-Lpush:  
-  if (ka_cache_tail[i])
-    fd[ka_cache_tail[i]].next = sock;
-  else
-    ka_cache_head[i] = sock;
-  ka_cache_tail[i] = sock;
-}
-
-static int get_ka(unsigned int ip) {
-  for (int i = 0; i < n_ka_cache; i++ ) 
-    if (fd[ka_cache_head[i]].ip == ip) {
-      int res = ka_cache_head[i];
-      ka_cache_head[i] = fd[ka_cache_head[i]].next;
-      if (res == ka_cache_tail[i]) {
-        ink_assert(!ka_cache_head[i]);
-        ka_cache_tail[i] = 0;
-      }
-      return res;
-    }
-  return -1;
-}
-
-static void defer_url(char * url) {
-  if (n_defered_urls < MAX_DEFERED_URLS -1)
-    defered_urls[n_defered_urls++] = strdup(url);
-  else
-    fprintf(stderr, "too many defered urls, dropping '%s'\n", url);
-}
-
-static int throttling_connections() {
-  return client_rate && keepalive_cons && current_clients >= keepalive_cons;
-}
-
-static void done() {
-  interval_report();
-  exit(0);
-}
-
-static int is_done() { 
-  return 
-    (urls_mode && !current_clients && !n_defered_urls) ||
-    (bandwidth_test && bandwidth_test_to_go <= 0 && !current_clients);
-}
-
-static void undefer_url(bool unthrottled) {
-  if ((unthrottled || !throttling_connections()) && n_defered_urls) {
-    --n_defered_urls;
-    char * url =  defered_urls[n_defered_urls];
-    make_url_client(url,0,true,unthrottled);
-    free(url);
-    if (verbose) 
-      printf("undefer_url: made client %d clients\n", current_clients);
-  } else
-    if (verbose) printf("undefer_url: throttle\n");
-  if (is_done())
-    done();
-}
-
-static void init_client(int sock) {
-  poll_init(sock);
-  fd[sock].start = now;
-  fd[sock].ready = now;
-  fd[sock].count = &clients;
-  poll_set(sock,NULL,write_request);
-}
-
-static unsigned int get_addr(char * host) {
-  unsigned int addr = inet_addr(host);
-  struct hostent *host_info = NULL;
-
-  if (!addr || (-1 == (int)addr)) {
-    host_info = gethostbyname(host);
-    if (!host_info) {
-      perror ("gethostbyname");
-      return (unsigned int)-1;
-    }
-    addr = *((unsigned int*) host_info->h_addr);
-  }
-
-  return addr;
-}
-
-char * find_href_end (char *start, int len)
-{
-  char *end = start;
-  if (!start) return NULL;
-
-  while (*end && len > 0) {
-      if (*end == '\"') break;  /* " */
-      if (*end == '\'') break;                 
-      if (*end == '>')  break;
-      if (*end == ' ')  break;
-      if (*end == '\t') break;
-      if (*end == '\n') break;
-      if (*end == '<')  break;
-      if(*end & 0x80) break; /* hi order bit! */
-      len--;
-      end++;
-    }
-
-  if (*end == 0 || len == 0) 
-    return NULL;
-  else
-    return end;
-} // find_href_end
-
-char * find_href_start(char * tag, char *base, int len)
-{
-  int taglen = strlen(tag);
-  if (base == NULL) return NULL;
-
-  char *start = base;
-  char *end = base + len;
-
- Lagain:
-  {
-    start = strncasestr(start, tag, len);
-    if ((start == NULL) || (end-start < 6)) {
-      return NULL;
-    }
-    start += taglen;
-    len -= taglen;
-  } // block
-
-  while (ParseRules::is_ws (*start) && (end - start > 1)) {
-    start++;
-    len--;
-  }
-  if (*start == '=' && (end - start > 1)) {
-    start++;
-    len--;
-  } else {
-    goto Lagain;
-  }
-  while (ParseRules::is_ws(*start) && (end - start > 1)) {
-    start++;
-    len--;
-  }
-  //
-  // Optional quotes:  href="x" or href='x' or href=x
-  //
-  if ((*start == '\"'||(*start == '\'')) && (end - start > 1)) { /*"'*/
-    start++;
-    len--;
-  }
-  while (ParseRules::is_ws(*start) && (end - start > 1)) {
-    start++;
-    len--;
-  }
-
-  return start;
-} // find_href_start
-
-int compose_url(char * new_url, char * base, char *input) {
-  char sche[8],host[512],port[10],path[512],frag[512],quer[512],para[512];
-  char curl[512];
-  int xsche,xhost,xport,xpath,xfrag,xquer,xpar,rel,slash;
-  ink_web_decompose_url(base,sche,host,port,path,frag,quer,para,
-                        &xsche,&xhost,&xport,&xpath,&xfrag,&xquer,
-                        &xpar,&rel,&slash);
-  strcpy(curl, "http://");
-  strcat(curl,host);
-  if (xport) {
-    strcat(curl,":");
-    strcat(curl,port);
-  }
-  strcat(curl,"/");
-  strcat(curl,path);
-
-  ink_web_canonicalize_url(curl, input, new_url, 512);
-  return 0;
-} // compose_urls
-
-void compose_all_urls( char * tag, char * buf, char * start, char * end, 
-                       int buflen, char * base_url)
-{
-  char old;
-  while ((start = find_href_start(tag, end, buflen - (end - buf)))) {
-    char newurl[512];
-    end = (char *) find_href_end(start, min(buflen - (start-buf), 512 - 10)); 
-    if (!end) { 
-      end = start + strlen(tag);
-      continue;
-    }
-    old = *end;
-    *end = 0;
-    compose_url(newurl, base_url, start);
-    make_url_client(newurl,base_url);
-    *end = old;
-  } // while
-}
-//
-// Input is a NULL-terminated string (buf of buflen)
-//       also, a read-write base_url
-//
-void extract_urls(char * buf, int buflen, char * base_url) {
-  //if (verbose) printf("EXTRACT<<%s\n>>", buf);
-  char old;
-  char *start = NULL;
-  char *end = NULL;
-  char old_base[512];
-  strcpy(old_base, base_url);
-
-  start = strncasestr(buf, "<base ", buflen);
-  if (start) {
-    end = (char*)memchr(start, '>', buflen - (start - buf));
-    if (end) {
-      char * rover = strncasestr(start, "href", end - start);
-      if (rover) {
-        rover += 4;
-        while (rover < end && 
-               (ParseRules::is_ws(*rover) || *rover == '=' || *rover == '\'' 
-                || *rover == '\"'))    /* " */
-          rover++;
-        start = rover;
-        while (rover < end && 
-               !(ParseRules::is_ws(*rover) || *rover == '\'' 
-                 || *rover == '\"'))
-          rover++;
-        old = *rover;
-        *rover = 0;
-        compose_url(base_url,old_base,start);
-        // fixup unqualified hostnames (e.g. http://internal/foo)
-        char * he = strchr(base_url + 8, '/'); 
-        if (!memchr(base_url,'.',he-base_url)) {
-          char t[512]; strcpy(t,base_url);
-          char * old_he = strchr(old_base + 8, '.');
-          if (old_he) {
-            char * old_hee = strchr(old_he, '/');
-            if (old_hee) {
-              memcpy(base_url,t,(he-base_url));
-              memcpy(base_url + (he-base_url), old_he, (old_hee-old_he));
-              memcpy(base_url + (he-base_url) + (old_hee-old_he),
-                     t+(he-base_url), strlen(t+(he-base_url)));
-              base_url[(he-base_url) + (old_hee-old_he) +
-                      strlen(t+(he-base_url))] = 0;
-            }}}}}}
-
-  end = buf;
-  if (follow)
-    compose_all_urls("href", buf, start, end, buflen, base_url);
-  if (fullpage) {
-    char *tags[] = { "src", "image", "object", "archive", "background", 
-                     // "location", "code" 
-    };
-    for (int i = 0 ; i < sizeof(tags)/sizeof(tags[0]) ; i++)
-      compose_all_urls(tags[i], buf, start, end, buflen, base_url);
-  }
-} // extract_urls
-
-void follow_links(int sock) {
-  if (urls_mode) {
-    if (fd[sock].binary) return;
-    int l = fd[sock].response_remaining;
-    char * r = fd[sock].response, *p = r, *n = r;
-    if (r)
-      extract_urls(r,l,fd[sock].base_url);
-    if (l < MAX_BUFSIZE) {
-      while (n) {
-        n = (char*)memchr(p,'\n',l - (p - r));
-        if (!n) n = (char*)memchr(p,'\r',l - (p - r));
-        if (n) p = n + 1;
-      }
-      int done = p - r, remaining = l - done;
-      if (done) {
-        memmove(r, p, remaining);
-        fd[sock].response_remaining = remaining;
-      }
-    } else  // bail
-      fd[sock].response_length = 0;
-  }
-}
-
-static int verify_content(int sock, char * buf, int done) {
-  if (urls_mode && !check_content)
-    return 1;
-  int l = fd[sock].response_length;
-  char * d = response_buffer + (l % 256) + fd[sock].nalternate;
-  int left = fd[sock].length;
-  if (left > 0) {
-    if (embed_url && !fd[sock].jg_compressed) {
-      if (l == left && left > 64) {
-        char *url_end = NULL, *url_start = NULL;
-        get_path_from_req(fd[sock].base_url,&url_start,&url_end);
-        if (url_end - url_start < done) {
-          if (memcmp(url_start,buf,url_end - url_start)) 
-            return 0;
-        }
-      }
-      // skip past the URL which is embedded in the document
-      // to confound the fingerprinting code
-      if (l - left < 64) {
-        int skip = 64 - (l - left);
-        left -= skip;
-        done -= skip;
-        buf += skip;
-        if (done < 0)
-          done = 0;
-      }
-    }
-    if (!check_content)
-      return 1;
-    if (done > left)
-      done = left;
-    if (memcmp(buf, d + (fd[sock].response_length - left), done))
-      return 0;
-  }
-  return 1;
-}
-
-#define ZIPF_SIZE (1<<20)
-static double *zipf_table = NULL;
-void build_zipf() {
-  zipf_table = (double*)malloc(ZIPF_SIZE * sizeof(double));
-  for (int i = 0; i < ZIPF_SIZE; i++)
-    zipf_table[i] = 1.0 / pow(i+2, zipf);
-  for (int i = 1; i < ZIPF_SIZE; i++)
-    zipf_table[i] = zipf_table[i-1] + zipf_table[i];
-  double x = zipf_table[ZIPF_SIZE-1];
-  for (int i = 0; i < ZIPF_SIZE; i++)
-    zipf_table[i] = zipf_table[i] / x;
-}
-
-int get_zipf(double v) {
-  int l = 0, r = ZIPF_SIZE-1, m;
-  do {
-    m = (r + l) / 2;
-    if (v < zipf_table[m])
-      r = m - 1;
-    else
-      l = m + 1;
-  } while (l < r);
-  if (zipf_bucket_size == 1)
-    return m;
-  double x = zipf_table[m], y = zipf_table[m+1];
-  m += (v - x) / (y - x);
-  return m;
-}
-
-static int read_response_error(int sock) {
-  errors++;
-  fd[sock].close();
-  if (!urls_mode)
-    make_bfc_client(proxy_addr, proxy_port);
-  return 0;
-}
-
-static int read_for_error(int sock) {
-  char b[8192];
-  int err = read(sock, &b, 8192);
-  if (err < 0)
-    return read_response_error(sock);
-  return 0;
-}
-
-static int read_response(int sock) {
-  int err = 0;
-
-  if (fd[sock].req_pos >= 0) {
-    if (!fd[sock].req_pos) 
-      memset(fd[sock].req_header,0,HEADER_SIZE);
-    do {
-      int l = HEADER_SIZE - fd[sock].req_pos - 1;
-      if (l <= 0) { 
-        if (verbose || verbose_errors) 
-          printf("header too long '%s'", fd[sock].req_header);
-        return read_response_error(sock);
-      }
-      err = read(sock, fd[sock].req_header + fd[sock].req_pos, 
-                 HEADER_SIZE - fd[sock].req_pos - 1);
-    } while ((err == -1) && (errno == EINTR));
-    if (err <= 0) {
-      if (!err) {
-        if (verbose_errors) 
-          printf("read_response %d closed during header for '%s' after %d%s\n",
-                 sock, fd[sock].base_url, fd[sock].req_pos,
-                 (keepalive && (fd[sock].keepalive != keepalive) 
-                  && !fd[sock].req_pos) ? " -- keepalive timeout" : "");
-        return read_response_error(sock);
-      }
-      if (errno == EAGAIN || errno == ENOTCONN) return 0;
-      if (errno == ECONNRESET) {
-        if (!fd[sock].req_pos && keepalive > 0 && 
-            fd[sock].keepalive != keepalive) {
-          fd[sock].close();
-          if (!urls_mode)
-            make_bfc_client(proxy_addr, proxy_port);
-          return 0;
-        }
-        if (verbose || verbose_errors)
-          perror ("read");
-        goto Ldone;
-      }
-      panic_perror("read");
-    }
-    if (verbose) 
-      printf("read %d header %d [%s]\n", 
-             sock, err, fd[sock].req_header);
-    b1_ops++;
-
-    strcpy(fd[sock].response_header, fd[sock].req_header);
-
-    b1latency += ((ink_get_hrtime() - fd[sock].start) / HRTIME_MSECOND);
-    new_cbytes += err;
-    new_tbytes += err;
-    fd[sock].req_pos += err;
-    fd[sock].bytes += err;
-    fd[sock].active = ink_get_hrtime();
-    int total_read = fd[sock].req_pos;
-    char * p = fd[sock].req_header;
-    char * cl = NULL;
-    int cli = 0;
-    while ((p = strchr(p,'\n'))) {
-      if (verbose) printf("read header end? [%s]\n", p);
-      if (p[1] == '\n' || (p[1] == '\r' && p[2] == '\n')) {
-        int off = 1 + (p[1] == '\r' ? 2 : 1);
-        p += off;
-        strncpy(fd[sock].response_header, fd[sock].req_header, p - fd[sock].req_header);
-        fd[sock].response_header[p - fd[sock].req_header] = '\0';
-        int lbody =  fd[sock].req_pos - (p - fd[sock].req_header);
-        cl = strncasestr(fd[sock].req_header,"Content-Length:", 
-                         p - fd[sock].req_header);
-        if (cl) {
-          cli = atoi(cl + 16);
-            int expected_length = fd[sock].response_length;
-            if (compd_suite) {
-              if (strstr(fd[sock].req_header, "x-jg")) {
-                fd[sock].jg_compressed = 1;
-                expected_length = (fd[sock].response_length * 2) / 3;
-              }
-            } 
-            if (fd[sock].response_length && verbose_errors &&
-                expected_length != cli && !nocheck_length) 
-              fprintf(stderr, "bad Content-Length expected %d got %d orig %d",
-                      expected_length, cli, fd[sock].response_length);
-            fd[sock].response_length = fd[sock].length = cli;
-        }
-        if (fd[sock].req_header[9] == '2') {
-          if (!verify_content(sock,p,lbody)) {
-            if (verbose || verbose_errors)
-              printf("content verification error '%s'\n", fd[sock].base_url);
-            return read_response_error(sock);
-          }
-        }
-        total_proxy_response_body_bytes += lbody;
-        total_proxy_response_header_bytes += p - fd[sock].req_header;
-        fd[sock].length -= lbody;
-        fd[sock].req_pos = -1;
-        if (fd[sock].length && drand48() < client_abort_rate) {
-          fd[sock].client_abort = 1;
-          fd[sock].length = (int)(drand48() * (fd[sock].length -1)); 
-          fd[sock].keepalive = 0;
-          fd[sock].drop_after_CL = 1;
-        }
-        if (verbose) printf("read %d header done\n", sock);
-        break;
-      }
-      p++;
-    }
-    if (!p) return 0;
-    int hlen = p -  fd[sock].req_header;
-    if (show_headers) {
-      printf("Response From Proxy: {\n");
-      for (char * c = fd[sock].req_header; c < p ; c++)
-        putc(*c,stdout);
-      printf("}\n");
-    }
-    if (obey_redirects && urls_mode && 
-        fd[sock].req_header[9] == '3' &&
-        fd[sock].req_header[10] == '0' &&
-        (fd[sock].req_header[11] == '1' || fd[sock].req_header[11] == '2')) 
-    {
-      char * redirect = strstr(fd[sock].req_header,"http://");
-      char * e = redirect?(char*)memchr(redirect,'\n',hlen):0;
-      if (!redirect || !e)
-        fprintf(stderr, "bad redirect '%s'",fd[sock].req_header);
-      else {
-        if (e[-1]=='\r') e--;
-        *e = 0;
-        make_url_client(redirect);
-      }
-      fd[sock].close();
-      return 0;
-    }
-    if (fd[sock].req_header[9] != '2') {
-      if (verbose_errors) {
-        char * e = (char*)memchr(fd[sock].req_header, '\r', hlen);
-        if (e) *e = 0;
-        else {
-          char * e = (char*)memchr(fd[sock].req_header, '\n', hlen);
-          if (e) *e = 0;
-          else *p = 0;
-        }
-        printf("error response %d: '%s':'%s'\n", sock, 
-               fd[sock].base_url, fd[sock].req_header);
-      }
-      return read_response_error(sock);
-    }
-    char * r = fd[sock].req_header;
-    int length = p - r;
-    char * ka = check_keepalive(r, length);
-    if (urls_mode) {
-      fd[sock].response_remaining = total_read - length;
-      if (fd[sock].response_remaining) 
-        memcpy(fd[sock].response,p,fd[sock].response_remaining);
-      if (check_content && !cl) {
-        if (verbose || verbose_errors)
-          printf("missiing Content-Length '%s'\n", fd[sock].base_url);
-        return read_response_error(sock);
-      }
-    } else
-      fd[sock].response = 0;      
-    if (!cl || !ka)
-      fd[sock].keepalive = -1;
-    if (!cl)
-      fd[sock].length = INT_MAX;
-  }
-  
-  if (fd[sock].length <= 0 && 
-      (fd[sock].keepalive > 0 || fd[sock].drop_after_CL))
-    goto Ldone;
-
-  {
-    char * r = NULL;
-    char buf[MAX_BUFSIZE];
-    int toread = cbuffersize;
-    if (urls_mode) {
-      if (fd[sock].response_remaining + cbuffersize < MAX_BUFSIZE)
-        r = fd[sock].response + fd[sock].response_remaining;
-      else {
-        toread = MAX_BUFSIZE - fd[sock].response_remaining;
-        if (!toread) {
-          if (verbose_errors || verbose)
-            fprintf(stderr,"line exceeds buffer, unable to follow links\n");
-          toread = cbuffersize;
-          r = fd[sock].response;
-          fd[sock].response_remaining = 0;
-        } else
-          r = fd[sock].response + fd[sock].response_remaining;
-      }
-    } else
-      r = buf;
-    if (fast(sock,client_speed,fd[sock].bytes)) return 0;
-    if (fd[sock].bytes > abort_retry_bytes && 
-        (((now - fd[sock].start + 1)/HRTIME_SECOND) > abort_retry_secs) && 
-        !faster_than(sock,abort_retry_speed,fd[sock].bytes)) 
-    {
-      fd[sock].client_abort = 1;
-      fd[sock].keepalive = 0;
-      if (!urls_mode && !client_rate)
-        make_bfc_client(proxy_addr, proxy_port);
-      goto Ldone;
-    }
-    do {
-      err = read(sock, r, toread);
-    } while ((err == -1) && (errno == EINTR));
-    if (err < 0) {
-      if (errno == EAGAIN || errno == ENOTCONN) return 0;
-      if (errno == ECONNRESET) {
-        if (verbose || verbose_errors)
-          perror ("read");
-        goto Ldone;
-      }
-      panic_perror("read");
-    }
-    if (!err)
-      goto Ldone;
-    if (!verify_content(sock,buf,err)) {
-      if (verbose || verbose_errors)
-        printf("content verification error '%s'\n", fd[sock].base_url);
-      return read_response_error(sock);
-    }
-    total_proxy_response_body_bytes += err;
-    new_cbytes += err;
-    new_tbytes += err;
-    fd[sock].response_remaining += err;
-    fd[sock].bytes += err;
-    follow_links(sock);
-    if (fd[sock].length != INT_MAX)
-      fd[sock].length -= err;
-    fd[sock].active = ink_get_hrtime();
-    if (verbose) 
-      printf("read %d got %d togo %d %d %d\n", sock, err, fd[sock].length,
-             fd[sock].keepalive, fd[sock].drop_after_CL);
-  }
-  
-  if (fd[sock].length <= 0 && 
-      (fd[sock].keepalive > 0 || fd[sock].drop_after_CL))
-    goto Ldone;
-
-  return 0;
-  
-Ldone:
-  int ok = false;
-  if (!fd[sock].client_abort && 
-      !(server_abort_rate > 0) &&
-      fd[sock].length && fd[sock].length != INT_MAX) 
-  {
-    if (verbose || verbose_errors) 
-      printf("bad length %d wanted %d after %d ms: '%s'\n", 
-             fd[sock].response_length - fd[sock].length,
-             fd[sock].response_length,
-             (int)((ink_get_hrtime() - fd[sock].active)/HRTIME_MSECOND),
-             fd[sock].base_url);
-    return read_response_error(sock);
-  }
-  if (verbose) printf("read %d done\n", sock);
-  new_ops++;
-  double thislatency =((ink_get_hrtime() - fd[sock].start) / HRTIME_MSECOND);
-  latency += (int)thislatency;
-  lat_ops++;
-  if (fd[sock].keepalive > 0) {
-    fd[sock].reset();
-    put_ka(sock);
-    current_clients--;
-    if (urls_mode) {
-      undefer_url();
-      return 0;
-    }
-  } else
-    fd[sock].close();
-  if (!urls_mode && !client_rate)
-    make_bfc_client(proxy_addr, proxy_port);
-  return 0;
-}
-  
-static int write_request(int sock) {
-  int err = 0;
-  
-  do {
-    err = write(sock, fd[sock].req_header + fd[sock].req_pos, 
-                fd[sock].length - fd[sock].req_pos);
-  } while ((err == -1) && (errno == EINTR));
-  if (err <= 0) {
-    if (!err) {
-      if (verbose_errors) printf("write %d closed early\n", sock);
-      goto Lerror;
-    }
-    if (errno == EAGAIN || errno == ENOTCONN) return 0;
-    perror("write");
-    goto Lerror;
-  }
-  if (verbose) printf("write %d %d\n", sock, err);
-
-  new_tbytes += err;
-  total_client_request_bytes += err;
-  fd[sock].req_pos += err;
-  fd[sock].active = ink_get_hrtime();
-  
-  if (fd[sock].req_pos >= fd[sock].length) {
-    if (verbose) printf("write complete %d %d\n", sock, fd[sock].length);
-    fd[sock].req_pos = 0;
-    fd[sock].length = fd[sock].response_length;
-    poll_set(sock, read_response);
-  }
-  return 0;
-Lerror:
-  errors++;
-#ifndef RETRY_CLIENT_WRITE_ERRORS
-  if (!--nclients)
-    panic("no more clients\n");
-  return 1;
-#else
-  if (!urls_mode)
-    make_bfc_client(proxy_host, proxy_port);
-  fd[sock].close();
-  return 0;
-#endif
-}
-
-static int write_ftp_response(int sock) {
-  int err = 0;
-  
-  do {
-    err = write(sock, fd[sock].req_header + fd[sock].req_pos, 
-                fd[sock].length - fd[sock].req_pos);
-  } while ((err == -1) && (errno == EINTR));
-  
-  if (err <= 0) {
-    if (!err) {
-      if (verbose_errors) printf("write %d closed early\n", sock);
-      goto Lerror;
-    }
-    if (errno == EAGAIN || errno == ENOTCONN) return 0;
-    perror("write");
-    goto Lerror;
-  }
-  if (verbose) printf("write %d %d\n", sock, err);
-
-  new_tbytes += err;
-  fd[sock].req_pos += err;
-  
-  if (fd[sock].req_pos >= fd[sock].length) {
-    if (verbose) printf("write complete %d %d\n", sock, fd[sock].length);
-    fd[sock].req_pos = 0;
-    fd[sock].length = fd[sock].response_length;
-    poll_set(sock, read_ftp_request);
-  }
-  return 0;
-Lerror:
-  errors++;
-  return 1;
-}
-
-static int make_client (unsigned int addr, int port) {
-  struct linger lngr;
-
-  int sock = socket (PF_INET, SOCK_STREAM, 0);
-  if (sock < 0)
-    panic_perror ("socket");
-
-  if (fcntl (sock, F_SETFL, O_NONBLOCK) < 0)
-    panic_perror ("fcntl");
-
-  /* tweak buffer size so that remote end can't close connection too fast */
-
-#if 0
-  int bufsize = cbuffersize;
-  if (setsockopt(sock,SOL_SOCKET,SO_RCVBUF,
-                 (const char *)&bufsize,sizeof(bufsize)) < 0)
-    panic_perror("setsockopt");
-  if (setsockopt(sock,SOL_SOCKET,SO_SNDBUF,
-                 (const char *)&bufsize,sizeof(bufsize)) < 0)
-    panic_perror("setsockopt");
-#endif
-  int enable =1;
-  if (setsockopt(sock,IPPROTO_TCP,TCP_NODELAY,
-                 (const char *)&enable,sizeof(enable)) < 0)
-    panic_perror("setsockopt");
-
-  /* Tell the socket not to linger on exit */
-  lngr.l_onoff = 1;
-  lngr.l_linger = 0;
-  if (!ftp) {  // this causes problems for PORT ftp -- ewong
-    if (setsockopt (sock, SOL_SOCKET, SO_LINGER, (char*) &lngr, 
-                    sizeof (struct linger)) < 0) {
-      perror ("setsockopt");
-      exit (EXIT_FAILURE);
-    }
-  }
-
-  /* Give the socket a name. */
-  struct sockaddr_in name;
-  name.sin_family = AF_INET;
-  name.sin_port = htons(port);
-  name.sin_addr.s_addr = addr;
-  
-  if (verbose) printf("connecting to %u.%u.%u.%u:%d\n",
-                      ((unsigned char*)&addr)[0], ((unsigned char*)&addr)[1], 
-                      ((unsigned char*)&addr)[2], ((unsigned char*)&addr)[3],
-                      port);
-  
-  while (connect (sock, (struct sockaddr *) &name, sizeof (name)) < 0) {
-    if (errno == EINTR) continue;
-    if (errno == EINPROGRESS)
-      break;
-    if (verbose_errors) fprintf(stderr, "connect failed errno = %d\n", errno);
-    errors++;
-    return -1;
-  }
-
-  init_client(sock);
-  fd[sock].ip = addr;
-  clients++;
-  current_clients++;
-  new_clients++;
-  return sock;
-}
-
-static void make_bfc_client (unsigned int addr, int port) {
-  int sock = -1;
-  if (bandwidth_test && bandwidth_test_to_go-- <= 0)
-    return;
-  if (keepalive) 
-    sock = get_ka(addr);
-  if (sock < 0) {
-    sock = make_client(addr,port);
-    fd[sock].keepalive = keepalive;
-  } else {
-    init_client(sock);
-    current_clients++;
-    fd[sock].keepalive--;
-  }
-  if (sock<0) 
-    panic("unable to open client connection\n");
-  double h = drand48();
-  double dr = drand48();
-  if (zipf == 0.0) {
-    if (h < hitrate) {
-      dr = 1.0 + (floor(dr * hotset) / hotset);
-      fd[sock].response_length = gen_bfc_dist(dr - 1.0);
-    } else
-      fd[sock].response_length = gen_bfc_dist(dr);
-  } else {
-    unsigned long long int doc = get_zipf(dr);
-    // Some large randomish number.
-    unsigned long long int doc_len_int = doc * 0x14A4D0FB0E93E3A7LL;
-    unsigned long int x = doc_len_int;
-    double y = (double)x;
-    y /= 0x100000000LL;  // deterministic random number between 0 and 1.0
-    fd[sock].response_length = gen_bfc_dist(y);
-    dr = doc;
-  }
-  if (verbose) printf("gen_bfc_dist %d\n", fd[sock].response_length);
-  char eheaders[16384];
-  *eheaders = 0;
-  int nheaders = extra_headers;
-  if (nheaders>0) {
-    char * eh = eheaders;
-    if (!vary_user_agent) {
-      eh += sprintf(eh, "User-Agent: Mozilla/4.04 [en] (X11; I; Linux 2.0.31 i586)\r\n");
-      nheaders--;
-    }
-    if (nheaders>0)
-      eh += sprintf(eh, "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*\r\n");
-    while (--nheaders>0)
-      eh += sprintf(eh, "Extra-Header%d: a lot of junk for header %d\r\n",
-                    nheaders, nheaders);
-  }
-  char cookie[256];
-  *cookie = 0;
-  fd[sock].nalternate = (int)(alternates * drand48());
-  if (alternates)
-    if (!vary_user_agent)
-      sprintf(cookie, "Cookie: jtest-cookie-%d\r\n", fd[sock].nalternate);
-    else
-      sprintf(cookie, "User-Agent: jtest-browser-%d\r\n", fd[sock].nalternate);
-  char* extension;
-  switch (request_extension) {
-    case 1: extension = (char*)".html"; break;
-    case 2: extension = (char*)".jpeg"; break;
-    case 3: extension = (char*)"/"; break;
-    default:
-      extension = (char*)(compd_suite ? ".jpeg" : "");
-  }
-  char evo_str[20];
-  evo_str[0] = '\0';
-  if (evo_rate != 0.0) {
-    double evo_index = dr + (((double)now)/HRTIME_HOUR) * evo_rate;
-    sprintf(evo_str, ".%u", ((unsigned int)evo_index));
-  }
-  if (0 == hostrequest) {
-    sprintf(fd[sock].req_header, 
-            ftp ? 
-            "GET ftp://%s:%d/%12.10f/%d%s%s HTTP/1.0\r\n"
-            "%s"
-            "%s"
-            "%s"
-            "%s"
-            "\r\n" 
-            :
-            "GET http://%s:%d/%12.10f/%d%s%s HTTP/1.0\r\n"
-            "%s"
-            "%s"
-            "%s"
-            "%s"
-            "\r\n"
-            ,
-            local_host, server_port, dr,
-            fd[sock].response_length, evo_str, extension,
-            fd[sock].keepalive?"Proxy-Connection: Keep-Alive\r\n":"",
-            reload_rate > drand48() ? "Pragma: no-cache\r\n":"",
-            eheaders, cookie
-      );
-  } else if (1 == hostrequest) {
-    sprintf(fd[sock].req_header, 
-            "GET /%12.10f/%d%s%s HTTP/1.0\r\n"
-            "Host: %s:%d\r\n"
-            "%s"
-            "%s"
-            "%s"
-            "%s"
-            "\r\n",
-            dr, fd[sock].response_length, evo_str, extension,
-            local_host, server_port,
-            fd[sock].keepalive?"Connection: Keep-Alive\r\n":"",
-            reload_rate > drand48() ? "Pragma: no-cache\r\n":"",
-            eheaders, cookie);
-  } else if (2 == hostrequest) {
-    /* Send a non-proxy client request i.e. for Transparency testing */
-    sprintf(fd[sock].req_header, 
-            "GET /%12.10f/%d%s%s HTTP/1.0\r\n"
-            "%s"
-            "%s"
-            "%s"
-            "%s"
-            "\r\n",
-            dr, fd[sock].response_length, evo_str, extension,
-            fd[sock].keepalive?"Connection: Keep-Alive\r\n":"",
-            reload_rate > drand48() ? "Pragma: no-cache\r\n":"",
-            eheaders, 
-            cookie);
-  }
-  if (verbose) printf("request %d [%s]\n", sock, fd[sock].req_header);
-  fd[sock].length = strlen(fd[sock].req_header); 
-  {
-    char * s = fd[sock].req_header;
-    char * e = (char*)memchr(s, '\r', 512);
-    char * url = fd[sock].base_url;
-    memcpy(url,s,e-s);
-    url[e-s] = 0;
-    if (show_before) printf("%s\n", url);
-  }
-  if (show_headers) printf("Request to Proxy: {\n%s}\n", fd[sock].req_header);
-}
-
-#define RUNNING(_n) \
-  total_##_n = (((total_##_n * (average_over-1))/average_over) + new_##_n); \
-  running_##_n =  total_##_n / average_over; \
-  new_##_n = 0;
-
-#define RUNNING_AVG(_t,_n,_o) \
-  _t = _o?((_t * (average_over-1) + _n/_o) / average_over):_t; \
-  _n = 0;
-
-void interval_report() {
-  static int here = 0;
-  now = ink_get_hrtime();
-  if (!(here++ % 20))
-    printf(
- " con  new     ops   1B  lat      bytes/per     svrs  new  ops      total   time  err\n");
-  RUNNING(clients);
-  RUNNING_AVG(running_latency,latency,lat_ops); lat_ops = 0;
-  RUNNING_AVG(running_b1latency,b1latency,b1_ops); b1_ops = 0;
-  RUNNING(cbytes);
-  RUNNING(ops);
-  RUNNING(servers);
-  RUNNING(sops);
-  RUNNING(tbytes);
-  float t = (float)(now - start_time);
-  uint64_t per = current_clients ? running_cbytes / current_clients : 0;
-  printf("%4d %4d %7.1f %4d %4d %10" PRIu64"/%-6" PRIu64"  %4d %4d %4d  %9" PRIu64" %6.1f %4d\n",
-         current_clients, // clients, n_ka_cache,
-         running_clients,
-         running_ops, running_b1latency, running_latency,
-         running_cbytes, per,
-         running_servers, 
-         running_servers,
-         running_sops, running_tbytes, 
-         t/((float)HRTIME_SECOND),
-         errors);
-  if (is_done()) {
-    printf("Total Client Request Bytes:\t\t%" PRIu64"\n", total_client_request_bytes);
-    printf("Total Server Response Header Bytes:\t%" PRIu64"\n",
-           total_server_response_header_bytes);
-    printf("Total Server Response Body Bytes:\t%" PRIu64"\n",
-           total_server_response_body_bytes);
-    printf("Total Proxy Request Bytes:\t\t%" PRIu64"\n", total_proxy_request_bytes);
-    printf("Total Proxy Response Header Bytes:\t%" PRIu64"\n",
-           total_proxy_response_header_bytes);
-    printf("Total Proxy Response Body Bytes:\t%" PRIu64"\n",
-           total_proxy_response_body_bytes);
-  }
-}
-
-#define URL_HASH_ENTRIES     url_hash_entries
-#define BYTES_PER_ENTRY      3
-#define ENTRIES_PER_BUCKET   16
-#define OVERFLOW_ENTRIES     1024                           // many many
-
-#define BUCKETS              (URL_HASH_ENTRIES / ENTRIES_PER_BUCKET)
-#define BYTES_PER_BUCKET     (BYTES_PER_ENTRY * ENTRIES_PER_BUCKET)
-#define URL_HASH_BYTES       \
-            (BYTES_PER_ENTRY * (URL_HASH_ENTRIES + OVERFLOW_ENTRIES))
-#define CHANCE_OF_COLLISION  \
-            (((double)ENTRIES_PER_BUCKET)/((double)(1<<(8*3))))
-#define WANT_FILESIZE        0
-
-// NOTE: change to match BYTES_PER_ENTRY
-#define ENTRY_TAG(_x)               \
-  (((unsigned int)_x[0] << 16) +    \
-   ((unsigned int)_x[1] << 8) +     \
-   (unsigned int)_x[2])
-#define SET_ENTRY_TAG(_x,_t) \
-  _x[0] = _t >> 16;          \
-  _x[1] = (_t >> 8) & 0xFF;  \
-  _x[2] = _t & 0xFF;
-
-#define MASK_TAG(_x)  (_x & ((1U << (BYTES_PER_ENTRY * 8)))-1)
-
-#define BEGIN_HASH_LOOP                                            \
-    unsigned int bucket = (i % BUCKETS);                           \
-    unsigned int tag = MASK_TAG((unsigned int)(i / BUCKETS));      \
-    if (!tag) tag++;                                               \
-    unsigned char * base = bytes + bucket * BYTES_PER_BUCKET;      \
-    unsigned char * last = bytes + (bucket+1) * BYTES_PER_BUCKET - \
-                           BYTES_PER_ENTRY;                        \
-    (void)last;                                                    \
-                                                                   \
-    for (unsigned int x = 0 ; x < ENTRIES_PER_BUCKET ; x++) {      \
-      unsigned char * e = base + x * BYTES_PER_ENTRY;
-
-#define BEGIN_OVERFLOW_HASH_LOOP                                     \
-    for (unsigned int j = 0 ; j < ENTRIES_PER_BUCKET ; j++) {        \
-      unsigned char * e = base + (URL_HASH_ENTRIES + j) * BYTES_PER_ENTRY;
-
-#define END_HASH_LOOP \
-    }
-
-struct UrlHashTable {
-
-  unsigned int    numbytes;
-  unsigned char * bytes;
-  int fd;
-  
-  void zero() { memset(bytes, 0, numbytes); }
-
-  void alloc(unsigned int want);
-
-  void set(uint64_t i) {
-    BEGIN_HASH_LOOP {
-      if (!ENTRY_TAG(e)) {
-        SET_ENTRY_TAG(e,tag);
-        return;
-      }
-    } END_HASH_LOOP;
-
-    fprintf(stderr, "url hash table overflow: %X, %X\n", (int)(base-bytes), tag);
-
-    BEGIN_OVERFLOW_HASH_LOOP {
-      if (!ENTRY_TAG(e)) {
-        SET_ENTRY_TAG(e,tag);
-        return;
-      }
-    } END_HASH_LOOP;
-
-    ink_fatal(1, "overview entries overflow");
-  }
-
-  void clear(uint64_t i) {
-    BEGIN_HASH_LOOP {
-      if (ENTRY_TAG(e) == tag) {
-        if (e != last)
-          SET_ENTRY_TAG(e,ENTRY_TAG(last));
-        SET_ENTRY_TAG(last,0);
-        return;
-      }
-    } END_HASH_LOOP;
-
-    fprintf(stderr, "url hash table entry to clear not found: %X, %X\n", 
-            (int)(base-bytes), tag);
-  }
-
-  int is_set(uint64_t i) {
-    BEGIN_HASH_LOOP {
-      if (ENTRY_TAG(e) == tag)
-        return 1;
-    } END_HASH_LOOP;
-
-    if (ENTRY_TAG((last))) {
-      BEGIN_OVERFLOW_HASH_LOOP {
-        if (ENTRY_TAG(e) == tag)
-          return 1;
-      } END_HASH_LOOP;
-    }
-    return 0;
-  }
-  
-  UrlHashTable();
-
-  ~UrlHashTable();
-};
-UrlHashTable * uniq_urls = NULL;
-
-
-UrlHashTable::UrlHashTable() {
-  unsigned long len = 0;
-
-  if (!url_hash_entries)
-    return;
-
-  if (*url_hash_filename) {
-    ink_assert((fd = open(url_hash_filename,O_RDWR|O_CREAT, 0644))>0);
-    len = lseek(fd, 0, SEEK_END);
-  }
-
-  if (url_hash_entries > 0) {
-    // if they specify the number of entries round it up
-    url_hash_entries = 
-      (url_hash_entries + ENTRIES_PER_BUCKET - 1) & ~(ENTRIES_PER_BUCKET - 1);
-    numbytes = URL_HASH_BYTES;
-
-    // ensure it is either a new file or the correct size
-    if (len != 0 && len != numbytes) 
-      panic("specified size != file size\n");
-
-  } else {
-
-    // otherwise make sure the file is non-zero and then use its
-    // size as the size
-    if (!len) 
-      panic("zero size URL Hash Table\n");
-    if (len != URL_HASH_BYTES) {
-      fprintf(stderr, 
-              "FATAL: hash file length (%lu) != URL_HASH_BYTES (%lu)\n",
-              len, (unsigned long)URL_HASH_BYTES);
-      exit(1);
-    }
-    numbytes = len;
-  }
-
-  if (*url_hash_filename) {
-    ink_assert( !ftruncate(fd,numbytes) );
-    bytes = (unsigned char *)
-      mmap(NULL,numbytes,PROT_READ|PROT_WRITE,
-           MAP_SHARED|MAP_NORESERVE,
-           fd, 0);
-    if (bytes == (unsigned char*)MAP_FAILED || !bytes)
-      panic("unable to map URL Hash file\n");
-  } else {
-    bytes = (unsigned char *)malloc(numbytes);
-    ink_assert(bytes);
-    zero();
-  }
-} // UrlHashTable::UrlHashTable
-
-
-UrlHashTable::~UrlHashTable()
-{
-  ink_assert(!munmap((char*)bytes, numbytes));
-  ink_assert(!close(fd));
-} // UrlHashTable::~UrlHashTable
-
-
-int seen_it(char * url) {
-  if (!url_hash_entries)
-    return 0;
-  union {
-    unsigned char md5[16];
-    uint64_t i[2];
-  } u;
-  int l = 0;
-  char * para = strrchr(url, '#');
-  if (para) 
-    l = para - url;
-  else
-    l = strlen(url);
-  ink_code_md5((unsigned char*)url,l,u.md5);
-  uint64_t x = u.i[0] + u.i[1];
-  if (uniq_urls->is_set(x)) {
-    if (verbose) printf("YES: seen it '%s'\n", url);
-    return 1;
-  }
-  uniq_urls->set(x);
-  if (verbose) printf("NO: marked it '%s'\n", url);
-  return 0;
-}
-
-static int make_url_client(char * url,char * base_url, bool seen,
-                           bool unthrottled) 
-{
-  int iport = 80;
-  unsigned int ip = 0;
-  char hostname[80],curl[512];
-  char sche[8],host[512],port[10],path[512],frag[512],quer[512],para[512];
-  int xsche,xhost,xport,xpath,xfrag,xquer,xpar,rel,slash;
-
-  if (base_url) {
-    ink_web_canonicalize_url(base_url, url, curl, 512);
-    // hack for our own web server!
-    if (curl[strlen(curl)-1] == 13)
-      curl[strlen(curl)-1] = 0;
-    if (curl[strlen(curl)-1] == 12)
-      curl[strlen(curl)-1] = 0;
-  } else
-    strcpy(curl,url);
-  if (!seen && seen_it(curl))
-    return -1;
-  ink_web_decompose_url(curl,sche,host,port,path,frag,quer,para,
-                        &xsche,&xhost,&xport,&xpath,&xfrag,&xquer,
-                        &xpar,&rel,&slash);
-  if (follow_same) {
-    if (!xhost || strcasecmp(host,current_host)) {
-      if (verbose) printf("skipping %s\n",curl);
-      return -1;
-    }
-  }
-  if (!unthrottled && throttling_connections()) {
-    defer_url(curl);
-    return -1;
-  }
-  if (proxy_port) {
-    iport = proxy_port;
-    ip = proxy_addr;
-  } else {
-    if (xport) iport = atoi(port);
-    if (!xhost) { 
-      if (verbose) fprintf(stderr, "bad url '%s'\n", curl); 
-      return -1;
-    }
-    ip = get_addr(host);
-    if ((int)ip == -1) { 
-      if (verbose || verbose_errors)
-        fprintf(stderr, "bad host '%s'\n", host); 
-      return -1;
-    }
-  }
-  int sock = -1;
-  if (keepalive) 
-    sock = get_ka(ip);
-  if (sock < 0) {
-    sock = make_client(ip, iport);
-    fd[sock].keepalive = keepalive;
-  } else {
-    init_client(sock);
-    current_clients++;
-    fd[sock].keepalive--;
-  }
-  if (sock < 0)
-    panic("cannot make client\n");
-  char eheaders[16384];
-  *eheaders = 0;
-  int nheaders = extra_headers;
-  memset(&eheaders,0,16384);
-  if (nheaders>0) {
-    char * eh = eheaders;
-    if (!vary_user_agent) {
-      eh += sprintf(eh, "User-Agent: Mozilla/4.04 [en] (X11; I; Linux 2.0.31 i586)\r\n");
-      nheaders--;
-    }
-    if (nheaders>0)
-      eh += sprintf(eh, "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*\r\n");
-    while (--nheaders>0)
-      eh += sprintf(eh, "Extra-Header%d: a lot of junk for header %d\r\n",
-                    nheaders, nheaders);
-  }
-  if (proxy_port)
-    sprintf(fd[sock].req_header, "GET %s HTTP/1.0\r\n"
-            "%s"
-            "%s"
-            "Accept: */*\r\n"
-            "%s"
-            "\r\n", 
-            curl,
-            reload_rate > drand48() ? "Pragma: no-cache\r\n":"",
-            fd[sock].keepalive?"Proxy-Connection: Keep-Alive\r\n":"",eheaders);
-  else 
-    sprintf(fd[sock].req_header, "GET /%s%s%s%s%s HTTP/1.0\r\n"
-            "Host: %s\r\n"
-            "%s"
-            "%s"
-            "Accept: */*\r\n"
-            "%s"
-            "\r\n", 
-            path,xquer?"?":"",quer,xpar?";":"",para,host,
-            reload_rate > drand48() ? "Pragma: no-cache\r\n":"",
-            fd[sock].keepalive?"Connection: Keep-Alive\r\n":"",eheaders);
-
-  if (verbose) printf("curl = '%s'\n",curl);
-  if (show_before) printf("%s\n", curl);
-  if (urlsdump_fp) fprintf(urlsdump_fp, "%s\n", curl);
-  if (show_headers) printf("Request to Proxy: {\n%s}\n",fd[sock].req_header);
-  char * epath = path + strlen(path);
-  fd[sock].binary = 
-    !strncasecmp(path - 3, "gif", 3) || !strncasecmp(path - 3, "jpg", 3);
-  fd[sock].response_length = 0;
-  fd[sock].length = strlen(fd[sock].req_header);
-  if (!fd[sock].response)
-    fd[sock].response = (char*)malloc(MAX_BUFSIZE);
-  strcpy(fd[sock].base_url, curl);
-  return sock;
-}
-
-static FILE * get_defered_urls(FILE * fp) {
-  char url[512];
-  while (fgets(url,512,fp)) {
-    if (n_defered_urls > MAX_DEFERED_URLS -2)
-      return NULL;
-    char * e = (char*)memchr(url,'\n', 512);
-    if (e) *e = 0;
-    make_url_client(url);
-  }
-  return fp;
-}
-
-int main(int argc, char *argv[]) {
-  /* for QA -- we want to be able to tail an output file
-   * during execution "nohup jtest -P pxy -p prt &"
-   */
-  setvbuf(stdout, (char*) NULL, _IOLBF, 0);
-
-  fd = (FD*)malloc(MAXFDS * sizeof(FD));
-  memset(fd,0,MAXFDS*sizeof(FD));
-  process_args(argument_descriptions, n_argument_descriptions, argv);
-  if (version) {
-    show_version();
-    exit(0);
-  }
-  if (!drand_seed) 
-    srand48((long)time(NULL));
-  else
-    srand48((long)drand_seed);
-  if (zipf != 0.0)
-    build_zipf();
-  int max_fds = max_limit_fd();
-  if (verbose) printf ("maximum of %d connections\n",max_fds);
-  signal(SIGPIPE,SIG_IGN);      
-  start_time = now = ink_get_hrtime();
-  
-  urls_mode = n_file_arguments || *urls_file;
-  nclients = client_rate? 0 : nclients;
-
-  if (!local_host[0])
-    ink_assert(!gethostname(local_host,80));
-  local_addr = get_addr(local_host);
-  if (!proxy_host[0])
-    strcpy(proxy_host, local_host);
-  if (proxy_port) {
-    proxy_addr = get_addr(proxy_host);
-  }
-
-  if (!urls_mode) {
-    if (compd_port) {
-      build_response();
-      open_server(compd_port, accept_compd);
-    } else {
-      if (!server_port)
-        server_port = proxy_port + 1000;
-      build_response();
-      if (!only_clients) {
-        for (int retry = 0 ; retry < 20 ; retry++) {
-          server_fd = open_server(server_port + retry, accept_read);
-          if (server_fd < 0) {
-            if (server_fd == -EADDRINUSE) { 
-              printf("here\n");
-              continue;
-            }
-            panic_perror("open_server");
-          }
-          break;
-        }
-      }
-      bandwidth_test_to_go = bandwidth_test;
-      if (!only_server) {
-        if (proxy_port) {
-          for (int i = 0 ; i < nclients ; i++)
-            make_bfc_client(proxy_addr, proxy_port);
-        }
-      }
-    }
-  } else {
-    if (check_content)
-      build_response();
-    follow = follow_arg;
-    follow_same = follow_same_arg;
-    uniq_urls = new UrlHashTable;
-    defered_urls = (char**)malloc(sizeof(char*) * MAX_DEFERED_URLS);
-    average_over = 1;
-    if (*urlsdump_file) {
-      urlsdump_fp = fopen(urlsdump_file,"w");
-      if (!urlsdump_fp)
-        panic_perror("fopen urlsdump file");
-    }
-    if (*urls_file) {
-      FILE * fp = fopen(urls_file,"r");
-      if (!fp)
-        panic_perror("fopen urls file");
-      if (get_defered_urls(fp))
-        fclose(fp);
-      else
-        urls_fp = fp;
-    }
-    int i;
-    for (i = 0; i < n_file_arguments; i++) {
-      char sche[8],host[512],port[10],path[512],frag[512],quer[512],para[512];
-      int xsche,xhost,xport,xpath,xfrag,xquer,xpar,rel,slash;
-      ink_web_decompose_url(file_arguments[i],sche,host,port,
-                            path,frag,quer,para,
-                            &xsche,&xhost,&xport,&xpath,&xfrag,&xquer,
-                            &xpar,&rel,&slash);
-      if (xhost) {
-        strcpy(current_host,host);
-      }
-    }
-    for (i = 0; i < n_file_arguments ; i++)
-      make_url_client(file_arguments[i]);
-  }
-
-  int t = now / HRTIME_SECOND;
-  int tclient = now / HRTIME_SECOND;
-  int start = now / HRTIME_SECOND;
-  while (1) {
-    if (poll_loop()) break;
-    int t2 = now / HRTIME_SECOND;
-    if (urls_fp && n_defered_urls < MAX_DEFERED_URLS - DEFERED_URLS_BLOCK - 2){
-      if (get_defered_urls(urls_fp)) {
-        fclose(urls_fp);
-        urls_fp = NULL;
-      }
-    }
-    if ((!urls_mode || client_rate) && interval && t + interval <= t2) {
-      t = t2;
-      interval_report();
-    }
-    if (t2 != tclient) {
-      for (int i = 0; i < client_rate * (t2 - tclient) ; i++)
-        if (!urls_mode)
-          make_bfc_client(proxy_addr, proxy_port);
-        else
-          undefer_url(true);
-      tclient = t2;
-    }
-    if (test_time)
-      if (t2 - start > test_time)
-        done();
-    if (is_done())
-      done();
-  }
-
-  return 0;
-}
-
-
-/*---------------------------------------------------------------------------*
-  
-  int ink_web_decompose_url(...)
-  
-  This function takes an input URL in src_url and splits it into its
-  component parts, including a scheme, host, port, path, fragment,
-  query, and parameters. you must pass in buffers for each of these.
-  If you pass in a NULL pointer for any of these, it will not be
-  return

<TRUNCATED>

[25/51] git commit: Fix bug with 128 bit compare and swap.

Posted by zw...@apache.org.
Fix bug with 128 bit compare and swap.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/4a090831
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/4a090831
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/4a090831

Branch: refs/heads/3.3.x
Commit: 4a0908314acb301f1e9eb691bbcd8d956e86c321
Parents: 57ffdf5
Author: jplevyak@apache.org <jp...@apache.org>
Authored: Thu Mar 21 10:10:16 2013 -0700
Committer: John Plevyak <jp...@acm.org>
Committed: Thu Mar 21 10:10:16 2013 -0700

----------------------------------------------------------------------
 lib/ts/ink_queue.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4a090831/lib/ts/ink_queue.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_queue.h b/lib/ts/ink_queue.h
index 6ac9945..20fbf9a 100644
--- a/lib/ts/ink_queue.h
+++ b/lib/ts/ink_queue.h
@@ -72,7 +72,7 @@ extern "C"
 #endif
 
 #if TS_HAS_128BIT_CAS
-#define INK_QUEUE_LD(dst,src) *((__int128_t*)&(dst)) = *((__int128_t*)&(src))
+#define INK_QUEUE_LD(dst,src) *(__int128_t*)&(dst) = __sync_fetch_and_add((__int128_t*)&(src), 0)
 #else
 #define INK_QUEUE_LD(dst,src) INK_QUEUE_LD64(dst,src)
 #endif


[38/51] git commit: TS-1742: Re-enable 16 byte compare and swap by default

Posted by zw...@apache.org.
TS-1742: Re-enable 16 byte compare and swap by default


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/70e10888
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/70e10888
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/70e10888

Branch: refs/heads/3.3.x
Commit: 70e10888506cdd41fa8eae86a2878cfb8a71f0fa
Parents: 18aadb0
Author: James Peach <jp...@apache.org>
Authored: Mon Mar 25 12:32:31 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Mon Mar 25 12:32:31 2013 -0700

----------------------------------------------------------------------
 configure.ac |   52 +++++++++++++++++++++++++---------------------------
 1 files changed, 25 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/70e10888/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 4561409..fe1648a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1108,33 +1108,31 @@ AC_SUBST(need_union_semun)
 AC_MSG_CHECKING(for 128bit CAS support)
 AC_LANG_PUSH([C++])
 
-dnl TS_TRY_COMPILE_NO_WARNING([],[
-dnl     __int128_t x = 0;
-dnl     __sync_bool_compare_and_swap(&x,0,10);
-dnl   ], [
-dnl     AC_MSG_RESULT(yes)
-dnl     has_128bit_cas=1
-dnl   ], [
-dnl       dnl If 128bit CAS fails, try again with the -mcx16 option. GCC needs this;
-dnl       dnl clang doesn't; icc is unknown but presumed sane.
-dnl     __saved_CXXFLAGS="${CXXFLAGS}"
-dnl     TS_ADDTO(CXXFLAGS, [-mcx16])
-dnl     TS_TRY_COMPILE_NO_WARNING([],[
-dnl         __int128_t x = 0;
-dnl         __sync_bool_compare_and_swap(&x,0,10);
-dnl       ], [
-dnl         AC_MSG_RESULT(yes)
-dnl         has_128bit_cas=1
-dnl         dnl Keep CFLAGS and CXXFLAGS in sync.
-dnl         TS_ADDTO(CFLAGS, [-mcx16])
-dnl       ], [
-dnl         AC_MSG_RESULT(no)
-dnl         has_128bit_cas=0
-dnl         CXXFLAGS="${__saved_CXXFLAGS}"
-dnl     ])
-dnl ])
-
-has_128bit_cas=0
+TS_TRY_COMPILE_NO_WARNING([],[
+    __int128_t x = 0;
+    __sync_bool_compare_and_swap(&x,0,10);
+  ], [
+    AC_MSG_RESULT(yes)
+    has_128bit_cas=1
+  ], [
+      dnl If 128bit CAS fails, try again with the -mcx16 option. GCC needs this;
+      dnl clang doesn't; icc is unknown but presumed sane.
+    __saved_CXXFLAGS="${CXXFLAGS}"
+    TS_ADDTO(CXXFLAGS, [-mcx16])
+    TS_TRY_COMPILE_NO_WARNING([],[
+        __int128_t x = 0;
+        __sync_bool_compare_and_swap(&x,0,10);
+      ], [
+        AC_MSG_RESULT(yes)
+        has_128bit_cas=1
+        dnl Keep CFLAGS and CXXFLAGS in sync.
+        TS_ADDTO(CFLAGS, [-mcx16])
+      ], [
+        AC_MSG_RESULT(no)
+        has_128bit_cas=0
+        CXXFLAGS="${__saved_CXXFLAGS}"
+    ])
+])
 
 AC_LANG_POP
 AC_SUBST(has_128bit_cas)


[44/51] git commit: [TS-1780] Fix Debuntu build with hardening flags

Posted by zw...@apache.org.
[TS-1780] Fix Debuntu build with hardening flags


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/7b6a4dd1
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/7b6a4dd1
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/7b6a4dd1

Branch: refs/heads/3.3.x
Commit: 7b6a4dd1070bad7b69f6d82e53833dd82b27fea0
Parents: ca7a84e
Author: Igor Galić <i....@brainsware.org>
Authored: Tue Mar 26 23:32:11 2013 +0100
Committer: Igor Galić <i....@brainsware.org>
Committed: Tue Mar 26 23:32:11 2013 +0100

----------------------------------------------------------------------
 CHANGES                                  |    2 ++
 iocore/eventsystem/UnixEventProcessor.cc |    2 +-
 2 files changed, 3 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b6a4dd1/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 90b631b..b319e6a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
   Changes with Apache Traffic Server 3.3.2
 
+  *) [TS-1780] Fix Debuntu build with hardening flags
+
   *) [TS-1623, TS-1625] Fixes for logging where the host name was not handled
     correctly because it was not in the URL.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b6a4dd1/iocore/eventsystem/UnixEventProcessor.cc
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/UnixEventProcessor.cc b/iocore/eventsystem/UnixEventProcessor.cc
index 1efdf0b..663217a 100644
--- a/iocore/eventsystem/UnixEventProcessor.cc
+++ b/iocore/eventsystem/UnixEventProcessor.cc
@@ -201,7 +201,7 @@ EventProcessor::start(int n_event_threads)
         set_cpu(&cpuset, cpu);
         len += snprintf(debug_message + len, sizeof(debug_message) - len, " %d", cpu);
       }
-      Debug("iocore_thread", debug_message);
+      Debug("iocore_thread", "%s", debug_message);
       if (!bind_cpu(&cpuset, tid)){
         Error("%s, failed with errno: %d", debug_message, errno);
       }


[12/51] git commit: TS-1758 Remove unused overviewPage aggregation functions.

Posted by zw...@apache.org.
TS-1758 Remove unused overviewPage aggregation functions.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/3ceb8a20
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/3ceb8a20
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/3ceb8a20

Branch: refs/heads/3.3.x
Commit: 3ceb8a20b965c137bb1da95fd181bd76b3ae352f
Parents: 11bfc1e
Author: Yunkai Zhang <yu...@gmail.com>
Authored: Tue Mar 19 14:15:04 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Tue Mar 19 14:15:04 2013 -0600

----------------------------------------------------------------------
 mgmt/web2/WebOverview.cc |  581 -----------------------------------------
 mgmt/web2/WebOverview.h  |   15 -
 2 files changed, 0 insertions(+), 596 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3ceb8a20/mgmt/web2/WebOverview.cc
----------------------------------------------------------------------
diff --git a/mgmt/web2/WebOverview.cc b/mgmt/web2/WebOverview.cc
index 792a896..83493f3 100644
--- a/mgmt/web2/WebOverview.cc
+++ b/mgmt/web2/WebOverview.cc
@@ -720,543 +720,6 @@ overviewPage::readFloat(const char *nodeName, const char *name, bool * found)
   return r;
 }
 
-// void overviewPage::agCachePercentFree()
-//
-//  Updates proxy.cluster.cache.percent_free
-//
-void
-overviewPage::agCachePercentFree()
-{
-  MgmtInt bTotal;
-  MgmtInt bFree;
-  MgmtFloat pFree;
-
-  clusterSumInt("proxy.node.cache.bytes_total", &bTotal);
-  clusterSumInt("proxy.node.cache.bytes_free", &bFree);
-
-  if (bTotal <= 0) {
-    pFree = 0.0;
-  } else {
-    pFree = (MgmtFloat) ((double) bFree / (double) bTotal);
-  }
-
-  ink_assert(varSetFloat("proxy.cluster.cache.percent_free", pFree));
-}
-
-// void overviewPage::agCacheHitRate()
-//
-void
-overviewPage::agCacheHitRate()
-{
-  static ink_hrtime last_set_time = 0;
-  const ink_hrtime window = 10 * HRTIME_SECOND; // update every 10 seconds
-  static StatTwoIntSamples cluster_hit_count = { "proxy.node.cache_total_hits", 0, 0, 0, 0 };
-  static StatTwoIntSamples cluster_hit_mem_count = { "proxy.node.cache_total_hits_mem", 0, 0, 0, 0 };
-  static StatTwoIntSamples cluster_miss_count = { "proxy.node.cache_total_misses", 0, 0, 0, 0 };
-  static const char *cluster_hit_count_name = "proxy.cluster.cache_total_hits_avg_10s";
-  static const char *cluster_hit_mem_count_name = "proxy.cluster.cache_total_hits_mem_avg_10s";
-  static const char *cluster_miss_count_name = "proxy.cluster.cache_total_misses_avg_10s";
-
-  MgmtIntCounter totalHits = 0;
-  MgmtIntCounter totalMemHits = 0;
-  MgmtIntCounter totalMisses = 0;
-  MgmtIntCounter totalAccess = 0;
-  MgmtFloat hitRate = 0.00;
-  MgmtFloat hitMemRate = 0.00;
-
-  // get current time and delta to work with
-  ink_hrtime current_time = ink_get_hrtime();
-  //  ink_hrtime delta = current_time - last_set_time;
-
-  ///////////////////////////////////////////////////////////////
-  // if enough time expired, or first time, or wrapped around: //
-  //  (1) scroll current value into previous value             //
-  //  (2) calculate new current values                         //
-  //  (3) only if proper time expired, set derived values      //
-  ///////////////////////////////////////////////////////////////
-  if (((current_time - last_set_time) > window) ||      // sufficient elapsed time
-      (last_set_time == 0) ||   // first time
-      (last_set_time > current_time))   // wrapped around
-  {
-    ////////////////////////////////////////
-    // scroll values for cluster Hit/Miss //
-    ///////////////////////////////////////
-    cluster_hit_count.previous_time = cluster_hit_count.current_time;
-    cluster_hit_count.previous_value = cluster_hit_count.current_value;
-
-    cluster_miss_count.previous_time = cluster_miss_count.current_time;
-    cluster_miss_count.previous_value = cluster_miss_count.current_value;
-
-    //////////////////////////
-    // calculate new values //
-    //////////////////////////
-    cluster_hit_count.current_value = -10000;
-    cluster_hit_count.current_time = ink_get_hrtime();
-    // TODO: Should we check return value?
-    clusterSumInt(cluster_hit_count.lm_record_name, &(cluster_hit_count.current_value));
-
-    cluster_miss_count.current_value = -10000;
-    cluster_miss_count.current_time = ink_get_hrtime();
-    // TODO: Should we check return value?
-    clusterSumInt(cluster_miss_count.lm_record_name, &(cluster_miss_count.current_value));
-
-    ////////////////////////////////////////////////
-    // if not initial or wrap, set derived values //
-    ////////////////////////////////////////////////
-    if ((current_time - last_set_time) > window) {
-      RecInt num_hits = 0;
-      RecInt num_hits_mem = 0;
-      RecInt num_misses = 0;
-      RecInt diff = 0;
-      RecInt total = 0;
-      // generate time window deltas and sum
-      diff = cluster_hit_count.diff_value();
-      varSetInt(cluster_hit_count_name, diff);
-      num_hits = diff;
-
-      diff = cluster_hit_mem_count.diff_value();
-      varSetInt(cluster_hit_mem_count_name, diff);
-      num_hits_mem = diff;
-
-      diff = cluster_miss_count.diff_value();
-      varSetInt(cluster_miss_count_name, diff);
-      num_misses = diff;
-
-      total = num_hits + num_misses;
-      if (total == 0)
-        hitRate = 0.00;
-      else {
-        hitRate = (MgmtFloat) ((double) num_hits / (double) total);
-        hitMemRate = (MgmtFloat) ((double) num_hits_mem / (double) total);
-      }
-
-      // Check if more than one cluster node
-      MgmtInt num_nodes;
-      varIntFromName("proxy.process.cluster.nodes", &num_nodes);
-      if (1 == num_nodes) {
-        // Only one node , so grab local value
-        varFloatFromName("proxy.node.cache_hit_ratio_avg_10s", &hitRate);
-        varFloatFromName("proxy.node.cache_hit_mem_ratio_avg_10s", &hitMemRate);
-      }
-      // new stat
-      varSetFloat("proxy.cluster.cache_hit_ratio_avg_10s", hitRate);
-      varSetFloat("proxy.cluster.cache_hit_mem_ratio_avg_10s", hitMemRate);
-    }
-    /////////////////////////////////////////////////
-    // done with a cycle, update the last_set_time //
-    /////////////////////////////////////////////////
-    last_set_time = current_time;
-  }
-  // Deal with Lifetime stats
-  clusterSumInt("proxy.node.cache_total_hits", &totalHits);
-  clusterSumInt("proxy.node.cache_total_hits_mem", &totalMemHits);
-  clusterSumInt("proxy.node.cache_total_misses", &totalMisses);
-  totalAccess = totalHits + totalMisses;
-
-  if (totalAccess != 0) {
-    hitRate = (MgmtFloat) ((double) totalHits / (double) totalAccess);
-    hitMemRate = (MgmtFloat) ((double) totalMemHits / (double) totalAccess);
-  }
-  // new stats
-  ink_assert(varSetFloat("proxy.cluster.cache_hit_ratio", hitRate));
-  ink_assert(varSetFloat("proxy.cluster.cache_hit_mem_ratio", hitMemRate));
-  ink_assert(varSetInt("proxy.cluster.cache_total_hits", totalHits));
-  ink_assert(varSetInt("proxy.cluster.cache_total_hits_mem", totalMemHits));
-  ink_assert(varSetInt("proxy.cluster.cache_total_misses", totalMisses));
-}
-
-// void overviewPage::agHostDBHitRate()
-//
-//   Updates proxy.cluster.hostdb.hit_ratio
-//
-void
-overviewPage::agHostdbHitRate()
-{
-  static ink_hrtime last_set_time = 0;
-  const ink_hrtime window = 10 * HRTIME_SECOND; // update every 10 seconds
-  static StatTwoIntSamples cluster_hostdb_total_lookups = { "proxy.node.hostdb.total_lookups", 0, 0, 0, 0 };
-  static StatTwoIntSamples cluster_hostdb_hits = { "proxy.node.hostdb.total_hits", 0, 0, 0, 0 };
-  static const char *cluster_hostdb_total_lookups_name = "proxy.cluster.hostdb.total_lookups_avg_10s";
-  static const char *cluster_hostdb_hits_name = "proxy.cluster.hostdb.total_hits_avg_10s";
-
-  RecInt hostDBtotal = 0;
-  RecInt hostDBhits = 0;
-  //  RecInt hostDBmisses = 0;
-  RecInt dnsTotal = 0;
-  RecFloat hitRate = 0.00;
-
-  // get current time and delta to work with
-  ink_hrtime current_time = ink_get_hrtime();
-  //  ink_hrtime delta = current_time - last_set_time;
-
-  ///////////////////////////////////////////////////////////////
-  // if enough time expired, or first time, or wrapped around: //
-  //  (1) scroll current value into previous value             //
-  //  (2) calculate new current values                         //
-  //  (3) only if proper time expired, set derived values      //
-  ///////////////////////////////////////////////////////////////
-  if (((current_time - last_set_time) > window) ||      // sufficient elapsed time
-      (last_set_time == 0) ||   // first time
-      (last_set_time > current_time))   // wrapped around
-  {
-    ////////////////////////////////////////
-    // scroll values for cluster DNS //
-    ///////////////////////////////////////
-    cluster_hostdb_total_lookups.previous_time = cluster_hostdb_total_lookups.current_time;
-    cluster_hostdb_total_lookups.previous_value = cluster_hostdb_total_lookups.current_value;
-
-    cluster_hostdb_hits.previous_time = cluster_hostdb_hits.current_time;
-    cluster_hostdb_hits.previous_value = cluster_hostdb_hits.current_value;
-
-    //////////////////////////
-    // calculate new values //
-    //////////////////////////
-    cluster_hostdb_total_lookups.current_value = -10000;
-    cluster_hostdb_total_lookups.current_time = ink_get_hrtime();
-    // TODO: Should we check return value?
-    clusterSumInt(cluster_hostdb_total_lookups.lm_record_name, &(cluster_hostdb_total_lookups.current_value));
-
-    cluster_hostdb_hits.current_value = -10000;
-    cluster_hostdb_hits.current_time = ink_get_hrtime();
-    // TODO: Should we check return value?
-    clusterSumInt(cluster_hostdb_hits.lm_record_name, &(cluster_hostdb_hits.current_value));
-
-    ////////////////////////////////////////////////
-    // if not initial or wrap, set derived values //
-    ////////////////////////////////////////////////
-    if ((current_time - last_set_time) > window) {
-      MgmtInt num_total_lookups = 0;
-      MgmtInt num_hits = 0;
-      MgmtInt diff = 0;
-
-      // generate time window deltas and sum
-      diff = cluster_hostdb_total_lookups.diff_value();
-      varSetInt(cluster_hostdb_total_lookups_name, diff);
-      num_total_lookups = diff;
-
-      diff = cluster_hostdb_hits.diff_value();
-      varSetInt(cluster_hostdb_hits_name, diff);
-      num_hits = diff;
-
-      if (num_total_lookups == 0)
-        hitRate = 0.00;
-      else
-        hitRate = (MgmtFloat) ((double) num_hits / (double) num_total_lookups);
-
-      // Check if more than one cluster node
-      MgmtInt num_nodes;
-      varIntFromName("proxy.process.cluster.nodes", &num_nodes);
-      if (1 == num_nodes) {
-        // Only one node , so grab local value
-        varFloatFromName("proxy.node.hostdb.hit_ratio_avg_10s", &hitRate);
-      }
-      // new stat
-      varSetFloat("proxy.cluster.hostdb.hit_ratio_avg_10s", hitRate);
-    }
-    /////////////////////////////////////////////////
-    // done with a cycle, update the last_set_time //
-    /////////////////////////////////////////////////
-    last_set_time = current_time;
-  }
-
-  // Deal with Lifetime stats
-  clusterSumInt("proxy.node.hostdb.total_lookups", &hostDBtotal);
-  clusterSumInt("proxy.node.dns.total_dns_lookups", &dnsTotal);
-  clusterSumInt("proxy.node.hostdb.total_hits", &hostDBhits);
-
-  if (hostDBtotal != 0) {
-    if (hostDBhits < 0) {
-      hostDBhits = 0;
-      mgmt_log(stderr, "truncating hit_ratio from %d to 0\n", hostDBhits);
-    }
-    hitRate = (MgmtFloat) ((double) hostDBhits / (double) hostDBtotal);
-  } else {
-    hitRate = 0.0;
-  }
-
-  ink_assert(hitRate >= 0.0);
-  ink_assert(varSetFloat("proxy.cluster.hostdb.hit_ratio", hitRate));
-}
-
-// void overviewPage::agBandwidthHitRate()
-//
-void
-overviewPage::agBandwidthHitRate()
-{
-  static ink_hrtime last_set_time = 0;
-  const ink_hrtime window = 10 * HRTIME_SECOND; // update every 10 seconds
-  static StatTwoIntSamples cluster_ua_total_bytes = { "proxy.node.user_agent_total_bytes", 0, 0, 0, 0 };
-  static StatTwoIntSamples cluster_os_total_bytes = { "proxy.node.origin_server_total_bytes", 0, 0, 0, 0 };
-  static const char *cluster_ua_total_bytes_name = "proxy.cluster.user_agent_total_bytes_avg_10s";
-  static const char *cluster_os_total_bytes_name = "proxy.cluster.origin_server_total_bytes_avg_10s";
-
-  MgmtInt bytes;
-  MgmtInt UA_total = 0;         // User Agent total
-  MgmtInt OSPP_total = 0;       // Origin Server and Parent Proxy(?)
-  MgmtFloat hitRate;
-  MgmtInt totalHits = 0;
-  MgmtInt cacheOn = 1;          // on by default
-  MgmtInt httpCacheOn;
-
-  // See if cache is on
-  ink_assert(varIntFromName("proxy.config.http.cache.http", &httpCacheOn));
-  cacheOn = httpCacheOn;
-
-  // Get total cluster hits first, only calculate bandwith if > 0
-  varIntFromName("proxy.cluster.cache_total_hits", &totalHits);
-
-  // User Agent
-
-  // HTTP
-  varIntFromName("proxy.cluster.http.user_agent_total_request_bytes", &bytes);
-  UA_total += bytes;
-  varIntFromName("proxy.cluster.http.user_agent_total_response_bytes", &bytes);
-  UA_total += bytes;
-
-  // HTTP
-  varIntFromName("proxy.cluster.http.origin_server_total_request_bytes", &bytes);
-  OSPP_total += bytes;
-  varIntFromName("proxy.cluster.http.origin_server_total_response_bytes", &bytes);
-  OSPP_total += bytes;
-  varIntFromName("proxy.cluster.http.parent_proxy_total_request_bytes", &bytes);
-  OSPP_total += bytes;
-  varIntFromName("proxy.cluster.http.parent_proxy_total_response_bytes", &bytes);
-  OSPP_total += bytes;
-
-  // Special negative bandwidth scenario is treated here
-  // See (Bug INKqa03094) and Ag_Bytes() in 'StatAggregation.cc'
-  bool setBW = true;
-  if (UA_total != 0 && totalHits && cacheOn) {
-    hitRate = ((double) UA_total - (double) OSPP_total) / (double) UA_total;
-    if (hitRate < 0.0)
-      setBW = false;            // negative bandwidth scenario....
-  } else {
-    hitRate = 0.0;
-  }
-
-  if (setBW) {
-    ink_assert(varSetFloat("proxy.cluster.bandwidth_hit_ratio", hitRate));
-  }
-  // get current time and delta to work with
-  ink_hrtime current_time = ink_get_hrtime();
-  //  ink_hrtime delta = current_time - last_set_time;
-
-  ///////////////////////////////////////////////////////////////
-  // if enough time expired, or first time, or wrapped around: //
-  //  (1) scroll current value into previous value             //
-  //  (2) calculate new current values                         //
-  //  (3) only if proper time expired, set derived values      //
-  ///////////////////////////////////////////////////////////////
-  if (((current_time - last_set_time) > window) ||      // sufficient elapsed time
-      (last_set_time == 0) ||   // first time
-      (last_set_time > current_time))   // wrapped around
-  {
-    ////////////////////////////////////////
-    // scroll values for node UA/OS bytes //
-    ///////////////////////////////////////
-    cluster_ua_total_bytes.previous_time = cluster_ua_total_bytes.current_time;
-    cluster_ua_total_bytes.previous_value = cluster_ua_total_bytes.current_value;
-
-    cluster_os_total_bytes.previous_time = cluster_os_total_bytes.current_time;
-    cluster_os_total_bytes.previous_value = cluster_os_total_bytes.current_value;
-
-    //////////////////////////
-    // calculate new values //
-    //////////////////////////
-    cluster_ua_total_bytes.current_value = -10000;
-    cluster_ua_total_bytes.current_time = ink_get_hrtime();
-    // TODO: Should we check return value?
-    clusterSumInt(cluster_ua_total_bytes.lm_record_name, &(cluster_ua_total_bytes.current_value));
-
-    cluster_os_total_bytes.current_value = -10000;
-    cluster_os_total_bytes.current_time = ink_get_hrtime();
-    // TODO: Should we check return value?
-    clusterSumInt(cluster_os_total_bytes.lm_record_name, &(cluster_os_total_bytes.current_value));
-
-    ////////////////////////////////////////////////
-    // if not initial or wrap, set derived values //
-    ////////////////////////////////////////////////
-    if ((current_time - last_set_time) > window) {
-      RecInt num_ua_total = 0;
-      RecInt num_os_total = 0;
-      RecInt diff = 0;
-
-      // generate time window deltas and sum
-      diff = cluster_ua_total_bytes.diff_value();
-      varSetInt(cluster_ua_total_bytes_name, diff);
-      num_ua_total = diff;
-
-      diff = cluster_os_total_bytes.diff_value();
-      varSetInt(cluster_os_total_bytes_name, diff);
-      num_os_total = diff;
-
-      if (num_ua_total == 0 || (num_ua_total < num_os_total))
-        hitRate = 0.00;
-      else
-        hitRate = (MgmtFloat) (((double) num_ua_total - (double) num_os_total) / (double) num_ua_total);
-
-      // Check if more than one cluster node
-      MgmtInt num_nodes;
-      varIntFromName("proxy.process.cluster.nodes", &num_nodes);
-      if (1 == num_nodes) {
-        // Only one node , so grab local value
-        varFloatFromName("proxy.node.bandwidth_hit_ratio_avg_10s", &hitRate);
-      }
-      // new stat
-      varSetFloat("proxy.cluster.bandwidth_hit_ratio_avg_10s", hitRate);
-    }
-    /////////////////////////////////////////////////
-    // done with a cycle, update the last_set_time //
-    /////////////////////////////////////////////////
-    last_set_time = current_time;
-  }
-
-}                               // end overviewPage::agBandwidthHitRate()
-
-// int overviewPage::clusterSumInt(char* nodeVar, MgmtInt* sum)
-//
-//   Sums nodeVar for every up node in the cluster and stores the
-//     sum in *sum.  Returns the number of nodes summed over
-//
-//   CALLEE MUST HOLD this->accessLock
-//
-int
-overviewPage::clusterSumInt(const char *nodeVar, RecInt * sum)
-{
-  int numUsed = 0;
-  int numHosts_local = sortRecords.getNumEntries();
-  overviewRecord *current;
-  bool found;
-
-  ink_assert(sum != NULL);
-  *sum = 0;
-
-  for (int i = 0; i < numHosts_local; i++) {
-    current = (overviewRecord *) sortRecords[i];
-    if (current->up == true) {
-      numUsed++;
-      *sum += current->readInteger(nodeVar, &found);
-      if (found == false) {
-      }
-    }
-  }
-
-  return numUsed;
-}
-
-//
-//   Updates proxy.cluster.current_client_connections
-//   Updates proxy.cluster.current_server_connections
-//   Updates proxy.cluster.current_cache_connections
-//
-void
-overviewPage::agConnections()
-{
-  MgmtInt client_conn = 0;
-  MgmtInt server_conn = 0;
-  MgmtInt cache_conn = 0;
-
-  clusterSumInt("proxy.node.current_client_connections", &client_conn);
-  clusterSumInt("proxy.node.current_server_connections", &server_conn);
-  clusterSumInt("proxy.node.current_cache_connections", &cache_conn);
-
-  ink_assert(varSetInt("proxy.cluster.current_client_connections", client_conn));
-  ink_assert(varSetInt("proxy.cluster.current_server_connections", server_conn));
-  ink_assert(varSetInt("proxy.cluster.current_cache_connections", cache_conn));
-}
-
-// void overviewPage::clusterAgInt(const char* clusterVar, const char* nodeVar)
-//
-//   Updates clusterVar with the sum of nodeVar for every node in the
-//      cluster
-//   CALLEE MUST HOLD this->accessLock
-//
-void
-overviewPage::clusterAgInt(const char *clusterVar, const char *nodeVar)
-{
-  int numUsed = 0;
-  MgmtInt sum = 0;
-
-  numUsed = clusterSumInt(nodeVar, &sum);
-  if (numUsed > 0) {
-    ink_assert(varSetInt(clusterVar, sum));
-  }
-}
-
-void
-overviewPage::clusterAgIntScale(const char *clusterVar, const char *nodeVar, double factor)
-{
-  int numUsed = 0;
-  RecInt sum = 0;
-
-  numUsed = clusterSumInt(nodeVar, &sum);
-  if (numUsed > 0) {
-    sum = (int) (sum * factor);
-    ink_assert(varSetInt(clusterVar, sum));
-  }
-}
-
-// int overviewPage::clusterSumCounter(char* nodeVar, MgmtIntCounter* sum)
-//
-//   Sums nodeVar for every up node in the cluster and stores the
-//     sum in *sum.  Returns the number of nodes summed over
-//
-//   CALLEE MUST HOLD this->accessLock
-//
-int
-overviewPage::clusterSumCounter(char *nodeVar, RecInt * sum)
-{
-  int numUsed = 0;
-  int numHosts_local = sortRecords.getNumEntries();
-  overviewRecord *current;
-  bool found;
-
-  ink_assert(sum != NULL);
-  *sum = 0;
-
-  for (int i = 0; i < numHosts_local; i++) {
-    current = (overviewRecord *) sortRecords[i];
-    if (current->up == true) {
-      numUsed++;
-      *sum += current->readCounter(nodeVar, &found);
-      if (found == false) {
-      }
-    }
-  }
-
-  return numUsed;
-}
-
-// int overviewPage::clusterSumFloat(char* nodeVar, MgmtFloat* sum)
-//
-//   Sums nodeVar for every up node in the cluster and stores the
-//     sum in *sum.  Returns the number of nodes summed over
-//
-//   CALLEE MUST HOLD this->accessLock
-//
-int
-overviewPage::clusterSumFloat(const char *nodeVar, RecFloat * sum)
-{
-  int numUsed = 0;
-  int numHosts_local = sortRecords.getNumEntries();
-  overviewRecord *current;
-  bool found;
-
-  ink_assert(sum != NULL);
-  *sum = 0.00;
-
-  for (int i = 0; i < numHosts_local; i++) {
-    current = (overviewRecord *) sortRecords[i];
-    if (current->up == true) {
-      numUsed++;
-      *sum += current->readFloat(nodeVar, &found);
-      if (found == false) {
-      }
-    }
-  }
-  return numUsed;
-}
-
 // int overviewPage::clusterSumData(RecDataT varType, const char* nodeVar,
 //                                  RecData* sum)
 //
@@ -1291,50 +754,6 @@ overviewPage::clusterSumData(RecDataT varType, const char *nodeVar,
   return numUsed;
 }
 
-// void overviewPage::clusterAgFloat(const char* clusterVar, const char* nodeVar)
-//
-//
-//   Sums nodeVar for every up node in the cluster and stores the
-//     sum in sumVar
-//
-//   CALLEE MUST HOLD this->accessLock
-//
-void
-overviewPage::clusterAgFloat(const char *clusterVar, const char *nodeVar)
-{
-  int numUsed = 0;
-  MgmtFloat sum = 0;
-
-  numUsed = clusterSumFloat(nodeVar, &sum);
-
-  if (numUsed > 0) {
-    ink_assert(varSetFloat(clusterVar, sum));
-  }
-}
-
-int
-overviewPage::varClusterFloatFromName(char *nodeVar, RecFloat * sum)
-{
-  ink_mutex_acquire(&accessLock);
-  int status = 0;
-  RecDataT varDataType;
-  RecInt tempInt = 0;
-  RecFloat tempFloat = 0.0;
-
-  RecGetRecordDataType(nodeVar, &varDataType);
-
-  if (varDataType == RECD_INT) {
-    status = clusterSumInt(nodeVar, &tempInt);
-    tempFloat = (RecFloat) tempInt;
-  } else if (varDataType == RECD_FLOAT) {
-    status = clusterSumFloat(nodeVar, &tempFloat);
-  }
-
-  *sum = tempFloat;
-  ink_mutex_release(&accessLock);
-  return (status);
-}
-
 int
 overviewPage::varClusterDataFromName(RecDataT varType, char *nodeVar,
                                      RecData *sum)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3ceb8a20/mgmt/web2/WebOverview.h
----------------------------------------------------------------------
diff --git a/mgmt/web2/WebOverview.h b/mgmt/web2/WebOverview.h
index 94b48a2..5992755 100644
--- a/mgmt/web2/WebOverview.h
+++ b/mgmt/web2/WebOverview.h
@@ -119,7 +119,6 @@ public:
   MgmtString readString(const char *nodeName, const char *name, bool * found = NULL);
   void addSelfRecord();
 
-  int varClusterFloatFromName(char *, MgmtFloat *);
   int varClusterDataFromName(RecDataT varType, char *nodeVar, RecData *sum);
 
 private:
@@ -141,21 +140,7 @@ private:
   ExpandingArray sortRecords;   // A second, sorted container for nodeRecords
   int numHosts;                 // number of peers we know about including ourself
 
-  // Functions to do cluster aggregation
-  //
-  void clusterAgInt(const char *clustVar, const char *nodeVar);
-  void clusterAgIntScale(const char *clustVar, const char *nodeVar, double factor);
-#define MB_SCALE (1/(1024*1024.0))
-  int clusterSumInt(const char *nodeVar, MgmtInt * sum);
-  int clusterSumCounter(char *nodeVar, MgmtInt * sum);
-  void clusterAgFloat(const char *clusterVar, const char *nodeVar);
-  int clusterSumFloat(const char *nodeVar, MgmtFloat * sum);
   int clusterSumData(RecDataT varType, const char *nodeVar, RecData *sum);
-  void agHostdbHitRate();
-  void agCacheHitRate();
-  void agCachePercentFree();
-  void agBandwidthHitRate();
-  void agConnections();
 };
 
 extern overviewPage *overviewGenerator; // global handle to overiewPage?


[27/51] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/trafficserver

Posted by zw...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/trafficserver


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/5a34bbd7
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/5a34bbd7
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/5a34bbd7

Branch: refs/heads/3.3.x
Commit: 5a34bbd7e5030494ce12285331d63ca582d1f051
Parents: 4a09083 bd8fd4f
Author: John Plevyak <jp...@apache.org>
Authored: Thu Mar 21 10:37:08 2013 -0700
Committer: John Plevyak <jp...@acm.org>
Committed: Thu Mar 21 10:37:08 2013 -0700

----------------------------------------------------------------------
 configure.ac |   52 +++++++++++++++++++++++++++-------------------------
 1 files changed, 27 insertions(+), 25 deletions(-)
----------------------------------------------------------------------



[39/51] git commit: Remove unused Windows NT code

Posted by zw...@apache.org.
Remove unused Windows NT code


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/0afb8946
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/0afb8946
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/0afb8946

Branch: refs/heads/3.3.x
Commit: 0afb8946a70cdc7addfc639c3720c262231f50a2
Parents: 70e1088
Author: James Peach <jp...@apache.org>
Authored: Mon Mar 25 12:49:01 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Mon Mar 25 12:49:01 2013 -0700

----------------------------------------------------------------------
 iocore/aio/NTAIO.cc |  168 ----------------------------------------------
 1 files changed, 0 insertions(+), 168 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0afb8946/iocore/aio/NTAIO.cc
----------------------------------------------------------------------
diff --git a/iocore/aio/NTAIO.cc b/iocore/aio/NTAIO.cc
deleted file mode 100644
index 0140f2f..0000000
--- a/iocore/aio/NTAIO.cc
+++ /dev/null
@@ -1,168 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @section license License
-
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
- */
-
-/****************************************************************************
-
-  NTAIO.cc
-
-
- ****************************************************************************/
-
-#include "P_AIO.h"
-
-extern Continuation *aio_err_callbck;
-
-// AIO Stats
-extern uint64_t aio_num_read;
-extern uint64_t aio_bytes_read;
-extern uint64_t aio_num_write;
-extern uint64_t aio_bytes_written;
-
-NTIOCompletionPort aio_completion_port(1);
-
-
-static inline void
-init_op_sequence(AIOCallback * op, int opcode)
-{
-
-  // zero aio_result's and init opcodes
-  AIOCallback *cur_op;
-  for (cur_op = op; cur_op; cur_op = cur_op->then) {
-    cur_op->aio_result = 0;
-    cur_op->aiocb.aio_lio_opcode = opcode;
-    // set the last op to point to the first op
-    if (cur_op->then == NULL)
-      ((AIOCallbackInternal *) cur_op)->first = op;
-  }
-}
-
-static inline void
-cache_op(AIOCallback * op)
-{
-
-  DWORD bytes_trans;
-
-  // make op continuation share op->action's mutex
-  op->mutex = op->action.mutex;
-
-  // construct a continuation to handle the io completion
-  NTCompletionEvent *ce = NTCompletionEvent_alloc(op);
-  OVERLAPPED *overlapped = ce->get_overlapped();
-  overlapped->Offset = (unsigned long) (op->aiocb.aio_offset & 0xFFFFFFFF);
-  overlapped->OffsetHigh = (unsigned long)
-    (op->aiocb.aio_offset >> 32) & 0xFFFFFFFF;
-  // do the io
-  BOOL ret;
-  switch (op->aiocb.aio_lio_opcode) {
-  case LIO_READ:
-    ret = ReadFile((HANDLE) op->aiocb.aio_fildes,
-                   op->aiocb.aio_buf, (unsigned long) op->aiocb.aio_nbytes, &bytes_trans, overlapped);
-    break;
-  case LIO_WRITE:
-    ret = WriteFile((HANDLE) op->aiocb.aio_fildes,
-                    op->aiocb.aio_buf, (unsigned long) op->aiocb.aio_nbytes, &bytes_trans, overlapped);
-    break;
-  default:
-    ink_debug_assert(!"unknown aio_lio_opcode");
-  }
-  DWORD lerror = GetLastError();
-  if (ret == FALSE && lerror != ERROR_IO_PENDING) {
-
-    op->aio_result = -((int) lerror);
-    eventProcessor.schedule_imm(op);
-  }
-
-}
-
-int
-ink_aio_read(AIOCallback * op)
-{
-  init_op_sequence(op, LIO_READ);
-  cache_op(op);
-  return 1;
-}
-
-int
-ink_aio_write(AIOCallback * op)
-{
-  init_op_sequence(op, LIO_WRITE);
-  cache_op(op);
-  return 1;
-}
-
-
-struct AIOMissEvent:Continuation
-{
-  AIOCallback *cb;
-
-  int mainEvent(int event, Event * e)
-  {
-    if (!cb->action.cancelled)
-      cb->action.continuation->handleEvent(AIO_EVENT_DONE, cb);
-    delete this;
-      return EVENT_DONE;
-  }
-
-  AIOMissEvent(ProxyMutex * amutex, AIOCallback * acb)
-  : Continuation(amutex), cb(acb)
-  {
-    SET_HANDLER(&AIOMissEvent::mainEvent);
-  }
-};
-
-int
-AIOCallbackInternal::io_complete(int event, void *data)
-{
-
-  int lerror;
-  NTCompletionEvent *ce = (NTCompletionEvent *) data;
-
-  // if aio_result is set, the original Read/Write call failed
-  if (!aio_result) {
-    lerror = ce->lerror;
-    aio_result = lerror ? -lerror : ce->_bytes_transferred;
-  }
-  // handle io errors
-  if ((lerror != 0) && aio_err_callbck) {
-    // schedule aio_err_callbck to be called-back
-    // FIXME: optimization, please... ^_^
-    AIOCallback *op = NEW(new AIOCallbackInternal());
-    op->aiocb.aio_fildes = aiocb.aio_fildes;
-    op->action = aio_err_callbck;
-    eventProcessor.schedule_imm(NEW(new AIOMissEvent(op->action.mutex, op)));
-  } else {
-    ink_debug_assert(ce->_bytes_transferred == aiocb.aio_nbytes);
-  }
-
-  if (then) {
-    // more op's in this sequence
-    cache_op(then);
-  } else {
-    // we're done! callback action
-    if (!first->action.cancelled) {
-      first->action.continuation->handleEvent(AIO_EVENT_DONE, first);
-    }
-  }
-
-  return 0;
-}


[31/51] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/trafficserver

Posted by zw...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/trafficserver


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/f41323e0
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/f41323e0
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/f41323e0

Branch: refs/heads/3.3.x
Commit: f41323e010480a7e206c680b3fc3b06ac8a4675a
Parents: 5a34bbd 1a2ebcc
Author: John Plevyak <jp...@apache.org>
Authored: Thu Mar 21 13:53:59 2013 -0700
Committer: John Plevyak <jp...@acm.org>
Committed: Thu Mar 21 13:53:59 2013 -0700

----------------------------------------------------------------------
 CHANGES                                   |    3 +
 iocore/eventsystem/P_UnixEventProcessor.h |    4 +-
 mgmt/Main.cc                              |   18 --
 mgmt/cluster/ClusterCom.cc                |   12 +-
 mgmt/cluster/VMap.cc                      |  341 ++----------------------
 mgmt/cluster/VMap.h                       |   13 +-
 proxy/config/vaddrs.config.default        |   11 +-
 7 files changed, 46 insertions(+), 356 deletions(-)
----------------------------------------------------------------------



[41/51] git commit: Added TS-1754

Posted by zw...@apache.org.
Added TS-1754


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/da8ca56e
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/da8ca56e
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/da8ca56e

Branch: refs/heads/3.3.x
Commit: da8ca56ec9cf4e368c2ca4291bfb859bc9e736ff
Parents: 0e599c3
Author: Leif Hedstrom <zw...@apache.org>
Authored: Mon Mar 25 15:41:16 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Mar 25 15:41:16 2013 -0600

----------------------------------------------------------------------
 CHANGES |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/da8ca56e/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 760d532..5559ab0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1754] Remove unecessary wWarnings from stats evaluation.
+   Author: Yunkai Zhang.
+
   *) [TS-1724] Add tool to compare records.config files to contrib
    Author: Mark Harrison <ma...@mivok.net>
 


[09/51] git commit: Fix remaining TSPluginRegister return value tests

Posted by zw...@apache.org.
Fix remaining TSPluginRegister return value tests


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/369346ef
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/369346ef
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/369346ef

Branch: refs/heads/3.3.x
Commit: 369346ef97e3d28f496f0e107b220bda72793469
Parents: 5cbc212
Author: James Peach <jp...@apache.org>
Authored: Mon Mar 18 15:38:00 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Mon Mar 18 15:38:05 2013 -0700

----------------------------------------------------------------------
 doc/sdk/TSPluginInit.3                             |    2 +-
 doc/sdk/TSTrafficServerVersionGet.3                |    2 +-
 example/prefetch/test-hns-plugin.c                 |    2 +-
 .../experimental/buffer_upload/buffer_upload.cc    |    2 +-
 .../custom_redirect/custom_redirect.cc             |    2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/369346ef/doc/sdk/TSPluginInit.3
----------------------------------------------------------------------
diff --git a/doc/sdk/TSPluginInit.3 b/doc/sdk/TSPluginInit.3
index 8994fc0..a040c8a 100644
--- a/doc/sdk/TSPluginInit.3
+++ b/doc/sdk/TSPluginInit.3
@@ -76,7 +76,7 @@ TSPluginInit (int argc, const char *argv[])
       info.vendor_name = "MyCompany";
       info.support_email = "ts-api-support@MyCompany.com";
 
-      if (!TSPluginRegister (TS_SDK_VERSION_2_0 , &info)) {
+      if (TSPluginRegister (TS_SDK_VERSION_2_0 , &info) != TS_SUCCESS) {
          TSError ("Plugin registration failed. \n");
       }
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/369346ef/doc/sdk/TSTrafficServerVersionGet.3
----------------------------------------------------------------------
diff --git a/doc/sdk/TSTrafficServerVersionGet.3 b/doc/sdk/TSTrafficServerVersionGet.3
index 63a1483..da41211 100644
--- a/doc/sdk/TSTrafficServerVersionGet.3
+++ b/doc/sdk/TSTrafficServerVersionGet.3
@@ -93,7 +93,7 @@ TSPluginInit (int argc, const char *argv[])
     info.vendor_name = "MyCompany";
     info.support_email = "ts-api-support@MyCompany.com";
 
-    if (!TSPluginRegister(TS_SDK_VERSION_2_0 , &info)) {
+    if (TSPluginRegister(TS_SDK_VERSION_2_0 , &info) != TS_SUCCESS) {
         TSError("Plugin registration failed. \n");
     }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/369346ef/example/prefetch/test-hns-plugin.c
----------------------------------------------------------------------
diff --git a/example/prefetch/test-hns-plugin.c b/example/prefetch/test-hns-plugin.c
index 5c344e7..fa5b01e 100644
--- a/example/prefetch/test-hns-plugin.c
+++ b/example/prefetch/test-hns-plugin.c
@@ -194,7 +194,7 @@ TSPluginInit(int argc, const char *argv[])
   plugin_info.vendor_name = "MyCompany";
   plugin_info.support_email = "ts-api-support@MyCompany.com";
 
-  if (!TSPluginRegister(TS_SDK_VERSION_3_0, &plugin_info)) {
+  if (TSPluginRegister(TS_SDK_VERSION_3_0, &plugin_info) != TS_SUCCESS) {
     TSError("Plugin registration failed.\n");
     return;
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/369346ef/plugins/experimental/buffer_upload/buffer_upload.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/buffer_upload/buffer_upload.cc b/plugins/experimental/buffer_upload/buffer_upload.cc
index 8595c9c..847c519 100644
--- a/plugins/experimental/buffer_upload/buffer_upload.cc
+++ b/plugins/experimental/buffer_upload/buffer_upload.cc
@@ -1239,7 +1239,7 @@ TSPluginInit(int argc, const char *argv[])
     uconfig->use_disk_buffer = 0;
   }
 
-  if (!TSPluginRegister(TS_SDK_VERSION_2_0, &info)) {
+  if (TSPluginRegister(TS_SDK_VERSION_2_0, &info) != TS_SUCCESS) {
     TSError("Plugin registration failed.");
   }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/369346ef/plugins/experimental/custom_redirect/custom_redirect.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/custom_redirect/custom_redirect.cc b/plugins/experimental/custom_redirect/custom_redirect.cc
index bd5e193..b09217c 100644
--- a/plugins/experimental/custom_redirect/custom_redirect.cc
+++ b/plugins/experimental/custom_redirect/custom_redirect.cc
@@ -160,7 +160,7 @@ TSPluginInit (int argc, const char *argv[])
         redirect_url_header_len = strlen(redirect_url_header);
     }
     /*
-    if (!TSPluginRegister (TS_SDK_VERSION_5_2 , &info)) {
+    if (TSPluginRegister (TS_SDK_VERSION_5_2 , &info) != TS_SUCCESS) {
         TSError ("[custom_redirect] Plugin registration failed.");
     }
     */


[50/51] git commit: TS-1764 Unify MAX/MIN definitions (in ink_defs.h). Also clean up the checks of gcc prior to v3.x (which we no longer support.

Posted by zw...@apache.org.
TS-1764 Unify MAX/MIN definitions (in ink_defs.h). Also clean up the checks of gcc prior to v3.x (which we no longer support.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/04610736
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/04610736
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/04610736

Branch: refs/heads/3.3.x
Commit: 046107366aba453b5fc05142110140a0621ac714
Parents: 8a4f583 965c40f
Author: Leif Hedstrom <zw...@apache.org>
Authored: Sat Mar 30 18:48:26 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Sat Mar 30 18:48:26 2013 -0600

----------------------------------------------------------------------
 CHANGES                                    |    3 ++
 example/remap/remap.cc                     |   16 +------------
 example/thread-pool/psi.c                  |    3 +-
 iocore/net/NetVCTest.cc                    |    7 -----
 iocore/net/P_InkBulkIO.h                   |    7 -----
 lib/ts/ink_defs.h                          |   18 ++++++++++++--
 lib/ts/ink_unused.h                        |   29 +---------------------
 mgmt/cli/cliAppInit.cc                     |    6 +----
 plugins/experimental/geoip_acl/lulu.h      |   14 +++--------
 plugins/experimental/header_rewrite/lulu.h |   11 +-------
 plugins/experimental/spdy/protocol.cc      |    6 +---
 plugins/header_filter/lulu.h               |   12 ++-------
 proxy/InkAPITestTool.cc                    |    3 --
 proxy/MuxVC.cc                             |    3 --
 proxy/PluginVC.cc                          |    5 ----
 proxy/api/ts/ts.h.in                       |    4 ---
 proxy/http/HttpTunnel.cc                   |    7 -----
 proxy/logstats.cc                          |    6 ----
 18 files changed, 34 insertions(+), 126 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/04610736/CHANGES
----------------------------------------------------------------------
diff --cc CHANGES
index 024f515,06974cf..7a4eea4
--- a/CHANGES
+++ b/CHANGES
@@@ -2,18 -2,9 +2,21 @@@
    Changes with Apache Traffic Server 3.3.2
  
  
 +  *) [TS-1790] authproxy should accept 2xx as authorization success
 +
 +  *) [TS-1780] Fix Debuntu build with hardening flags
 +
 +  *) [TS-1623, TS-1625] Fixes for logging where the host name was not handled
 +    correctly because it was not in the URL.
 +
 +  *) [TS-1754] Remove unecessary wWarnings from stats evaluation.
 +   Author: Yunkai Zhang.
 +
 +  *) [TS-1169] Eliminate bogus asserts. Credits to Conan Wang.
 +
+   *) [TS-1764] Unify MAX/MIN definitions (in ink_defs.h). Also clean
 -   up the checks of gcc prior to v3.x (which we no long support).
++   up the checks of gcc prior to v3.x (which we no longer support).
+ 
    *) [TS-1724] Add tool to compare records.config files to contrib
     Author: Mark Harrison <ma...@mivok.net>
  


[34/51] git commit: Revert automake subdir-objects

Posted by zw...@apache.org.
Revert automake subdir-objects

This is supposed to be the automake default in the future, but it
breaks 'make distclean' for our build. Each time I fix one instance
of this breakage another one pops up.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/02eb936f
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/02eb936f
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/02eb936f

Branch: refs/heads/3.3.x
Commit: 02eb936fed2e90c7b9db47c958b3754876a966a5
Parents: da19639
Author: James Peach <jp...@apache.org>
Authored: Fri Mar 22 15:40:43 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Fri Mar 22 15:40:43 2013 -0700

----------------------------------------------------------------------
 configure.ac           |    2 +-
 mgmt/Makefile.am       |    2 +-
 mgmt/utils/Makefile.am |    2 --
 3 files changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/02eb936f/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 19d2a39..4561409 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,7 +40,7 @@ AC_PREREQ([2.59])
 AC_CONFIG_AUX_DIR([build/aux])
 AC_CONFIG_SRCDIR([proxy/Main.cc])
 AC_CONFIG_MACRO_DIR([build])
-AM_INIT_AUTOMAKE([-Wall -Werror foreign no-installinfo no-installman subdir-objects 1.9.2])
+AM_INIT_AUTOMAKE([-Wall -Werror foreign no-installinfo no-installman 1.9.2])
 AC_CONFIG_HEADERS([lib/ts/ink_autoconf.h])
 
 # Configure with --disable-silent-rules to get verbose output. For more info, see

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/02eb936f/mgmt/Makefile.am
----------------------------------------------------------------------
diff --git a/mgmt/Makefile.am b/mgmt/Makefile.am
index a5b8c0d..ea47373 100644
--- a/mgmt/Makefile.am
+++ b/mgmt/Makefile.am
@@ -18,7 +18,6 @@
 #  limitations under the License.
 
 SUBDIRS = cluster preparse tools utils web2 stats api cli
-DIST_SUBDIRS = $(SUBDIRS)
 
 # This is for traffic_manager only (local manager)
 AM_CPPFLAGS = $(ink_with_modules_local) \
@@ -71,6 +70,7 @@ libmgmt_p_a_SOURCES = \
 
 traffic_manager_SOURCES = \
   ../proxy/Error.cc \
+  ../proxy/DiagsConfig.cc \
   AddConfigFilesHere.cc \
   Alarms.cc \
   Alarms.h \

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/02eb936f/mgmt/utils/Makefile.am
----------------------------------------------------------------------
diff --git a/mgmt/utils/Makefile.am b/mgmt/utils/Makefile.am
index 7829b01..a03ecb0 100644
--- a/mgmt/utils/Makefile.am
+++ b/mgmt/utils/Makefile.am
@@ -40,8 +40,6 @@ noinst_LIBRARIES = libutils_lm.a libutils_p.a
 
 libutils_lm_a_CPPFLAGS = $(ink_with_modules_local) $(AM_CPPFLAGS)
 libutils_lm_a_SOURCES = \
-  ../../lib/ts/MatcherUtils.cc \
-  ../../proxy/DiagsConfig.cc \
   EnvBlock.cc \
   EnvBlock.h \
   ExpandingArray.cc \


[23/51] git commit: Fix the out-of-tree build

Posted by zw...@apache.org.
Fix the out-of-tree build


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/8accf5e5
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/8accf5e5
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/8accf5e5

Branch: refs/heads/3.3.x
Commit: 8accf5e5d78e8238254d1b97924da60a023bdf29
Parents: 097996a
Author: James Peach <jp...@apache.org>
Authored: Thu Mar 21 09:37:34 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu Mar 21 09:37:34 2013 -0700

----------------------------------------------------------------------
 mgmt/Makefile.am |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8accf5e5/mgmt/Makefile.am
----------------------------------------------------------------------
diff --git a/mgmt/Makefile.am b/mgmt/Makefile.am
index 291daaf..a5b8c0d 100644
--- a/mgmt/Makefile.am
+++ b/mgmt/Makefile.am
@@ -70,7 +70,7 @@ libmgmt_p_a_SOURCES = \
   RecordsConfig.h
 
 traffic_manager_SOURCES = \
-  $(top_srcdir)/proxy/Error.cc \
+  ../proxy/Error.cc \
   AddConfigFilesHere.cc \
   Alarms.cc \
   Alarms.h \


[24/51] git commit: FreeBSD doesn't need a gethostname declaration

Posted by zw...@apache.org.
FreeBSD doesn't need a gethostname declaration


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/57ffdf5f
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/57ffdf5f
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/57ffdf5f

Branch: refs/heads/3.3.x
Commit: 57ffdf5fc41cfb30aded815adf29d1ae50941015
Parents: 8accf5e
Author: James Peach <jp...@apache.org>
Authored: Thu Mar 21 09:58:29 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu Mar 21 09:58:29 2013 -0700

----------------------------------------------------------------------
 tools/jtest/jtest.cc |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/57ffdf5f/tools/jtest/jtest.cc
----------------------------------------------------------------------
diff --git a/tools/jtest/jtest.cc b/tools/jtest/jtest.cc
index f4e3a24..1361ae3 100644
--- a/tools/jtest/jtest.cc
+++ b/tools/jtest/jtest.cc
@@ -76,10 +76,6 @@ typedef int64_t ink_hrtime;
 
 #define MAX_URL_LEN 1024
 
-#if defined(freebsd)
-extern "C" int gethostname(char *name, int namelen);
-#endif
-
 //
 // Compilation Options
 //


[05/51] git commit: Fix cmpxchg16b configure test

Posted by zw...@apache.org.
Fix cmpxchg16b configure test


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/a51a4395
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/a51a4395
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/a51a4395

Branch: refs/heads/3.3.x
Commit: a51a4395dc3ed642750ccb316ce312ee12af95eb
Parents: a9b6516
Author: James Peach <jp...@apache.org>
Authored: Sat Mar 16 20:11:10 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Sat Mar 16 20:11:10 2013 -0700

----------------------------------------------------------------------
 build/common.m4 |   12 ++++--------
 configure.ac    |    8 +++-----
 2 files changed, 7 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a51a4395/build/common.m4
----------------------------------------------------------------------
diff --git a/build/common.m4 b/build/common.m4
index df08fc1..7c37129 100644
--- a/build/common.m4
+++ b/build/common.m4
@@ -171,6 +171,9 @@ dnl is false if the code doesn't compile cleanly.  For compilers
 dnl where it is not known how to activate a "fail-on-error" mode,
 dnl it is undefined which of the sets of actions will be run.
 dnl
+dnl We actually always try to link the resulting program, since gcc has
+dnl a nasty habit of compiling code that cannot subsequently be linked.
+dnl
 AC_DEFUN([TS_TRY_COMPILE_NO_WARNING],
 [ats_save_CFLAGS=$CFLAGS
  CFLAGS="$CFLAGS $CFLAGS_WARN"
@@ -178,14 +181,7 @@ AC_DEFUN([TS_TRY_COMPILE_NO_WARNING],
    CFLAGS="$CFLAGS -Werror"
  fi
  CFLAGS=$(echo $CFLAGS | sed -e 's/^-w$//' -e 's/^-w //' -e 's/ -w$//' -e 's/ -w / /')
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([
-  [#include "confdefs.h"
-  ]
-  [[$1]]
-  [int main(int argc, const char *const *argv) {]
-  [[$2]]
-  [   return 0; }]])],
-  [$3], [$4])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([$1], [$2])], [$3], [$4])
  CFLAGS=$ats_save_CFLAGS
 ])
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a51a4395/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 2db8c46..fe1648a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1108,8 +1108,7 @@ AC_SUBST(need_union_semun)
 AC_MSG_CHECKING(for 128bit CAS support)
 AC_LANG_PUSH([C++])
 
-TS_TRY_COMPILE_NO_WARNING(
-  [],[
+TS_TRY_COMPILE_NO_WARNING([],[
     __int128_t x = 0;
     __sync_bool_compare_and_swap(&x,0,10);
   ], [
@@ -1117,11 +1116,10 @@ TS_TRY_COMPILE_NO_WARNING(
     has_128bit_cas=1
   ], [
       dnl If 128bit CAS fails, try again with the -mcx16 option. GCC needs this;
-      dnl clang doesn't; icc isunknown but presumed sane.
+      dnl clang doesn't; icc is unknown but presumed sane.
     __saved_CXXFLAGS="${CXXFLAGS}"
     TS_ADDTO(CXXFLAGS, [-mcx16])
-    TS_TRY_COMPILE_NO_WARNING(
-      [],[
+    TS_TRY_COMPILE_NO_WARNING([],[
         __int128_t x = 0;
         __sync_bool_compare_and_swap(&x,0,10);
       ], [


[26/51] git commit: TS-1746: disable 128bit compare and swap

Posted by zw...@apache.org.
TS-1746: disable 128bit compare and swap

Disable the use of 128bit compare and swap that was introduced in
TS-1742. That change was causing crashes in the freelist.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/bd8fd4fb
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/bd8fd4fb
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/bd8fd4fb

Branch: refs/heads/3.3.x
Commit: bd8fd4fbb5ee4026f107365bcab6d546fc855f83
Parents: 57ffdf5
Author: James Peach <jp...@apache.org>
Authored: Thu Mar 21 10:34:07 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu Mar 21 10:34:07 2013 -0700

----------------------------------------------------------------------
 configure.ac |   52 +++++++++++++++++++++++++++-------------------------
 1 files changed, 27 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bd8fd4fb/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 652f327..19d2a39 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1108,31 +1108,33 @@ AC_SUBST(need_union_semun)
 AC_MSG_CHECKING(for 128bit CAS support)
 AC_LANG_PUSH([C++])
 
-TS_TRY_COMPILE_NO_WARNING([],[
-    __int128_t x = 0;
-    __sync_bool_compare_and_swap(&x,0,10);
-  ], [
-    AC_MSG_RESULT(yes)
-    has_128bit_cas=1
-  ], [
-      dnl If 128bit CAS fails, try again with the -mcx16 option. GCC needs this;
-      dnl clang doesn't; icc is unknown but presumed sane.
-    __saved_CXXFLAGS="${CXXFLAGS}"
-    TS_ADDTO(CXXFLAGS, [-mcx16])
-    TS_TRY_COMPILE_NO_WARNING([],[
-        __int128_t x = 0;
-        __sync_bool_compare_and_swap(&x,0,10);
-      ], [
-        AC_MSG_RESULT(yes)
-        has_128bit_cas=1
-        dnl Keep CFLAGS and CXXFLAGS in sync.
-        TS_ADDTO(CFLAGS, [-mcx16])
-      ], [
-        AC_MSG_RESULT(no)
-        has_128bit_cas=0
-        CXXFLAGS="${__saved_CXXFLAGS}"
-    ])
-])
+dnl TS_TRY_COMPILE_NO_WARNING([],[
+dnl     __int128_t x = 0;
+dnl     __sync_bool_compare_and_swap(&x,0,10);
+dnl   ], [
+dnl     AC_MSG_RESULT(yes)
+dnl     has_128bit_cas=1
+dnl   ], [
+dnl       dnl If 128bit CAS fails, try again with the -mcx16 option. GCC needs this;
+dnl       dnl clang doesn't; icc is unknown but presumed sane.
+dnl     __saved_CXXFLAGS="${CXXFLAGS}"
+dnl     TS_ADDTO(CXXFLAGS, [-mcx16])
+dnl     TS_TRY_COMPILE_NO_WARNING([],[
+dnl         __int128_t x = 0;
+dnl         __sync_bool_compare_and_swap(&x,0,10);
+dnl       ], [
+dnl         AC_MSG_RESULT(yes)
+dnl         has_128bit_cas=1
+dnl         dnl Keep CFLAGS and CXXFLAGS in sync.
+dnl         TS_ADDTO(CFLAGS, [-mcx16])
+dnl       ], [
+dnl         AC_MSG_RESULT(no)
+dnl         has_128bit_cas=0
+dnl         CXXFLAGS="${__saved_CXXFLAGS}"
+dnl     ])
+dnl ])
+
+has_128bit_cas=0
 
 AC_LANG_POP
 AC_SUBST(has_128bit_cas)


[40/51] git commit: TS-1754 Warnings from stats evaluation.

Posted by zw...@apache.org.
TS-1754 Warnings from stats evaluation.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/0e599c33
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/0e599c33
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/0e599c33

Branch: refs/heads/3.3.x
Commit: 0e599c331b7d7b6e302f0ef1482530f2d3a479bc
Parents: 0afb894
Author: Yunkai Zhang <yunkai dot me at gmail dot com>
Authored: Mon Mar 25 15:39:40 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Mar 25 15:40:15 2013 -0600

----------------------------------------------------------------------
 mgmt/stats/StatType.cc |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0e599c33/mgmt/stats/StatType.cc
----------------------------------------------------------------------
diff --git a/mgmt/stats/StatType.cc b/mgmt/stats/StatType.cc
index e206272..7a283cc 100644
--- a/mgmt/stats/StatType.cc
+++ b/mgmt/stats/StatType.cc
@@ -825,7 +825,6 @@ StatExprToken *StatObject::StatBinaryEval(StatExprToken * left, char op,
 
   if (left->m_token_type == RECD_NULL
       && right->m_token_type == RECD_NULL) {
-    Warning("Both two token type are RECD_NULL.");
     return result;
   }
 


[47/51] git commit: Fix centos vagrant box

Posted by zw...@apache.org.
Fix centos vagrant box


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/e1e83f87
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/e1e83f87
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/e1e83f87

Branch: refs/heads/3.3.x
Commit: e1e83f874fcfed6f40eecdc65eaf3ea11b00a36c
Parents: 5774cc4
Author: James Peach <jp...@apache.org>
Authored: Thu Mar 28 11:20:05 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu Mar 28 11:20:05 2013 -0700

----------------------------------------------------------------------
 Vagrantfile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e1e83f87/Vagrantfile
----------------------------------------------------------------------
diff --git a/Vagrantfile b/Vagrantfile
index ab57463..8c7c755 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -55,7 +55,7 @@ Vagrant.configure("2") do |config|
 
   config.vm.define :centos63 do |config|
     config.vm.box = "centos63"
-    config.vm.network :hostonly, "192.168.100.8"
+    config.vm.network :private_network, ip: "192.168.100.8"
     config.vm.box_url = "https://dl.dropbox.com/u/7225008/Vagrant/CentOS-6.3-x86_64-minimal.box"
     config.vm.provision :puppet do |puppet|
       puppet.manifests_path = "contrib/manifests"


[21/51] git commit: cluster: free_connections should be assigned before num_connections @ClusterHandler::startClusterEvent(...)

Posted by zw...@apache.org.
cluster: free_connections should be assigned before num_connections @ClusterHandler::startClusterEvent(...)

When cluster member is removed from the cluster, it will trigger a
core when deleting the cluster machine, 2 days later.

Signed-off-by: Zhao Yongming <mi...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/09b28d44
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/09b28d44
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/09b28d44

Branch: refs/heads/3.3.x
Commit: 09b28d447bb266172f4ad6e16a8ebbb17aec74e6
Parents: 13411cb
Author: quehan <qu...@taobao.com>
Authored: Wed Mar 20 11:11:06 2013 +0800
Committer: Zhao Yongming <mi...@gmail.com>
Committed: Thu Mar 21 15:53:39 2013 +0800

----------------------------------------------------------------------
 iocore/cluster/ClusterHandlerBase.cc |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/09b28d44/iocore/cluster/ClusterHandlerBase.cc
----------------------------------------------------------------------
diff --git a/iocore/cluster/ClusterHandlerBase.cc b/iocore/cluster/ClusterHandlerBase.cc
index fddba69..a8ee01c 100644
--- a/iocore/cluster/ClusterHandlerBase.cc
+++ b/iocore/cluster/ClusterHandlerBase.cc
@@ -1044,8 +1044,8 @@ ClusterHandler::startClusterEvent(int event, Event * e)
                 if (m->clusterHandlers[i])
                   m->clusterHandlers[i]->downing = true;
               }
-              m->num_connections = machine->num_connections;
               m->free_connections -= (m->num_connections - machine->num_connections);
+              m->num_connections = machine->num_connections;
               // delete_this
               failed = -2;
               MUTEX_UNTAKE_LOCK(the_cluster_config_mutex, this_ethread());


[02/51] git commit: TS-1748: Add jtest to the build

Posted by zw...@apache.org.
TS-1748: Add jtest to the build


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/e8ad2978
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/e8ad2978
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/e8ad2978

Branch: refs/heads/3.3.x
Commit: e8ad2978176e62da929c4343db89b26f100b1353
Parents: 79e146a
Author: James Peach <jp...@apache.org>
Authored: Thu Mar 7 14:50:22 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Mar 14 20:21:48 2013 -0700

----------------------------------------------------------------------
 CHANGES              |    2 +
 tools/Makefile.am    |    8 +-
 tools/jtest/jtest.cc | 8369 ++++++++++++++++++++++-----------------------
 3 files changed, 4186 insertions(+), 4193 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e8ad2978/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index c6c8c96..6c32dfc 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1748] add jtest to the build
+
   *) [TS-1730] Supporting First Byte Flush for ESI plugin
    Author: Shu Kit Chan <ch...@gmail.com>
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e8ad2978/tools/Makefile.am
----------------------------------------------------------------------
diff --git a/tools/Makefile.am b/tools/Makefile.am
index ceed22e..d009d4d 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -17,8 +17,8 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 
-# Local Macros
-# http://www.gnu.org/software/automake/manual/automake.html#Local-Macros
-ACLOCAL_AMFLAGS = -I build
-
 bin_SCRIPTS = tsxs
+
+noinst_PROGRAMS = jtest/jtest
+
+jtest_jtest_SOURCES = jtest/jtest.cc


[29/51] git commit: TS-1735: Remove dead code that invokes missing vmap_config tool

Posted by zw...@apache.org.
TS-1735: Remove dead code that invokes missing vmap_config tool

Virtual IPs were once managed such that within a cluster they would
automatically rebalance themselves between nodes by bringing
subinterfaces up and down. After ATS was open sourced the original
setuid tool, vip_config (or traffic_vip_config) was inadvertently
removed; but the code which depended on this tool was not cleaned
up.

Since modern deployments either do not use this tool at all (because
it was broken for a few years) and modern deployments also have
some central system for managing cluster state reliably, we do not
need VMap to implement some scheme for automatically rebalancing
the ips.

This patch keeps much of the code for detecting ip address conflicts
and for receiving the multicast messages from the cluster; but we
remove all instances where we either bring up/down an interface.
Deployments should manage this through external state systems.

Note: VIPs do not actually bind to the specific addresses in vaddrs;
this is just an operations convience to ensure that a cluster has
no ip conflicts or unmanaged vips. This feature becomes even less
useful. LocalManager.cc would have to be modified in some way to
set this up properly.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/dbf7124a
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/dbf7124a
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/dbf7124a

Branch: refs/heads/3.3.x
Commit: dbf7124a945f38204b0548b1d2fdc54f51ed84ce
Parents: ae08594
Author: John Kew <jo...@gmail.com>
Authored: Thu Mar 21 12:14:20 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu Mar 21 12:14:20 2013 -0700

----------------------------------------------------------------------
 CHANGES                            |    3 +
 mgmt/Main.cc                       |   18 --
 mgmt/cluster/ClusterCom.cc         |   12 +-
 mgmt/cluster/VMap.cc               |  341 ++-----------------------------
 mgmt/cluster/VMap.h                |   13 +-
 proxy/config/vaddrs.config.default |   11 +-
 6 files changed, 44 insertions(+), 354 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dbf7124a/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index b60079d..04ad34d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1735] Remove dead code that invokes missing vmap_config tool
+   Author: John Kew <jo...@gmail.com>
+
   *) [TS-1660] Host field should not has c style terminator.
 
   *) [TS-1627] Support requests with payload

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dbf7124a/mgmt/Main.cc
----------------------------------------------------------------------
diff --git a/mgmt/Main.cc b/mgmt/Main.cc
index 4c3a3f6..2463689 100644
--- a/mgmt/Main.cc
+++ b/mgmt/Main.cc
@@ -752,24 +752,6 @@ main(int argc, char **argv)
   Debug("lm", "Created Web Agent thread (%"  PRId64 ")", (int64_t)webThrId);
   lmgmt->listenForProxy();
 
-  /* Check the permissions on vip_config */
-  if (lmgmt->virt_map->enabled) {
-    char absolute_vipconf_binary[1024];
-    struct stat buf;
-
-    snprintf(absolute_vipconf_binary, sizeof(absolute_vipconf_binary), "%s/vip_config", lmgmt->bin_path);
-    if (stat(absolute_vipconf_binary, &buf) < 0) {
-      mgmt_elog(stderr, "[main] Unable to stat vip_config for proper permissions\n");
-    } else if (!((buf.st_mode & S_ISUID) &&
-                 (buf.st_mode & S_IRWXU) &&
-                 (buf.st_mode & S_IRGRP) &&
-                 (buf.st_mode & S_IXGRP) && (buf.st_mode & S_IROTH) && (buf.st_mode & S_IXOTH))) {
-      lmgmt->alarm_keeper->signalAlarm(MGMT_ALARM_PROXY_SYSTEM_ERROR,
-                                       "Virtual IP Addressing enabled, but improper permissions on '/inktomi/bin/vip_config'"
-                                       "[requires: setuid root and at least a+rx]\n");
-    }
-  }
-
   ticker = time(NULL);
   mgmt_log("[TrafficManager] Setup complete\n");
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dbf7124a/mgmt/cluster/ClusterCom.cc
----------------------------------------------------------------------
diff --git a/mgmt/cluster/ClusterCom.cc b/mgmt/cluster/ClusterCom.cc
index 157b5dc..aaea1df 100644
--- a/mgmt/cluster/ClusterCom.cc
+++ b/mgmt/cluster/ClusterCom.cc
@@ -63,16 +63,16 @@ drainIncomingChannel(void *arg)
   struct sockaddr_in cli_addr;
 
   // Fix for INKqa07688: There was a problem at Genuity where if you
-  // pulled out the cable on the cluser interface (or just ifconfig'd
-  // down/up the cluster interface), the fd assocated with that
-  // inteface would somehow get into a bad state... and the multicast
+  // pulled out the cable on the cluster interface (or just ifconfig'd
+  // down/up the cluster interface), the fd associated with that
+  // interface would somehow get into a bad state... and the multicast
   // packets from other nodes wouldn't be received anymore.
   //
   // The fix for the problem was to close() and re-open the multicast
-  // socket if we detected that no activity has occured for 30
+  // socket if we detected that no activity has occurred for 30
   // seconds.  30 seconds was based on the default peer_timeout
   // (proxy.config.cluster.peer_timeout) value.  davey showed that
-  // this value worked out well experiementally (though more testing
+  // this value worked out well experimentally (though more testing
   // and experimentation would be beneficial).
   //
   // traffic_manager running w/ no cop: In this case, our select()
@@ -1240,7 +1240,7 @@ ClusterCom::handleMultiCastAlarmPacket(char *last, char *ip)
 
 /*
  * handleMultiCastVMapPacket(...)
- *   Handles incoming reports from peers about which virtua interfaces
+ *   Handles incoming reports from peers about which virtual interfaces
  * they are servicing. This then updates the VMap class to indicate who
  * is holding what.
  */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dbf7124a/mgmt/cluster/VMap.cc
----------------------------------------------------------------------
diff --git a/mgmt/cluster/VMap.cc b/mgmt/cluster/VMap.cc
index ccfcd4e..0228f7e 100644
--- a/mgmt/cluster/VMap.cc
+++ b/mgmt/cluster/VMap.cc
@@ -61,57 +61,6 @@ vmapEnableHandler(const char *tok, RecDataT data_type, RecData data, void *cooki
 }                               /* End vmapEnableHandler */
 
 
-/*
- * init()
- *   The code is used to be part of the VMap::VMap().
- *   Initialize the location of vaddrs.config.
- */
-void
-VMap::init()
-{
-//    int id;
-//    bool found;
-//    RecordType type;
-
-  if (enabled) {
-    ink_strlcpy(vip_conf, "vip_config", sizeof(vip_conf));
-    snprintf(absolute_vipconf_binary, sizeof(absolute_vipconf_binary), "%s/%s", lmgmt->bin_path, vip_conf);
-
-    /* Make sure vip_config is setuid root */
-    int vip_config_fd = open(absolute_vipconf_binary, O_RDONLY);
-    char msg_buffer[1024];
-
-    if (vip_config_fd < 0) {
-      snprintf(msg_buffer, sizeof(msg_buffer), "unable to open %s", absolute_vipconf_binary);
-      lmgmt->alarm_keeper->signalAlarm(MGMT_ALARM_PROXY_SYSTEM_ERROR, msg_buffer);
-    } else {
-      struct stat stat_buf;
-
-      int err = fstat(vip_config_fd, &stat_buf);
-      if (err < 0) {
-        snprintf(msg_buffer, sizeof(msg_buffer), "[VMap::VMap] fstat of %s failed, see syslog for more info.",
-                 absolute_vipconf_binary);
-        mgmt_elog(msg_buffer);
-        snprintf(msg_buffer, sizeof(msg_buffer), "fstat of %s failed, see syslog for more info.",
-                 absolute_vipconf_binary);
-        lmgmt->alarm_keeper->signalAlarm(MGMT_ALARM_PROXY_SYSTEM_ERROR, msg_buffer);
-      } else if (stat_buf.st_uid != 0 || !(stat_buf.st_mode & C_ISUID)) {
-        snprintf(msg_buffer, sizeof(msg_buffer),
-                 "[VMap::VMap] %s is not setuid root, manager will be unable to enable virtual ip addresses.",
-                 absolute_vipconf_binary);
-        mgmt_elog(msg_buffer);
-        snprintf(msg_buffer, sizeof(msg_buffer),
-                 "%s is not setuid root, traffic manager will be unable to enable virtual ip addresses.",
-                 absolute_vipconf_binary);
-        lmgmt->alarm_keeper->signalAlarm(MGMT_ALARM_PROXY_SYSTEM_ERROR, msg_buffer);
-      }
-      close(vip_config_fd);
-    }
-    enabled_init = true;
-  }
-}
-
-
 VMap::VMap(char *interface, unsigned long ip, ink_mutex * m)
 {
   bool found;
@@ -133,13 +82,9 @@ VMap::VMap(char *interface, unsigned long ip, ink_mutex * m)
 
 
   this->interface = ats_strdup(interface);
-  enabled_init = false;         // don't whether enabled, but definitely no init'd
   turning_off = false;          // we are not turning off VIP
 
   enabled = REC_readInteger("proxy.config.vmap.enabled", &found);
-
-  init();                       // Initialize VIP
-
   /*
    * Perpetuating a hack for the cluster interface. Here I want to loop
    * at startup(before any virtual ips have been brought up) and get the real
@@ -309,11 +254,6 @@ VMap::lt_runGambit()
   if (num_addrs == 0) {
     return;
   }
-  // Have we initialized yet? If not, VIP is turned from OFF to ON since last restart
-  // Let's initialize it
-  if (!enabled_init) {
-    this->init();
-  }
 
   ink_mutex_acquire(mutex);
   if (lmgmt->ccom->isMaster()) {        /* Are we the cluster master? */
@@ -327,10 +267,7 @@ VMap::lt_runGambit()
       }
     }
 
-    if (i == num_addrs) {       /* So, all addrs are mapped. Check if rebalance is needed */
-      rl_rebalance();
-    } else {                    /* Got one to map, find a candidate and map it */
-
+    if (i != num_addrs) {                /* Got one to map, find a candidate and map it */
       real_addr.s_addr = lmgmt->ccom->lowestPeer(&no);
       if (no != -1) {           /* Make sure we have peers to map interfaces to */
         init = true;
@@ -353,16 +290,12 @@ VMap::lt_runGambit()
     ink_strlcpy(vaddr, inet_ntoa(virtual_addr), sizeof(vaddr));
 
     if ((conf_addr = rl_checkConflict(vaddr))) {
-      mgmt_log(stderr, "[VMap::lt_runGambit] Conflict w/addr: '%s'\n", vaddr);
+      mgmt_log(stderr, "[VMap::lt_runGambit] Conflict w/addr: '%s' - Unable to use virtual address.\n", vaddr);
+      ats_free(conf_addr);
       break;
     }
   }
 
-  if (conf_addr) {              /* If there was a conflict, resolve it */
-    rl_resolveConflict(vaddr, conf_addr);
-    ats_free(conf_addr);
-  }
-
   ink_mutex_release(mutex);
   return;
 }                               /* End VMap::lt_runGambit */
@@ -561,7 +494,8 @@ VMap::rl_remote_unmap(char *virt_ip, char *real_ip)
 /*
  * rl_map(...)
  *   Function maps a virt_ip to a real_ip, if real_ip is NULL it maps it
- * to the local node itself(actually bringing the interface up as well).
+ *   to the local node itself. Otherwise it means another node within
+ *   the multicast cluster has it.
  */
 bool
 VMap::rl_map(char *virt_ip, char *real_ip)
@@ -588,13 +522,8 @@ VMap::rl_map(char *virt_ip, char *real_ip)
   *entry = true;
 
   if (!real_ip) {
+    mgmt_elog("[VMap::rl_map] no real ip associated with virtual ip %s, mapping to local\n", buf);
     last_map_change = time(NULL);
-
-    if (!upAddr(virt_ip)) {
-      mgmt_elog(stderr, "[VMap::rl_map] upAddr failed\n");
-      ats_free(entry);
-      return false;
-    }
   }
   ink_hash_table_insert(tmp, buf, (void *) entry);
   return true;
@@ -622,10 +551,6 @@ VMap::rl_unmap(char *virt_ip, char *real_ip)
 
   if (!real_ip) {
     last_map_change = time(NULL);
-    if (!(downAddr(virt_ip))) {
-      mgmt_elog(stderr, "[VMap::rl_unmap] downAddr failed\n");
-      return false;
-    }
   }
   ink_hash_table_delete(tmp, buf);
   ats_free(hash_value);
@@ -723,29 +648,6 @@ VMap::rl_checkGlobConflict(char *virt_ip)
   return ret;
 }                               /* End VMap::rl_checkGlobConflict */
 
-
-/*
- * resolveConflict(...)
- *   This function is to be called after a conflict has been detected between
- * the local node and some peer. It will down the interface, pause for a bit,
- * determine who wins in the conflict and potentially attempt to bring the
- * interface up again.
- */
-void
-VMap::rl_resolveConflict(char *virt_ip, char *conf_ip)
-{
-
-  if (inet_addr(conf_ip) < our_ip) {    /* They win, bow out gracelfully */
-    rl_unmap(virt_ip);
-  } else {                      /* We win(don't gloat), down, timeout, up */
-    downAddr(virt_ip);          /* downAddr, to avoid possible re-assignment */
-    mgmt_sleep_sec(down_up_timeout);    /* FIX: SHOULD this be changed to a wait till no-ping? */
-    upAddr(virt_ip);
-  }
-  return;
-}                               /* End VMap::rl_resolveConflict */
-
-
 /*
  * remap(...)
  *   Function attempts to remap virt_ip. If dest is NULL, test to see if local
@@ -922,203 +824,6 @@ VMap::lt_constructVMapMessage(char *ip, char *message, int max)
   return;
 }                               /* End VMap::constructVMapMessage */
 
-
-/*
- * rebalance()
- *   Advanced feature that initiates a re-balancing effort(if determined to be
- * necessary) of the addresses throughout the cluster.
- */
-void
-VMap::rl_rebalance()
-{
-  int naddr_low, naddr_high;
-  char low_ip[80], high_ip[80];
-  unsigned long low, high;
-  struct in_addr tmp_addr;
-
-  low = lmgmt->ccom->lowestPeer(&naddr_low);
-  high = lmgmt->ccom->highestPeer(&naddr_high);
-  tmp_addr.s_addr = high;
-  ink_strlcpy(high_ip, inet_ntoa(tmp_addr), sizeof(high_ip));
-  tmp_addr.s_addr = low;
-  ink_strlcpy(low_ip, inet_ntoa(tmp_addr), sizeof(low_ip));
-
-  if (naddr_low == -1 || naddr_high == -1) {
-    return;
-  }
-
-  if (naddr_low > num_interfaces || (naddr_low == num_interfaces && our_ip < low)) {
-    naddr_low = num_interfaces;
-    tmp_addr.s_addr = our_ip;
-    low = our_ip;
-    ink_strlcpy(low_ip, inet_ntoa(tmp_addr), sizeof(low_ip));
-  } else if (naddr_high<num_interfaces || (naddr_high == num_interfaces && our_ip> high)) {
-    naddr_high = num_interfaces;
-    tmp_addr.s_addr = our_ip;
-    high = our_ip;
-    ink_strlcpy(high_ip, inet_ntoa(tmp_addr), sizeof(high_ip));
-  }
-#ifdef DEBUG_VMAP
-  Debug("vmap",
-        "[VMap::rl_rebalance] Checking balance of virtual map low: %s, %d high: %s, %d\n",
-        low_ip, naddr_low, high_ip, naddr_high);
-#endif /* DEBUG_VMAP */
-
-  if (naddr_low < naddr_high && high != low && (naddr_high - naddr_low) != 1) {
-    InkHashTableEntry *entry;
-    InkHashTableIteratorState iterator_state;
-
-    mgmt_log(stderr, "[VMap::rl_rebalance] Attempting to rebalance virtual map\n");
-    if (high == our_ip) {
-      char *key, tmp_key[80];
-
-      entry = ink_hash_table_iterator_first(our_map, &iterator_state);
-      key = (char *) ink_hash_table_entry_key(ext_map, entry);
-      ink_strlcpy(tmp_key, key, sizeof(tmp_key));
-
-      mgmt_log(stderr, "[VMap::rl_rebalance] Remapping vaddr: '%s' from: '%s' to: '%s'\n", key, high_ip, low_ip);
-      if (!rl_remap(key, high_ip, low_ip, naddr_high, naddr_low)) {
-        mgmt_elog(stderr, "[VMap::rl_rebalance] Remap failed vaddr: '%s' from: '%s' to: '%s'\n", key, high_ip, low_ip);
-      }
-    } else {
-      for (entry = ink_hash_table_iterator_first(ext_map, &iterator_state);
-           entry != NULL; entry = ink_hash_table_iterator_next(ext_map, &iterator_state)) {
-        char *key = (char *) ink_hash_table_entry_key(ext_map, entry);
-
-        if (strstr(key, high_ip)) {
-          char vip[80], buf[80];
-          //coverity[secure_coding]
-          if (sscanf(key, "%79s %79s", vip, buf) != 2) {
-            mgmt_fatal("[VMap::rl_rebalance] Corrupt VMap entry('%s'), bailing\n", key);
-          }
-
-          mgmt_log(stderr, "[VMap::rl_rebalance] Remapping vaddr: '%s' from: '%s' to: '%s'\n", vip, high_ip, low_ip);
-          if (!rl_remap(vip, high_ip, low_ip, naddr_high, naddr_low)) {
-            mgmt_elog(stderr, "[VMap::lt_rebalance] Failed vaddr: '%s' from: '%s' to: '%s'\n", vip, high_ip, low_ip);
-          }
-          break;
-        }
-      }
-    }
-  }
-  return;
-}                               /* End VMap::rl_rebalance */
-
-
-bool
-VMap::upAddr(char *virt_ip)
-{
-  int status;
-  pid_t pid;
-  InkHashTableValue hash_value;
-
-  if (!enabled) {
-    mgmt_elog(stderr, "[VMap::upAddr] Called for '%s' though virtual addressing disabled\n", virt_ip);
-    return false;
-  }
-  mgmt_log(stderr, "[VMap::upAddr] Bringing up addr: '%s'\n", virt_ip);
-
-  if (ink_hash_table_lookup(id_map, (InkHashTableKey) virt_ip, &hash_value) == 0) {
-    mgmt_elog(stderr, "[VMap::upAddr] Called for '%s' which is not in our vaddr.config\n", virt_ip);
-    return false;
-  }
-#ifdef POSIX_THREAD
-  if ((pid = fork()) < 0)
-#else
-  if ((pid = fork1()) < 0)
-#endif
-  {
-    mgmt_elog(stderr, "[VMap::upAddr] Unable to fork1 process\n");
-    return false;
-  } else if (pid > 0) {         /* Parent */
-    waitpid(pid, &status, 0);
-
-    if (status != 0) {
-      return false;
-    }
-    num_interfaces++;
-    return true;
-  } else {
-    int res = 1;
-    char *interface, *sub_id;
-
-    interface = ((VIPInfo *) hash_value)->interface;
-    sub_id = ((VIPInfo *) hash_value)->sub_interface_id;
-
-#if defined(linux) || defined(freebsd) || defined(solaris) || defined(darwin)
-    res = execl(absolute_vipconf_binary, vip_conf, "up", virt_ip, "/sbin/ifconfig", interface, sub_id, (char*) NULL);
-#else
-    res = execl(absolute_vipconf_binary, vip_conf, "up", virt_ip, "/usr/sbin/ifconfig", interface, sub_id, NULL);
-#endif
-    _exit(res);
-  }
-
-
-  num_interfaces++;
-  ink_assert(num_interfaces > 0 && num_interfaces <= num_addrs);
-
-  return true;
-}                               /* End VMap::upAddr */
-
-
-bool
-VMap::downAddr(char *virt_ip)
-{
-  if (!enabled && !turning_off) {
-    mgmt_elog(stderr, "[VMap::downAddr] Called for '%s' though virtual addressing disabled\n", virt_ip);
-    return false;
-  }
-  mgmt_log(stderr, "[VMap::downAddr] Bringing down addr: '%s'\n", virt_ip);
-
-
-  int status;
-  pid_t pid;
-  InkHashTableValue hash_value;
-
-  if (ink_hash_table_lookup(id_map, (InkHashTableKey) virt_ip, &hash_value) == 0) {
-    mgmt_elog(stderr, "[VMap::downAddr] Called for '%s' which is not in our vaddr.config\n", virt_ip);
-    return false;
-  }
-#ifdef POSIX_THREAD
-  if ((pid = fork()) < 0)
-#else
-  if ((pid = fork1()) < 0)
-#endif
-  {
-    mgmt_elog(stderr, "[VMap::downAddr] Unable to fork1 process\n");
-    return false;
-  } else if (pid > 0) {         /* Parent */
-    waitpid(pid, &status, 0);
-    if (status != 0) {
-      return false;
-    }
-    num_interfaces--;
-    return true;
-  } else {
-    int res = 1;
-    char *interface, *sub_id;
-
-    interface = ((VIPInfo *) hash_value)->interface;
-    sub_id = ((VIPInfo *) hash_value)->sub_interface_id;
-
-#if defined(linux)|| defined(freebsd) || defined(solaris) || defined(darwin)
-    res = execl(absolute_vipconf_binary, vip_conf, "down", virt_ip, "/sbin/ifconfig", interface, sub_id, (char*)NULL);
-#else
-    res = execl(absolute_vipconf_binary, vip_conf, "down", virt_ip, "/usr/sbin/ifconfig", interface, sub_id, NULL);
-#endif
-    _exit(res);
-  }
-
-  num_interfaces--;
-
-  // whenever the manager starts up, it tries to remove all vip's
-  // and at that time num_interfaces was 0
-  ink_assert(num_interfaces >= 0 && num_interfaces < num_addrs);
-
-  return true;
-}                               /* End VMap::downAddr */
-
-
 void
 VMap::rl_downAddrs()
 {
@@ -1136,21 +841,9 @@ VMap::rl_downAddrs()
 void
 VMap::downAddrs()
 {
-
-
-  // Now for WIN32, we have to find the nte_context for the virtual ip address
-  // if its still bound to the machine
-  // BUGBUG:
-  // The way we are doing it is totally undocumented and can change...
-
   ink_mutex_acquire(mutex);
   for (int i = 0; i < num_addrs; i++) {
-    char str_addr[1024];
-    struct in_addr address;
-    address.s_addr = addr_list[i];
-    ink_strlcpy(str_addr, inet_ntoa(address), sizeof(str_addr));
-    downAddr(str_addr);
-    ink_hash_table_delete(our_map, str_addr);   /* Make sure removed */
+    removeAddressMapping(i);
   }
 
   // Reset On->Off flag
@@ -1183,14 +876,22 @@ VMap::downOurAddrs()
 
 
     for (int i = 0; i < num_addrs; i++) {
-      char str_addr[1024];
-      struct in_addr address;
-      address.s_addr = addr_list[i];
-      ink_strlcpy(str_addr, inet_ntoa(address), sizeof(str_addr));
-      downAddr(str_addr);
-      ink_hash_table_delete(our_map, str_addr); /* Make sure removed */
+      removeAddressMapping(i);
     }
   }
   num_interfaces = 0;
   ink_mutex_release(mutex);
 }                               /* End VMap::downOurAddrs */
+
+/*
+ * Remove a virtual address from our map
+ */
+void
+VMap::removeAddressMapping(int i)
+{
+  char str_addr[1024];
+  struct in_addr address;
+  address.s_addr = addr_list[i];
+  ink_strlcpy(str_addr, inet_ntoa(address), sizeof(str_addr));
+  ink_hash_table_delete(our_map, str_addr); /* Make sure removed */
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dbf7124a/mgmt/cluster/VMap.h
----------------------------------------------------------------------
diff --git a/mgmt/cluster/VMap.h b/mgmt/cluster/VMap.h
index dd7229c..1860720 100644
--- a/mgmt/cluster/VMap.h
+++ b/mgmt/cluster/VMap.h
@@ -65,20 +65,14 @@ public:
   VMap(char *interface, unsigned long ip, ink_mutex * m);
    ~VMap();
 
-  void init();                  /* VIP is ON, initialize it */
-
-  bool upAddr(char *virt_ip);
-  bool downAddr(char *virt_ip);
   void downAddrs();
   void downOurAddrs();
   void rl_downAddrs();
-
+  void removeAddressMapping(int i);
   void lt_runGambit();
   void lt_readAListFile(char *data);
   void lt_constructVMapMessage(char *ip, char *message, int max);
 
-  void rl_rebalance();
-
   bool rl_remote_map(char *virt_ip, char *real_ip);
   bool rl_remote_unmap(char *virt_ip, char *real_ip);
 
@@ -88,7 +82,6 @@ public:
 
   char *rl_checkConflict(char *virt_ip);
   bool rl_checkGlobConflict(char *virt_ip);
-  void rl_resolveConflict(char *virt_ip, char *conf_ip);
 
   int rl_boundAddr(char *virt_ip);
   unsigned long rl_boundTo(char *virt_ip);
@@ -99,7 +92,6 @@ public:
   char absolute_vipconf_binary[PATH_NAME_MAX];
 
   int enabled;
-  bool enabled_init;            /* have we initialized VIP? Call when VIP is turned on */
   bool turning_off;             /* are we turning off VIP but haven't down'd the addr? */
   /* map_init has never been used, remove it to avoid coverity complain */
   int map_change_thresh;
@@ -116,7 +108,10 @@ public:
   unsigned long our_ip;
 
   ink_mutex *mutex;
+  // Map of virtual ip addresses assigned to the local node
   InkHashTable *our_map;
+  // Map of virtual ip addresses assigned to other nodes; as indicated through multicast messages; used
+  // to detect conflicts
   InkHashTable *ext_map;
   InkHashTable *id_map;
   InkHashTable *interface_realip_map;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dbf7124a/proxy/config/vaddrs.config.default
----------------------------------------------------------------------
diff --git a/proxy/config/vaddrs.config.default b/proxy/config/vaddrs.config.default
index f091103..01233a8 100644
--- a/proxy/config/vaddrs.config.default
+++ b/proxy/config/vaddrs.config.default
@@ -1,7 +1,16 @@
 # Virtual IP Address Configuration
 #
 # The purpose of this file is to specify virtual IP addresses
-# for Traffic Server.
+# for Traffic Server. This DOES NOT actually bind to these
+# addresses; ATS either listens to all or the address specified
+# through proxy.local.incoming_ip_to_bind.
+#
+# The vips specified here will be verified and broadcast across
+# the cluster. Any conflicts will be logged as errors.
+#
+# In order to enable these checks you must also set:
+#     CONFIG proxy.config.vmap.enabled INT 1
+# In records.conf
 #
 # UNIX
 #   Format:


[43/51] git commit: TS-1742: correct 32bit freelist case

Posted by zw...@apache.org.
TS-1742: correct 32bit freelist case


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/ca7a84ee
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ca7a84ee
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ca7a84ee

Branch: refs/heads/3.3.x
Commit: ca7a84eebd0711c254959fc723d9de73f10aef68
Parents: cf0e2f1
Author: Brian Geffon <bg...@bgeffon-mn1.linkedin.biz>
Authored: Tue Mar 26 11:26:36 2013 -0700
Committer: Brian Geffon <bg...@bgeffon-mn1.linkedin.biz>
Committed: Tue Mar 26 11:26:36 2013 -0700

----------------------------------------------------------------------
 lib/ts/ink_queue_utils.cc |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ca7a84ee/lib/ts/ink_queue_utils.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_queue_utils.cc b/lib/ts/ink_queue_utils.cc
index c249e77..bea41e2 100644
--- a/lib/ts/ink_queue_utils.cc
+++ b/lib/ts/ink_queue_utils.cc
@@ -71,7 +71,7 @@ ink_queue_load_64(void *dst, void *src)
 {
 #if (defined(__i386__) || defined(__arm__)) && (SIZEOF_VOIDP == 4)
   volatile int32_t src_version = (*(head_p *) src).s.version;
-  volatile void *src_pointer = (*(head_p *) src).s.pointer;
+  void *src_pointer = (*(head_p *) src).s.pointer;
 
   (*(head_p *) dst).s.version = src_version;
   (*(head_p *) dst).s.pointer = src_pointer;


[17/51] git commit: CRUFT.txt: Track the horrible things we do

Posted by zw...@apache.org.
CRUFT.txt: Track the horrible things we do

CRUFT.txt is a place where we track the mistakes we deliberately make
to make things temporarily, that is, until better compilers, libraries,
OSes, machines come up ;) -- or, until a better programmer comes along
and fixes @igalic's horrible code.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/0f436307
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/0f436307
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/0f436307

Branch: refs/heads/3.3.x
Commit: 0f436307a4ed1454840763aa95877aabd21f82fc
Parents: 3c51b61
Author: Igor Galić <i....@brainsware.org>
Authored: Wed Mar 20 18:22:17 2013 +0100
Committer: Igor Galić <i....@brainsware.org>
Committed: Wed Mar 20 18:22:17 2013 +0100

----------------------------------------------------------------------
 CRUFT.txt |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0f436307/CRUFT.txt
----------------------------------------------------------------------
diff --git a/CRUFT.txt b/CRUFT.txt
new file mode 100644
index 0000000..634fadd
--- /dev/null
+++ b/CRUFT.txt
@@ -0,0 +1,27 @@
+CRUFT
+*****
+
+This file is designated for tracking cruft in our code. That is, code paths
+or ugly hacks that were put into place for a reason: Getting stuff to work
+but which could either been done better, or which time will obsolete.
+
+Examples are crude workarounds for broken compilers, libraries, OSes, or
+hardware, or or massive ``#ifdef`` clusters, that are better abstracted away
+into autoconf and convenience wrappers.
+
+If you are new to the project this is a good place to look for explanations
+of why things are the way they are, or help us fix things and make the code
+easier to read and maintain.
+
+
+Store.cc
+========
+``iocore/cache/Store.cc`` contains three different ``#ifdef`` clusters with
+near identical code. Often you will read the same confused comment in three
+places, see for instance: http://issues.apache.org/jira/browse/TS-1707
+
+Web2
+====
+``mgmt/web2`` is very old, very broken, very deeply infested code that needs
+to be removed as it is no longer appropriate, or functional.
+Please see https://issues.apache.org/jira/browse/TS-641 for further refernece.


[07/51] git commit: fix omnios vagrant box

Posted by zw...@apache.org.
fix omnios vagrant box


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/d66eef8a
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/d66eef8a
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/d66eef8a

Branch: refs/heads/3.3.x
Commit: d66eef8a7056c6abc2699fb0442e4acd2e224bf3
Parents: 7c5e5a6
Author: James Peach <jp...@apache.org>
Authored: Mon Mar 18 15:09:12 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Mon Mar 18 15:09:12 2013 -0700

----------------------------------------------------------------------
 Vagrantfile |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d66eef8a/Vagrantfile
----------------------------------------------------------------------
diff --git a/Vagrantfile b/Vagrantfile
index d40799d..ab57463 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -66,8 +66,8 @@ Vagrant.configure("2") do |config|
   # Current OmniOS release, see http://omnios.omniti.com/wiki.php/Installation
   config.vm.define :omnios do | config |
     config.vm.box = "omnios"
-    config.vm.network :hostonly, "192.168.100.9"
-    config.vm.share_folder "src", "/opt/src/trafficserver.git", ".", :nfs => false
+    config.vm.network :private_network, ip: "192.168.100.9"
+    config.vm.synced_folder ".", "/opt/src/trafficserver.git", :nfs => false
     config.vm.box_url = "http://omnios.omniti.com/media/omnios-latest.box"
     config.vm.provision :shell,  :path => "contrib/manifests/omnios.sh"
   end


[08/51] git commit: Log an error if registration was not successful

Posted by zw...@apache.org.
Log an error if registration was not successful


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/5cbc2127
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/5cbc2127
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/5cbc2127

Branch: refs/heads/3.3.x
Commit: 5cbc2127d53b5ce8a00922259534cfb3a0303261
Parents: d66eef8
Author: Kris Foster <kr...@opendns.com>
Authored: Mon Mar 18 14:56:24 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Mon Mar 18 15:38:04 2013 -0700

----------------------------------------------------------------------
 plugins/header_filter/header_filter.cc |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5cbc2127/plugins/header_filter/header_filter.cc
----------------------------------------------------------------------
diff --git a/plugins/header_filter/header_filter.cc b/plugins/header_filter/header_filter.cc
index 0b04607..c4ddc26 100644
--- a/plugins/header_filter/header_filter.cc
+++ b/plugins/header_filter/header_filter.cc
@@ -104,7 +104,7 @@ TSPluginInit(int argc, const char *argv[])
   info.vendor_name = const_cast<char*>("Apache");
   info.support_email = const_cast<char*>("users@trafficserver.apache.org");
 
-  if (!TSPluginRegister(TS_SDK_VERSION_3_0 , &info)) {
+  if (TSPluginRegister(TS_SDK_VERSION_3_0 , &info) != TS_SUCCESS) {
     TSError("header_filter: plugin registration failed.\n"); 
   }
 


[49/51] git commit: TS-1169 Eliminate bogus asserts. Credits to Conan Wang.

Posted by zw...@apache.org.
TS-1169 Eliminate bogus asserts. Credits to Conan Wang.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/8a4f5837
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/8a4f5837
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/8a4f5837

Branch: refs/heads/3.3.x
Commit: 8a4f5837fb354ce49e1073805f07dd0f0a6e9970
Parents: 52f2409
Author: Leif Hedstrom <zw...@apache.org>
Authored: Mon Mar 25 15:22:16 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Sat Mar 30 18:41:41 2013 -0600

----------------------------------------------------------------------
 CHANGES              |    2 ++
 proxy/http/HttpSM.cc |   10 +---------
 2 files changed, 3 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8a4f5837/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 5aee40e..024f515 100644
--- a/CHANGES
+++ b/CHANGES
@@ -12,6 +12,8 @@
   *) [TS-1754] Remove unecessary wWarnings from stats evaluation.
    Author: Yunkai Zhang.
 
+  *) [TS-1169] Eliminate bogus asserts. Credits to Conan Wang.
+
   *) [TS-1724] Add tool to compare records.config files to contrib
    Author: Mark Harrison <ma...@mivok.net>
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8a4f5837/proxy/http/HttpSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 17f3ba7..36f5608 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -4195,16 +4195,8 @@ HttpSM::do_cache_delete_all_alts(Continuation * cont)
   // Do not delete a non-existant object.
   ink_assert(t_state.cache_info.object_read);
 
-#ifdef DEBUG
-  INK_MD5 md5a;
-  INK_MD5 md5b;
-  t_state.hdr_info.client_request.url_get()->MD5_get(&md5a);
-  t_state.cache_info.lookup_url->MD5_get(&md5b);
-  ink_assert(md5a == md5b || t_state.txn_conf->maintain_pristine_host_hdr);
-#endif
-
   DebugSM("http_seq", "[HttpSM::do_cache_delete_all_alts] Issuing cache delete for %s",
-        t_state.cache_info.lookup_url->string_get_ref());
+          t_state.cache_info.lookup_url->string_get_ref());
 
   Action *cache_action_handle = NULL;
 


[13/51] git commit: Added TS-1758

Posted by zw...@apache.org.
Added TS-1758


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/8961f12a
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/8961f12a
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/8961f12a

Branch: refs/heads/3.3.x
Commit: 8961f12ab5c2ef7c55733cea7ce13abfbd911789
Parents: 3ceb8a2
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Mar 19 14:16:09 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Tue Mar 19 14:16:09 2013 -0600

----------------------------------------------------------------------
 CHANGES |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8961f12a/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 6c32dfc..10945ab 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1758] Remove unused overviewPage aggregation functions.
+   Author: Yunkai Zhang.
+
   *) [TS-1748] add jtest to the build
 
   *) [TS-1730] Supporting First Byte Flush for ESI plugin


[22/51] git commit: ignore all of the .dirstamp

Posted by zw...@apache.org.
ignore all of the .dirstamp


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/097996ab
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/097996ab
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/097996ab

Branch: refs/heads/3.3.x
Commit: 097996abb006aa31f7e8a8149c43905ea14158d3
Parents: 09b28d4
Author: Zhao Yongming <mi...@gmail.com>
Authored: Thu Mar 21 17:16:06 2013 +0800
Committer: Zhao Yongming <mi...@gmail.com>
Committed: Thu Mar 21 17:16:06 2013 +0800

----------------------------------------------------------------------
 .gitignore |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/097996ab/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index c32a79a..d38a35f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,8 @@
 
 .deps
 
+.dirstamp
+
 !doc/Doxyfile.in
 
 /aclocal.m4
@@ -113,7 +115,6 @@ lib/tsconfig/test-tsconfig
 
 tools/http_load/http_load
 tools/jtest/jtest
-tools/jtest/.dirstamp
 
 BUILDS
 DEBUG


[32/51] git commit: TS-1708: Using tr-pass port option causes requests with large headers to hang

Posted by zw...@apache.org.
TS-1708: Using tr-pass port option causes requests with large headers to hang

If 4KB of headers are read and we haven't decided on requets validity yet, disregard
tr-pass option in order to avoid blocking the writer


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/ec019615
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ec019615
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ec019615

Branch: refs/heads/3.3.x
Commit: ec019615ff15894e01b91ea7b593a76534883b3b
Parents: f41323e
Author: Uri Shachar <us...@apache.org>
Authored: Fri Mar 22 17:10:02 2013 +0200
Committer: Uri Shachar <us...@apache.org>
Committed: Fri Mar 22 17:10:02 2013 +0200

----------------------------------------------------------------------
 CHANGES              |    2 ++
 proxy/http/HttpSM.cc |   12 ++++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ec019615/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 4669806..61e5938 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1708] Using tr-pass port option causes requests with large headers to hang
+
   *) [TS-1734] Remove dead code that invokes missing vmap_config tool
    Author: John Kew <jo...@gmail.com>
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ec019615/proxy/http/HttpSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index bbd6495..17f3ba7 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -728,9 +728,9 @@ HttpSM::state_read_client_request_header(int event, void *data)
 
   if (event == VC_EVENT_READ_READY &&
       state == PARSE_ERROR &&
-      is_transparent_passthrough_allowed()) {
+      is_transparent_passthrough_allowed() &&
+      ua_raw_buffer_reader != NULL) {
 
-      ink_assert(ua_raw_buffer_reader != NULL);
       DebugSM("http", "[%" PRId64 "] first request on connection failed parsing, switching to passthrough.", sm_id);
 
       t_state.transparent_passthrough = true;
@@ -773,6 +773,14 @@ HttpSM::state_read_client_request_header(int event, void *data)
       call_transact_and_set_next_state(HttpTransact::BadRequest);
       break;
     } else {
+      if (is_transparent_passthrough_allowed() &&
+          ua_raw_buffer_reader != NULL &&
+          ua_raw_buffer_reader->get_current_block()->write_avail() <= 0) {
+        //Disable passthrough regardless of eventual parsing failure or success -- otherwise
+        //we either have to consume some data or risk blocking the writer.
+        ua_raw_buffer_reader->dealloc();
+        ua_raw_buffer_reader = NULL;
+      }
       ua_entry->read_vio->reenable();
       return VC_EVENT_CONT;
     }


[16/51] git commit: TS-1627: Support requests with payload

Posted by zw...@apache.org.
TS-1627: Support requests with payload

Allow payload in all request methods (except TRACE).


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/3c51b612
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/3c51b612
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/3c51b612

Branch: refs/heads/3.3.x
Commit: 3c51b612f65ab8e65d913ac168decb8c162b1431
Parents: 1475f86
Author: Uri Shachar <us...@apache.org>
Authored: Wed Mar 20 12:44:09 2013 +0200
Committer: Uri Shachar <us...@apache.org>
Committed: Wed Mar 20 12:44:09 2013 +0200

----------------------------------------------------------------------
 CHANGES                    |    2 +
 proxy/http/HttpSM.cc       |   15 ++-
 proxy/http/HttpTransact.cc |  254 ++++++++++++++++-----------------------
 3 files changed, 118 insertions(+), 153 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3c51b612/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 3c24117..a60d138 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1627] Support requests with payload
+
   *) [TS-1763] add Arch Linux config.layout
    Author: Galen Sampson <ga...@gmail.com>
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3c51b612/proxy/http/HttpSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 27a687a..bbd6495 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -783,7 +783,10 @@ HttpSM::state_read_client_request_header(int event, void *data)
       ua_session->m_active = true;
       HTTP_INCREMENT_DYN_STAT(http_current_active_client_connections_stat);
     }
-    if (t_state.hdr_info.client_request.method_get_wksidx() == HTTP_WKSIDX_GET) {
+    if (t_state.hdr_info.client_request.method_get_wksidx() == HTTP_WKSIDX_TRACE ||
+         (t_state.hdr_info.request_content_length == 0 &&
+          t_state.client_info.transfer_encoding != HttpTransact::CHUNKED_ENCODING)) {
+
       // Enable further IO to watch for client aborts
       ua_entry->read_vio->reenable();
     } else {
@@ -1888,9 +1891,9 @@ HttpSM::state_send_server_request_header(int event, void *data)
     server_entry->write_buffer = NULL;
     method = t_state.hdr_info.server_request.method_get_wksidx();
     if (!t_state.api_server_request_body_set &&
-        (method != HTTP_WKSIDX_GET) &&
-        (method == HTTP_WKSIDX_POST || method == HTTP_WKSIDX_PUT ||
-         (t_state.hdr_info.extension_method && t_state.hdr_info.request_content_length > 0))) {
+         method != HTTP_WKSIDX_TRACE &&
+         (t_state.hdr_info.request_content_length > 0 || t_state.client_info.transfer_encoding == HttpTransact::CHUNKED_ENCODING)) {
+
       if (post_transform_info.vc) {
         setup_transform_to_server_transfer();
       } else {
@@ -4900,7 +4903,9 @@ HttpSM::handle_http_server_open()
   }
 
   int method = t_state.hdr_info.server_request.method_get_wksidx();
-  if ((method == HTTP_WKSIDX_POST || method == HTTP_WKSIDX_PUT) && do_post_transform_open()) {
+  if (method != HTTP_WKSIDX_TRACE &&
+      (t_state.hdr_info.request_content_length > 0 || t_state.client_info.transfer_encoding == HttpTransact::CHUNKED_ENCODING) &&
+       do_post_transform_open()) {
     do_setup_post_tunnel(HTTP_TRANSFORM_VC);
   } else {
     setup_server_send_request_api();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3c51b612/proxy/http/HttpTransact.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index 6626c1d..e5f2394 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -5261,6 +5261,23 @@ HttpTransact::RequestError_t HttpTransact::check_request_validity(State* s, HTTP
   int scheme = incoming_url->scheme_get_wksidx();
   int method = incoming_hdr->method_get_wksidx();
 
+  // Check for chunked encoding
+  if (incoming_hdr->presence(MIME_PRESENCE_TRANSFER_ENCODING)) {
+    MIMEField *field = incoming_hdr->field_find(MIME_FIELD_TRANSFER_ENCODING, MIME_LEN_TRANSFER_ENCODING);
+    HdrCsvIter enc_val_iter;
+    int enc_val_len;
+    const char *enc_value = enc_val_iter.get_first(field, &enc_val_len);
+
+    while (enc_value) {
+      const char *wks_value = hdrtoken_string_to_wks(enc_value, enc_val_len);
+      if (wks_value == HTTP_VALUE_CHUNKED) {
+          s->client_info.transfer_encoding = CHUNKED_ENCODING;
+        break;
+      }
+        enc_value = enc_val_iter.get_next(&enc_val_len);
+    }
+  }
+
   if (!((scheme == URL_WKSIDX_HTTP) && (method == HTTP_WKSIDX_GET))) {
     if (scheme != URL_WKSIDX_HTTP && scheme != URL_WKSIDX_HTTPS &&
         method != HTTP_WKSIDX_CONNECT) {
@@ -5278,33 +5295,13 @@ HttpTransact::RequestError_t HttpTransact::check_request_validity(State* s, HTTP
       return BAD_CONNECT_PORT;
     }
 
+    // Require Content-Length/Transfer-Encoding for POST/PUSH/PUT
     if ((scheme == URL_WKSIDX_HTTP || scheme == URL_WKSIDX_HTTPS) &&
-        (method == HTTP_WKSIDX_POST || method == HTTP_WKSIDX_PUSH || method == HTTP_WKSIDX_PUT)) {
-      if (!incoming_hdr->presence(MIME_PRESENCE_CONTENT_LENGTH)) {
-        bool chunked_encoding = false;
-
-        if (incoming_hdr->presence(MIME_PRESENCE_TRANSFER_ENCODING)) {
-          MIMEField *field = incoming_hdr->field_find(MIME_FIELD_TRANSFER_ENCODING, MIME_LEN_TRANSFER_ENCODING);
-          HdrCsvIter enc_val_iter;
-          int enc_val_len;
-          const char *enc_value = enc_val_iter.get_first(field, &enc_val_len);
-
-          while (enc_value) {
-            const char *wks_value = hdrtoken_string_to_wks(enc_value, enc_val_len);
-
-            if (wks_value == HTTP_VALUE_CHUNKED) {
-              chunked_encoding = true;
-              break;
-            }
-            enc_value = enc_val_iter.get_next(&enc_val_len);
-          }
-        }
+        (method == HTTP_WKSIDX_POST || method == HTTP_WKSIDX_PUSH || method == HTTP_WKSIDX_PUT) &&
+        ! incoming_hdr->presence(MIME_PRESENCE_CONTENT_LENGTH) &&
+        ! s->client_info.transfer_encoding == CHUNKED_ENCODING) {
 
-        if (!chunked_encoding)
           return NO_POST_CONTENT_LENGTH;
-        else
-          s->client_info.transfer_encoding = CHUNKED_ENCODING;
-      }
     }
   }
   // Check whether a Host header field is missing in the request.
@@ -5656,12 +5653,10 @@ HttpTransact::initialize_state_variables_from_request(State* s, HTTPHdr* obsolet
     s->hdr_info.extension_method = true;
   }
 
-  ////////////////////////////////////////////////
-  // get request content length for POST or PUT //
-  ////////////////////////////////////////////////
-  if ((s->method != HTTP_WKSIDX_GET) &&
-      (s->method == HTTP_WKSIDX_POST || s->method == HTTP_WKSIDX_PUT ||
-       s->method == HTTP_WKSIDX_PUSH || s->hdr_info.extension_method)) {
+  //////////////////////////////////////////////////
+  // get request content length 									//
+  //////////////////////////////////////////////////
+  if (s->method != HTTP_WKSIDX_TRACE) {
     int64_t length = incoming_request->get_content_length();
     s->hdr_info.request_content_length = (length >= 0) ? length : HTTP_UNDEFINED_CL;    // content length less than zero is invalid
 
@@ -5672,19 +5667,8 @@ HttpTransact::initialize_state_variables_from_request(State* s, HTTPHdr* obsolet
     s->hdr_info.request_content_length = 0;
   }
   // if transfer encoding is chunked content length is undefined
-  if (incoming_request->presence(MIME_PRESENCE_TRANSFER_ENCODING)) {
-    MIMEField *field = incoming_request->field_find(MIME_FIELD_TRANSFER_ENCODING, MIME_LEN_TRANSFER_ENCODING);
-    HdrCsvIter enc_val_iter;
-    int enc_val_len;
-    const char *enc_value = enc_val_iter.get_first(field, &enc_val_len);
-
-    while (enc_value) {
-      const char *wks_value = hdrtoken_string_to_wks(enc_value, enc_val_len);
-
-      if (wks_value == HTTP_VALUE_CHUNKED)
-        s->hdr_info.request_content_length = HTTP_UNDEFINED_CL;
-      enc_value = enc_val_iter.get_next(&enc_val_len);
-    }
+  if (s->client_info.transfer_encoding == CHUNKED_ENCODING) {
+    s->hdr_info.request_content_length = HTTP_UNDEFINED_CL;
   }
   s->request_data.hdr = &s->hdr_info.client_request;
   s->request_data.hostname_str = s->arena.str_store(host_name, host_len);
@@ -6699,126 +6683,100 @@ HttpTransact::will_this_request_self_loop(State* s)
 void
 HttpTransact::handle_content_length_header(State* s, HTTPHdr* header, HTTPHdr* base)
 {
-  if (header->type_get() == HTTP_TYPE_RESPONSE) {
-    // This isn't used.
-    // int status_code = base->status_get();
-    int64_t cl = HTTP_UNDEFINED_CL;
-    if (base->presence(MIME_PRESENCE_CONTENT_LENGTH)) {
-      cl = base->get_content_length();
-      if (cl >= 0) {
-        // header->set_content_length(cl);
-        ink_debug_assert(header->get_content_length() == cl);
-
-        switch (s->source) {
-        case SOURCE_HTTP_ORIGIN_SERVER:
-          // We made our decision about whether to trust the
-          //   response content length in init_state_vars_from_response()
-          if (s->range_setup != HttpTransact::RANGE_NOT_TRANSFORM_REQUESTED)
-            break;
-        case SOURCE_CACHE:
-          
-          // if we are doing a single Range: request, calculate the new
-          // C-L: header
-          if (s->range_setup == HttpTransact::RANGE_NOT_TRANSFORM_REQUESTED) {
-            Debug("http_trans", "Partial content requested, re-calculating content-length");
-            change_response_header_because_of_range_request(s,header);
-            s->hdr_info.trust_response_cl = true;
-          }
-          ////////////////////////////////////////////////
-          //  Make sure that the cache's object size    //
-          //   agrees with the Content-Length           //
-          //   Otherwise, set the state's machine view  //
-          //   of c-l to undefined to turn off K-A      //
-          ////////////////////////////////////////////////
-          else if ((int64_t) s->cache_info.object_read->object_size_get() == cl) {
-            s->hdr_info.trust_response_cl = true;
-          } else {
-            DebugTxn("http_trans", "Content Length header and cache object size mismatch." "Disabling keep-alive");
-            s->hdr_info.trust_response_cl = false;
-          }
-          break;
-        case SOURCE_TRANSFORM:
-          if (s->hdr_info.transform_response_cl == HTTP_UNDEFINED_CL) {
-            s->hdr_info.trust_response_cl = false;
-          } else {
-            s->hdr_info.trust_response_cl = true;
-          }
-          break;
-        default:
-          ink_release_assert(0);
+  int64_t cl = HTTP_UNDEFINED_CL;
+  ink_debug_assert(header->type_get() == HTTP_TYPE_RESPONSE);
+  if (base->presence(MIME_PRESENCE_CONTENT_LENGTH)) {
+    cl = base->get_content_length();
+    if (cl >= 0) {
+      // header->set_content_length(cl);
+      ink_debug_assert(header->get_content_length() == cl);
+
+      switch (s->source) {
+      case SOURCE_HTTP_ORIGIN_SERVER:
+        // We made our decision about whether to trust the
+        //   response content length in init_state_vars_from_response()
+        if (s->range_setup != HttpTransact::RANGE_NOT_TRANSFORM_REQUESTED)
           break;
-        }
-      } else {
-        header->field_delete(MIME_FIELD_CONTENT_LENGTH, MIME_LEN_CONTENT_LENGTH);
-        s->hdr_info.trust_response_cl = false;
-      }
-      Debug("http_trans", "[handle_content_length_header] RESPONSE cont len in hdr is %" PRId64, header->get_content_length());
-    } else {
-      // No content length header
-      if (s->source == SOURCE_CACHE) {
-        // If there is no content-length header, we can
-        //   insert one since the cache knows definately
-        //   how long the object is unless we're in a
-        //   read-while-write mode and object hasn't been
-        //   written into a cache completely.
-        cl = s->cache_info.object_read->object_size_get();
-        if (cl == INT64_MAX) { //INT64_MAX cl in cache indicates rww in progress
-          header->field_delete(MIME_FIELD_CONTENT_LENGTH, MIME_LEN_CONTENT_LENGTH);
-          s->hdr_info.trust_response_cl = false;
-          s->hdr_info.request_content_length = HTTP_UNDEFINED_CL;
-          ink_assert(s->range_setup == RANGE_NONE);
-        } 
-        else if (s->range_setup == RANGE_NOT_TRANSFORM_REQUESTED) {
-          // if we are doing a single Range: request, calculate the new
-          // C-L: header
+      case SOURCE_CACHE:
+
+        // if we are doing a single Range: request, calculate the new
+        // C-L: header
+        if (s->range_setup == HttpTransact::RANGE_NOT_TRANSFORM_REQUESTED) {
           Debug("http_trans", "Partial content requested, re-calculating content-length");
           change_response_header_because_of_range_request(s,header);
           s->hdr_info.trust_response_cl = true;
         }
-        else {
-          header->set_content_length(cl);
-          s->hdr_info.trust_response_cl = true;
-        }
-      } else {
-        // Check to see if there is no content length
-        //  header because the response precludes a
-        // body
-        if (is_response_body_precluded(header->status_get(), s->method)) {
-          // We want to be able to do keep-alive here since
-          //   there can't be body so we don't have any
-          //   issues about trusting the body length
+        ////////////////////////////////////////////////
+        //  Make sure that the cache's object size    //
+        //   agrees with the Content-Length           //
+        //   Otherwise, set the state's machine view  //
+        //   of c-l to undefined to turn off K-A      //
+        ////////////////////////////////////////////////
+        else if ((int64_t) s->cache_info.object_read->object_size_get() == cl) {
           s->hdr_info.trust_response_cl = true;
         } else {
+          DebugTxn("http_trans", "Content Length header and cache object size mismatch." "Disabling keep-alive");
           s->hdr_info.trust_response_cl = false;
         }
-        header->field_delete(MIME_FIELD_CONTENT_LENGTH, MIME_LEN_CONTENT_LENGTH);
-        ink_assert(s->range_setup != RANGE_NOT_TRANSFORM_REQUESTED);
+        break;
+      case SOURCE_TRANSFORM:
+        if (s->hdr_info.transform_response_cl == HTTP_UNDEFINED_CL) {
+          s->hdr_info.trust_response_cl = false;
+        } else {
+          s->hdr_info.trust_response_cl = true;
+        }
+        break;
+      default:
+        ink_release_assert(0);
+        break;
       }
-    }
-  } else if (header->type_get() == HTTP_TYPE_REQUEST) {
-    int method = header->method_get_wksidx();
-
-    if (method == HTTP_WKSIDX_GET || method == HTTP_WKSIDX_HEAD || method == HTTP_WKSIDX_OPTIONS || method == HTTP_WKSIDX_TRACE) {      /* No body, no content-length */
-
+    } else {
       header->field_delete(MIME_FIELD_CONTENT_LENGTH, MIME_LEN_CONTENT_LENGTH);
-      s->hdr_info.request_content_length = 0;
-
-    } else if (base && base->presence(MIME_PRESENCE_CONTENT_LENGTH)) {
-      /* Copy over the content length if its set */
-      ink_debug_assert(s->hdr_info.request_content_length == base->get_content_length());
-      ink_debug_assert(header->get_content_length() == base->get_content_length());
+      s->hdr_info.trust_response_cl = false;
+    }
+    Debug("http_trans", "[handle_content_length_header] RESPONSE cont len in hdr is %" PRId64, header->get_content_length());
+  } else {
+    // No content length header
+    if (s->source == SOURCE_CACHE) {
+      // If there is no content-length header, we can
+      //   insert one since the cache knows definately
+      //   how long the object is unless we're in a
+      //   read-while-write mode and object hasn't been
+      //   written into a cache completely.
+      cl = s->cache_info.object_read->object_size_get();
+      if (cl == INT64_MAX) { //INT64_MAX cl in cache indicates rww in progress
+        header->field_delete(MIME_FIELD_CONTENT_LENGTH, MIME_LEN_CONTENT_LENGTH);
+        s->hdr_info.trust_response_cl = false;
+        s->hdr_info.request_content_length = HTTP_UNDEFINED_CL;
+        ink_assert(s->range_setup == RANGE_NONE);
+      }
+      else if (s->range_setup == RANGE_NOT_TRANSFORM_REQUESTED) {
+        // if we are doing a single Range: request, calculate the new
+        // C-L: header
+        Debug("http_trans", "Partial content requested, re-calculating content-length");
+        change_response_header_because_of_range_request(s,header);
+        s->hdr_info.trust_response_cl = true;
+      }
+      else {
+        header->set_content_length(cl);
+        s->hdr_info.trust_response_cl = true;
+      }
     } else {
-      /*
-       * Otherwise we are in a method with a potential cl, so unset
-       * the header and flag the cl as undefined for the state machine.
-       */
+      // Check to see if there is no content length
+      //  header because the response precludes a
+      // body
+      if (is_response_body_precluded(header->status_get(), s->method)) {
+        // We want to be able to do keep-alive here since
+        //   there can't be body so we don't have any
+        //   issues about trusting the body length
+        s->hdr_info.trust_response_cl = true;
+      } else {
+        s->hdr_info.trust_response_cl = false;
+      }
       header->field_delete(MIME_FIELD_CONTENT_LENGTH, MIME_LEN_CONTENT_LENGTH);
-      s->hdr_info.request_content_length = HTTP_UNDEFINED_CL;
+      ink_assert(s->range_setup != RANGE_NOT_TRANSFORM_REQUESTED);
     }
-    DebugTxn("http_trans", "[handle_content_length_header] cont len in hdr is %" PRId64", stat var is %" PRId64,
-          header->get_content_length(), s->hdr_info.request_content_length);
   }
-
   return;
 }                               /* End HttpTransact::handle_content_length_header */
 


[18/51] git commit: TS-1660 Host field should not has c style terminator

Posted by zw...@apache.org.
TS-1660 Host field should not has c style terminator


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/8d6562ba
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/8d6562ba
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/8d6562ba

Branch: refs/heads/3.3.x
Commit: 8d6562ba44b408b48192b4b6951c669b3236dda0
Parents: 0f43630
Author: weijin <weilogster at 126 dot com>
Authored: Wed Mar 20 14:34:13 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Wed Mar 20 14:34:13 2013 -0600

----------------------------------------------------------------------
 proxy/http/HttpTransact.cc |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8d6562ba/proxy/http/HttpTransact.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index e5f2394..931fe80 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -5254,7 +5254,7 @@ HttpTransact::RequestError_t HttpTransact::check_request_validity(State* s, HTTP
     return MISSING_HOST_FIELD;
   }
 
-  if (hostname_len >= MAXDNAME || hostname_len <= 0) {
+  if (hostname_len >= MAXDNAME || hostname_len <= 0 || memchr(hostname, '\0', hostname_len)) {
     return BAD_HTTP_HEADER_SYNTAX;
   }
 


[45/51] git commit: TS-1781: Make clang happy and esi compile

Posted by zw...@apache.org.
TS-1781: Make clang happy and esi compile


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/4e53792f
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/4e53792f
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/4e53792f

Branch: refs/heads/3.3.x
Commit: 4e53792f2740de507b6fd51f0d34f6bf4f780852
Parents: 7b6a4dd
Author: Igor Galić <i....@brainsware.org>
Authored: Wed Mar 27 00:47:21 2013 +0100
Committer: Igor Galić <i....@brainsware.org>
Committed: Wed Mar 27 00:47:21 2013 +0100

----------------------------------------------------------------------
 plugins/experimental/esi/lib/EsiProcessor.cc |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4e53792f/plugins/experimental/esi/lib/EsiProcessor.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/esi/lib/EsiProcessor.cc b/plugins/experimental/esi/lib/EsiProcessor.cc
index ed4868b..96a647e 100644
--- a/plugins/experimental/esi/lib/EsiProcessor.cc
+++ b/plugins/experimental/esi/lib/EsiProcessor.cc
@@ -422,7 +422,7 @@ EsiProcessor::flush(string &data, int &overall_len) {
           const Attribute &url = (*node_iter).attr_list.front();              
           string raw_url(url.value, url.value_len);
           attemptUrls.push_back(_expression.expand(raw_url));
-        if (!_getIncludeStatus(*node_iter) == STATUS_ERROR) {
+        if (_getIncludeStatus(*node_iter) != STATUS_DATA_AVAILABLE) {
           attempt_succeeded = false;
           _errorLog("[%s] attempt section errored; due to url [%s]", __FUNCTION__, raw_url.c_str());
           break;


[35/51] git commit: TS-1724: Add tool to compare records.config files to contrib

Posted by zw...@apache.org.
TS-1724: Add tool to compare records.config files to contrib


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/63098358
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/63098358
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/63098358

Branch: refs/heads/3.3.x
Commit: 63098358054c1e605c42f71815dd7a6a4ab85e56
Parents: 02eb936
Author: Mark Harrison <ma...@mivok.net>
Authored: Sun Mar 24 17:23:28 2013 -0400
Committer: Phil Sorber <so...@apache.org>
Committed: Sun Mar 24 17:23:28 2013 -0400

----------------------------------------------------------------------
 CHANGES                                  |    3 +
 contrib/python/compare_records_config.py |   67 +++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63098358/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 4212088..760d532 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1724] Add tool to compare records.config files to contrib
+   Author: Mark Harrison <ma...@mivok.net>
+
   *) [TS-1566] dynamic update for string vars does not work
    Author: Aidan McGurn <ai...@openwave.com>
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63098358/contrib/python/compare_records_config.py
----------------------------------------------------------------------
diff --git a/contrib/python/compare_records_config.py b/contrib/python/compare_records_config.py
new file mode 100644
index 0000000..a8283a3
--- /dev/null
+++ b/contrib/python/compare_records_config.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Compares two records.config files, printing which items are different and
+# what the before/after values are.
+# Ignores FLOAT differences and @foo@ values from the source code defaults.
+import sys
+
+def parse_records_file(filename):
+    fh = open(filename)
+    settings = {}
+    for line in fh:
+        line = line.strip()
+        if line.startswith('CONFIG') or line.startswith('LOCAL'):
+            parts = line.split()
+            if parts[2] == 'FLOAT':
+                parts[3] = parts[3].rstrip('0')
+            if parts[2] == 'INT' and parts[3][-1] in 'KMG':
+                unit = parts[3][-1]
+                val = parts[3][:-1]
+                if unit == 'K':
+                    val = int(val) * 1024
+                if unit == 'M':
+                    val = int(val) * 1048576
+                if unit == 'G':
+                    val = int(val) * 1073741824
+                parts[3] = str(val)
+            try:
+                settings[parts[1]] = parts[3]
+            except IndexError:
+                sys.stderr.write("Skipping malformed line: %s\n" % line)
+                continue
+    return settings
+
+def compare_settings(old, new):
+    for key in sorted(tuple(set(old) | set(new))):
+        if key not in old:
+            old[key] = "missing"
+        if key not in new:
+            new[key] = "missing"
+
+    for key in sorted(old):
+        if old[key].startswith('@') and old[key].endswith('@'):
+            # Skip predefined values
+            continue
+        if old[key] != new[key]:
+            print "%s %s -> %s" % (key, old[key], new[key])
+
+if __name__ == '__main__':
+    settings_orig = parse_records_file(sys.argv[1])
+    settings_new = parse_records_file(sys.argv[2])
+    compare_settings(settings_orig, settings_new)


[33/51] git commit: TS-1566: dynamic update for string vars does not work

Posted by zw...@apache.org.
TS-1566: dynamic update for string vars does not work


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/da19639e
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/da19639e
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/da19639e

Branch: refs/heads/3.3.x
Commit: da19639e0b0338b78b69e11e0fd4e3a0c5220b6b
Parents: ec01961
Author: Aidan McGurn <ai...@openwave.com>
Authored: Fri Mar 22 10:27:43 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Fri Mar 22 10:29:06 2013 -0700

----------------------------------------------------------------------
 CHANGES                |    3 +++
 lib/records/RecCore.cc |   18 +++++++++---------
 2 files changed, 12 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/da19639e/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 61e5938..4212088 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1566] dynamic update for string vars does not work
+   Author: Aidan McGurn <ai...@openwave.com>
+
   *) [TS-1708] Using tr-pass port option causes requests with large headers to hang
 
   *) [TS-1734] Remove dead code that invokes missing vmap_config tool

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/da19639e/lib/records/RecCore.cc
----------------------------------------------------------------------
diff --git a/lib/records/RecCore.cc b/lib/records/RecCore.cc
index 4888fbb..be3a2fd 100644
--- a/lib/records/RecCore.cc
+++ b/lib/records/RecCore.cc
@@ -143,30 +143,30 @@ link_byte(const char *name, RecDataT data_type, RecData data, void *cookie)
 }
 
 // mimic Config.cc::config_string_alloc_cb
+// cookie e.g. is the DEFAULT_xxx_str value which this functiion keeps up to date with
+// the latest default applied during a config update from records.config
 static int
 link_string_alloc(const char *name, RecDataT data_type, RecData data, void *cookie)
 {
   REC_NOWARN_UNUSED(name);
   REC_NOWARN_UNUSED(data_type);
 
-  RecString _ss = (RecString) cookie;
-  RecString _new_value = 0;
+  RecString _ss = data.rec_string;
+  RecString _new_value = NULL;
 
-  int len = -1;
   if (_ss) {
-    len = strlen(_ss);
-    _new_value = (RecString)ats_malloc(len + 1);
-    memcpy(_new_value, _ss, len + 1);
+    _new_value = ats_strdup(_ss);
   }
 
-  RecString _temp2 = data.rec_string;
-  data.rec_string = _new_value;
+  // set new string for DEFAULT_xxx_str tp point to
+  RecString _temp2 = *((RecString *)cookie);
+  *((RecString *)cookie) = _new_value;
+  // free previous string DEFAULT_xxx_str points to
   ats_free(_temp2);
 
   return REC_ERR_OKAY;
 }
 
-
 //-------------------------------------------------------------------------
 // RecCoreInit
 //-------------------------------------------------------------------------


[19/51] git commit: Added TS-1660.

Posted by zw...@apache.org.
Added TS-1660.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/66192fca
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/66192fca
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/66192fca

Branch: refs/heads/3.3.x
Commit: 66192fca60169a2bd0d5a6b835677eb40c2fcf6d
Parents: 8d6562b
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed Mar 20 14:34:52 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Wed Mar 20 14:34:52 2013 -0600

----------------------------------------------------------------------
 CHANGES |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/66192fca/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index a60d138..b60079d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1660] Host field should not has c style terminator.
+
   *) [TS-1627] Support requests with payload
 
   *) [TS-1763] add Arch Linux config.layout


[30/51] git commit: TS-1734: fix wrong jira number

Posted by zw...@apache.org.
TS-1734: fix wrong jira number


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/1a2ebccb
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/1a2ebccb
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/1a2ebccb

Branch: refs/heads/3.3.x
Commit: 1a2ebccb112987acf450a5d678b6185c5d98257f
Parents: dbf7124
Author: James Peach <jp...@apache.org>
Authored: Thu Mar 21 12:22:10 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu Mar 21 12:22:10 2013 -0700

----------------------------------------------------------------------
 CHANGES |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1a2ebccb/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 04ad34d..4669806 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,7 +2,7 @@
   Changes with Apache Traffic Server 3.3.2
 
 
-  *) [TS-1735] Remove dead code that invokes missing vmap_config tool
+  *) [TS-1734] Remove dead code that invokes missing vmap_config tool
    Author: John Kew <jo...@gmail.com>
 
   *) [TS-1660] Host field should not has c style terminator.


[28/51] git commit: TS-1742 just make the regression test passed if cas128 enabled

Posted by zw...@apache.org.
TS-1742 just make the regression test passed if cas128 enabled


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/ae085945
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ae085945
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ae085945

Branch: refs/heads/3.3.x
Commit: ae085945184c43195d825a6be72a259b84d9df33
Parents: bd8fd4f
Author: weijin <ta...@taobao.com>
Authored: Fri Mar 22 02:09:10 2013 +0800
Committer: weijin <ta...@taobao.com>
Committed: Fri Mar 22 02:10:35 2013 +0800

----------------------------------------------------------------------
 iocore/eventsystem/P_UnixEventProcessor.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ae085945/iocore/eventsystem/P_UnixEventProcessor.h
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/P_UnixEventProcessor.h b/iocore/eventsystem/P_UnixEventProcessor.h
index 0c89f7c..7249770 100644
--- a/iocore/eventsystem/P_UnixEventProcessor.h
+++ b/iocore/eventsystem/P_UnixEventProcessor.h
@@ -44,9 +44,9 @@ thread_data_used(0)
 TS_INLINE off_t
 EventProcessor::allocate(int size)
 {
-  static off_t start = (offsetof(EThread, thread_private) + 7) & ~7;
+  static off_t start = INK_ALIGN(offsetof(EThread, thread_private), 16);
   static off_t loss = start - offsetof(EThread, thread_private);
-  size = (size + 7) & ~7;       // 8 byte alignment
+  size = INK_ALIGN(size, 16);       // 16 byte alignment
 
   int old;
   do {


[04/51] git commit: Update vagrant configuration for vagrant 1.1

Posted by zw...@apache.org.
Update vagrant configuration for vagrant 1.1


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/a9b65160
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/a9b65160
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/a9b65160

Branch: refs/heads/3.3.x
Commit: a9b6516089a843249d3cb978c746472cc99a3fe3
Parents: 70f224d
Author: James Peach <jp...@apache.org>
Authored: Fri Mar 15 16:39:56 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Fri Mar 15 16:39:56 2013 -0700

----------------------------------------------------------------------
 Vagrantfile                 |   10 ++++++----
 contrib/manifests/debian.pp |    2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a9b65160/Vagrantfile
----------------------------------------------------------------------
diff --git a/Vagrantfile b/Vagrantfile
index e316cae..d40799d 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -14,20 +14,22 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 
-Vagrant::Config.run do |config|
+Vagrant.configure("2") do |config|
 
   # Default all VMs to 1GB.
-  config.vm.customize ["modifyvm", :id, "--memory", 1024]
+  config.vm.provider :virtualbox do |v|
+    v.customize ["modifyvm", :id, "--memory", 1024]
+  end
 
   # Mount the Traffic Server source code in a fixed location everywhere. Use NFS
   # because it's faster and vboxfs doesn't support links.
-  config.vm.share_folder "src", "/opt/src/trafficserver.git", ".", :nfs => true
+  config.vm.synced_folder ".", "/opt/src/trafficserver.git", :nfs => true
 
   # Ubuntu 12.04 LTS (Precise Pangolin)
   config.vm.define :precise64 do | config |
     config.vm.box = "precise64"
     config.vm.box_url = "http://files.vagrantup.com/precise64.box"
-    config.vm.network :hostonly, "192.168.100.3"
+    config.vm.network :private_network, ip: "192.168.100.3"
     config.vm.provision :puppet do |puppet|
       puppet.manifests_path = "contrib/manifests"
       puppet.manifest_file = "debian.pp"

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a9b65160/contrib/manifests/debian.pp
----------------------------------------------------------------------
diff --git a/contrib/manifests/debian.pp b/contrib/manifests/debian.pp
index a21d404..d495226 100644
--- a/contrib/manifests/debian.pp
+++ b/contrib/manifests/debian.pp
@@ -25,7 +25,7 @@ package {[
 
 # Development extras.
 package {[
-    'gdb', ,valgrind', 'git', 'ack-grep', 'curl', 'tmux', 'screen'
+    'gdb', 'valgrind', 'git', 'ack-grep', 'curl', 'tmux', 'screen'
   ]:
   ensure => latest
 }


[48/51] git commit: TS-1790: authproxy should accept 2xx as authorization success

Posted by zw...@apache.org.
TS-1790: authproxy should accept 2xx as authorization success


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/52f24094
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/52f24094
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/52f24094

Branch: refs/heads/3.3.x
Commit: 52f240943554ee5fb3d7bbf82e792517878e426d
Parents: e1e83f8
Author: James Peach <jp...@apache.org>
Authored: Fri Mar 29 11:08:46 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Fri Mar 29 11:08:46 2013 -0700

----------------------------------------------------------------------
 CHANGES                                     |    3 +++
 plugins/experimental/authproxy/authproxy.cc |    4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/52f24094/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index b319e6a..5aee40e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
   Changes with Apache Traffic Server 3.3.2
 
+
+  *) [TS-1790] authproxy should accept 2xx as authorization success
+
   *) [TS-1780] Fix Debuntu build with hardening flags
 
   *) [TS-1623, TS-1625] Fixes for logging where the host name was not handled

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/52f24094/plugins/experimental/authproxy/authproxy.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/authproxy/authproxy.cc b/plugins/experimental/authproxy/authproxy.cc
index 9f16f9a..10bc7b5 100644
--- a/plugins/experimental/authproxy/authproxy.cc
+++ b/plugins/experimental/authproxy/authproxy.cc
@@ -461,8 +461,8 @@ StateAuthProxyCompleteHeaders(AuthRequestContext * auth, void * edata)
     status = TSHttpHdrStatusGet(auth->rheader.buffer, auth->rheader.header);
     AuthLogDebug("authorization proxy returned status %d", (int)status);
 
-    // Authorize the original request on a 200 response.
-    if (status == TS_HTTP_STATUS_OK) {
+    // Authorize the original request on a 2xx response.
+    if (status >= 200 && status < 300) {
         return TS_EVENT_IMMEDIATE;
     }
 


[46/51] git commit: Remove config.nice during distclean.

Posted by zw...@apache.org.
Remove config.nice during distclean.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/5774cc43
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/5774cc43
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/5774cc43

Branch: refs/heads/3.3.x
Commit: 5774cc439294a99dc8f1661da401fa93ed1c8514
Parents: 4e53792
Author: James Peach <jp...@apache.org>
Authored: Thu Mar 28 11:19:30 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu Mar 28 11:19:30 2013 -0700

----------------------------------------------------------------------
 Makefile.am |   29 ++++++++++++++++-------------
 1 files changed, 16 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5774cc43/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index 939f822..46cf284 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -44,6 +44,9 @@ test: check
 installcheck-local:
 	$(DESTDIR)$(bindir)/traffic_server -R 1
 
+distclean-local:
+	-rm -f config.nice
+
 doxygen:
 	@cd doc && $(MAKE) $(AM_MAKEFLAGS) $@
 
@@ -73,17 +76,17 @@ install-data-hook:
 
 help:
 	@echo 'all              default target for building the package' && \
-   echo 'check            run the test suite, if any' && \
-   echo 'clean            remove whatever make created' && \
-   echo 'distclean        remove whatever configure created' && \
-   echo 'dist             DEPRECATED: recreate source package' && \
-   echo 'examples         make examples' && \
-   echo 'asf-dist         recreate source package' && \
-   echo 'asf-dist-sign    recreate source package, with checksums and signature' && \
-   echo 'distcheck        verify dist by performing VPATH build and then distclean' && \
-   echo 'doxygen          generate doxygen docs in doc/html dir' && \
-   echo 'help             display this list of make targets' && \
-   echo 'install          install by copying the built files to system-wide dirs' && \
-   echo 'install-strip    same as install but then strips debugging symbols' && \
-   echo 'install-examples install examples by copying the built files to system-wide dirs'
+	echo 'check            run the test suite, if any' && \
+	echo 'clean            remove whatever make created' && \
+	echo 'distclean        remove whatever configure created' && \
+	echo 'dist             DEPRECATED: recreate source package' && \
+	echo 'examples         make examples' && \
+	echo 'asf-dist         recreate source package' && \
+	echo 'asf-dist-sign    recreate source package, with checksums and signature' && \
+	echo 'distcheck        verify dist by performing VPATH build and then distclean' && \
+	echo 'doxygen          generate doxygen docs in doc/html dir' && \
+	echo 'help             display this list of make targets' && \
+	echo 'install          install by copying the built files to system-wide dirs' && \
+	echo 'install-strip    same as install but then strips debugging symbols' && \
+	echo 'install-examples install examples by copying the built files to system-wide dirs'
 


[36/51] git commit: Unify MAX/MIN definitions (in ink_defs.h). Also clean up the checks of gcc prior to v3.x (which we no long support).

Posted by zw...@apache.org.
Unify MAX/MIN definitions (in ink_defs.h). Also clean up the checks of
gcc prior to v3.x (which we no long support).


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/965c40f2
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/965c40f2
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/965c40f2

Branch: refs/heads/3.3.x
Commit: 965c40f2d12f028d4cf027fe77a72847f6ebe1e2
Parents: 6309835
Author: Leif Hedstrom <zw...@apache.org>
Authored: Sun Mar 24 18:28:28 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Sun Mar 24 18:28:28 2013 -0600

----------------------------------------------------------------------
 CHANGES                                    |    3 ++
 example/remap/remap.cc                     |   16 +------------
 example/thread-pool/psi.c                  |    3 +-
 iocore/net/NetVCTest.cc                    |    7 -----
 iocore/net/P_InkBulkIO.h                   |    7 -----
 lib/ts/ink_defs.h                          |   18 ++++++++++++--
 lib/ts/ink_unused.h                        |   29 +---------------------
 mgmt/cli/cliAppInit.cc                     |    6 +----
 plugins/experimental/geoip_acl/lulu.h      |   14 +++--------
 plugins/experimental/header_rewrite/lulu.h |   11 +-------
 plugins/experimental/spdy/protocol.cc      |    6 +---
 plugins/header_filter/lulu.h               |   12 ++-------
 proxy/InkAPITestTool.cc                    |    3 --
 proxy/MuxVC.cc                             |    3 --
 proxy/PluginVC.cc                          |    5 ----
 proxy/api/ts/ts.h.in                       |    4 ---
 proxy/http/HttpTunnel.cc                   |    7 -----
 proxy/logstats.cc                          |    6 ----
 18 files changed, 34 insertions(+), 126 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 760d532..06974cf 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1764] Unify MAX/MIN definitions (in ink_defs.h). Also clean
+   up the checks of gcc prior to v3.x (which we no long support).
+
   *) [TS-1724] Add tool to compare records.config files to contrib
    Author: Mark Harrison <ma...@mivok.net>
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/example/remap/remap.cc
----------------------------------------------------------------------
diff --git a/example/remap/remap.cc b/example/remap/remap.cc
index f316ca4..da5d5ed 100644
--- a/example/remap/remap.cc
+++ b/example/remap/remap.cc
@@ -47,21 +47,7 @@
 #include <ts/ts.h>
 #include <ts/remap.h>
 
-#if __GNUC__ >= 3
-#ifndef likely
-#define likely(x)   __builtin_expect (!!(x),1)
-#endif
-#ifndef unlikely
-#define unlikely(x) __builtin_expect (!!(x),0)
-#endif
-#else
-#ifndef likely
-#define likely(x)   (x)
-#endif
-#ifndef unlikely
-#define unlikely(x) (x)
-#endif
-#endif /* #if __GNUC__ >= 3 */
+#include "ink_unused.h"
 
 class remap_entry
 {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/example/thread-pool/psi.c
----------------------------------------------------------------------
diff --git a/example/thread-pool/psi.c b/example/thread-pool/psi.c
index 43e0a40..b10aeca 100644
--- a/example/thread-pool/psi.c
+++ b/example/thread-pool/psi.c
@@ -52,8 +52,7 @@
 #include <ts/ts.h>
 
 #include "thread.h"
-
-#define MIN(x,y) ((x < y) ? x :y)
+#include "ink_defs.h"
 
 #define DBG_TAG "xpsi"
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/iocore/net/NetVCTest.cc
----------------------------------------------------------------------
diff --git a/iocore/net/NetVCTest.cc b/iocore/net/NetVCTest.cc
index 0890533..8903e72 100644
--- a/iocore/net/NetVCTest.cc
+++ b/iocore/net/NetVCTest.cc
@@ -36,13 +36,6 @@
 
 #include "P_Net.h"
 
-// Get rid of any previous MIN declaration, since we have our own
-// funky MIN here. /leif
-#if defined(MIN)
-#undef MIN
-#endif
-#define MIN(x,y) (x <= y) ? x : y;
-
 // Each test requires two definition entries.  One for the passive
 //   side of the connection and one for the active side
 //

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/iocore/net/P_InkBulkIO.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_InkBulkIO.h b/iocore/net/P_InkBulkIO.h
index 96937f9..19c15c5 100644
--- a/iocore/net/P_InkBulkIO.h
+++ b/iocore/net/P_InkBulkIO.h
@@ -146,13 +146,6 @@ struct InkBulkIORequest
 #define INKBIO_SPLIT_REQUEST  0xf1
 
 /*
- * These 2 better be the same in user/kernel land
- */
-#ifndef MAX
-#define MAX(x, y) (x > y ? x : y)
-#endif
-
-/*
  * Purposely, under specify the size; we need to leave space for the "terminating" packet.
  * Every block contains at least 1 request.
  */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/lib/ts/ink_defs.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_defs.h b/lib/ts/ink_defs.h
index 2970e2b..e39aa7e 100644
--- a/lib/ts/ink_defs.h
+++ b/lib/ts/ink_defs.h
@@ -24,16 +24,26 @@
 #ifndef _ink_defs_h
 #define	_ink_defs_h
 
-/* Defines
+/* Some popular defines
 */
 #define SIZE(x) (sizeof(x)/sizeof((x)[0]))
 #define SOCKOPT_ON ((char*)&on)
 #define SOCKOPT_OFF ((char*)&off)
+
 #ifndef ABS
-#define ABS(_x_) (((_x_) < 0) ? ( - (_x_)) : (_x_))
+#define ABS(x) (((x) < 0) ? ( - (x)) : (x))
+#endif
+
+#ifndef MAX
+#define MAX(x,y) (((x) >= (y)) ? (x) : (y))
 #endif
+
+#ifndef MIN
+#define MIN(x,y) (((x) <= (y)) ? (x) : (y))
+#endif
+
 #if TS_USE_HWLOC
-#include <hwloc.h>
+#  include <hwloc.h>
 #endif
 
 /* Debugging
@@ -82,8 +92,10 @@ const hwloc_topology_t* ink_get_topology();
 
 /** Constants.
  */
+#ifdef __cplusplus
 namespace ts {
   static const int NO_FD = -1; ///< No or invalid file descriptor.
 }
+#endif
 
 #endif /*__ink_defs_h*/

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/lib/ts/ink_unused.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_unused.h b/lib/ts/ink_unused.h
index 0ca5190..3aba5f3 100644
--- a/lib/ts/ink_unused.h
+++ b/lib/ts/ink_unused.h
@@ -24,21 +24,15 @@
 #ifndef _ink_unused_h
 #define _ink_unused_h
 
-#if ((__GNUC__ >= 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
 #ifdef DEBUG
 #define RELEASE_UNUSED
 #else
 #define RELEASE_UNUSED __attribute__ ((unused))
 #endif /* #ifdef DEBUG */
+
 #define UNUSED __attribute__ ((unused))
 #define INK_UNUSED __attribute__ ((unused))
-#else
-#define UNUSED
-#define INK_UNUSED
-#define RELEASE_UNUSED
-#endif /* #if ((__GNUC__ >= 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7))) */
 
-#if __GNUC__ >= 3
 #if 0 /* NOT USED */
 # define inline               inline __attribute__ ((always_inline))
 # define __pure               __attribute__ ((pure))
@@ -50,31 +44,12 @@
 # define __unused     __attribute__ ((unused))
 # define __packed     __attribute__ ((packed))
 #endif
+
 #ifndef likely
 #define likely(x)	__builtin_expect (!!(x), 1)
 #endif
 #ifndef unlikely
 #define unlikely(x)	__builtin_expect (!!(x), 0)
 #endif
-#else
-#if 0 /* NOT USED */
-# define inline               /* no inline */
-# define __pure               /* no pure */
-# define __const      /* no const */
-# define __noreturn   /* no noreturn */
-# define __malloc     /* no malloc */
-# define __must_check /* no warn_unused_result */
-# define __deprecated /* no deprecated */
-# define __used               /* no used */
-# define __unused     /* no unused */
-# define __packed     /* no packed */
-#endif
-#ifndef likely
-#define likely(x)	(x)
-#endif
-#ifndef unlikely
-#define unlikely(x)	(x)
-#endif
-#endif /* #if __GNUC__ >= 3 */
 
 #endif /* #ifndef _ink_unused_h */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/mgmt/cli/cliAppInit.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/cliAppInit.cc b/mgmt/cli/cliAppInit.cc
index 93163e9..52c6f22 100644
--- a/mgmt/cli/cliAppInit.cc
+++ b/mgmt/cli/cliAppInit.cc
@@ -35,12 +35,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
-// Not sure if we need to worry about old gcc compilers any more, but ... /leif
-#if (__GNUC__ >= 3)
 #include <iostream>
-#else
-#include <iostream.h>
-#endif
+
 //#include "tclExtend.h"
 #include "tcl.h"
 #include <unistd.h>

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/plugins/experimental/geoip_acl/lulu.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/geoip_acl/lulu.h b/plugins/experimental/geoip_acl/lulu.h
index a4f5653..0e44509 100644
--- a/plugins/experimental/geoip_acl/lulu.h
+++ b/plugins/experimental/geoip_acl/lulu.h
@@ -24,18 +24,12 @@
 #ifndef __LULU_H__
 #define __LULU_H__ 1
 
-// Pick the Geo implementation to use
-#define MAXMIND_GEOIP 1
-
+#include <sys/types.h>
 
-// Define UNUSED properly.
-#if ((__GNUC__ >= 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
-#define UNUSED __attribute__ ((unused))
-#else
-#define UNUSED
-#endif /* #if ((__GNUC__ >= 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7))) */
+#include "ink_defs.h"
 
-#include <sys/types.h>
+// Pick the Geo implementation to use
+#define MAXMIND_GEOIP 1
 
 // Memory barriers on i386 / linux / gcc
 #if defined(__i386__)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/plugins/experimental/header_rewrite/lulu.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/header_rewrite/lulu.h b/plugins/experimental/header_rewrite/lulu.h
index 02dfefb..d517cf7 100644
--- a/plugins/experimental/header_rewrite/lulu.h
+++ b/plugins/experimental/header_rewrite/lulu.h
@@ -22,17 +22,10 @@
 #ifndef __LULU_H__
 #define __LULU_H__ 1
 
-// Define UNUSED properly.
-#if ((__GNUC__ >= 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
-#define UNUSED __attribute__ ((unused))
-#else
-#define UNUSED
-#endif /* #if ((__GNUC__ >= 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7))) */
-
-static char UNUSED rcsId__lulu_h[] = "@(#) $Id$ built on " __DATE__ " " __TIME__;
-
 #include <sys/types.h>
 
+#include "ink_defs.h"
+
 // Memory barriers on i386 / linux / gcc
 #if defined(__i386__)
 #define mb()  __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/plugins/experimental/spdy/protocol.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/spdy/protocol.cc b/plugins/experimental/spdy/protocol.cc
index ab06ea5..0dc5c33 100644
--- a/plugins/experimental/spdy/protocol.cc
+++ b/plugins/experimental/spdy/protocol.cc
@@ -26,10 +26,8 @@
 
 #include <algorithm>
 #include <vector>
-#include <sys/param.h> // MAX
-#if !defined(MAX)
-# define MAX(a,b) (((a)>(b))?(a):(b))
-#endif
+
+#include "ink_defs.h" // MAX
 
 void
 spdy_send_reset_stream(

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/plugins/header_filter/lulu.h
----------------------------------------------------------------------
diff --git a/plugins/header_filter/lulu.h b/plugins/header_filter/lulu.h
index a16f943..bff1a2e 100644
--- a/plugins/header_filter/lulu.h
+++ b/plugins/header_filter/lulu.h
@@ -24,17 +24,11 @@
 #ifndef __LULU_H__
 #define __LULU_H__ 1
 
-#include "ink_atomic.h"
-
-// Define UNUSED properly.
-#if ((__GNUC__ >= 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
-#define UNUSED __attribute__ ((unused))
-#else
-#define UNUSED
-#endif /* #if ((__GNUC__ >= 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7))) */
-
 #include <sys/types.h>
 
+#include "ink_atomic.h"
+#include "ink_unused.h"
+
 // Memory barriers on i386 / linux / gcc
 #if defined(__i386__)
 #define mb()  __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/proxy/InkAPITestTool.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPITestTool.cc b/proxy/InkAPITestTool.cc
index 91e3093..7e2c988 100644
--- a/proxy/InkAPITestTool.cc
+++ b/proxy/InkAPITestTool.cc
@@ -31,9 +31,6 @@
 #define SDBG_TAG "SockServer"
 #define CDBG_TAG "SockClient"
 
-#ifndef MIN
-#define MIN(_x, _y) ((_x < _y) ? _x : _y)
-#endif
 #define IP(a,b,c,d) htonl((a) << 24 | (b) << 16 | (c) << 8 | (d))
 
 #define SET_TEST_HANDLER(_d, _s) {_d = _s;}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/proxy/MuxVC.cc
----------------------------------------------------------------------
diff --git a/proxy/MuxVC.cc b/proxy/MuxVC.cc
index 799d8d2..2f08a85 100644
--- a/proxy/MuxVC.cc
+++ b/proxy/MuxVC.cc
@@ -42,9 +42,6 @@
 const int MUX_LOCK_RETRY = HRTIME_MSECONDS(10);
 const int MUX_MAX_DATA_SIZE = USHRT_MAX - sizeof(MuxMessage);
 
-#define MIN(x,y) (x <= y) ? x : y;
-#define MAX(x,y) (x >= y) ? x : y;
-
 #define MUX_MAX_BYTES_SLOT 32768
 #define MUX_MAX_BYTES_BANK 32768
 #define MUX_SMALL_BLOCK_SIZE 256

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/proxy/PluginVC.cc
----------------------------------------------------------------------
diff --git a/proxy/PluginVC.cc b/proxy/PluginVC.cc
index 52dfa26..47a285a 100644
--- a/proxy/PluginVC.cc
+++ b/proxy/PluginVC.cc
@@ -77,11 +77,6 @@
 #include "Regression.h"
 
 #define PVC_LOCK_RETRY_TIME HRTIME_MSECONDS(10)
-#undef MIN
-#define MIN(x,y) (((x) <= (y)) ? (x) : (y))
-#undef MAX
-#define MAX(x,y) (((x) >= (y)) ? (x) : (y))
-
 #define PVC_DEFAULT_MAX_BYTES 32768
 #define MIN_BLOCK_TRANSFER_BYTES 128
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/proxy/api/ts/ts.h.in
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts.h.in b/proxy/api/ts/ts.h.in
index cabef07..b8fd4a1 100644
--- a/proxy/api/ts/ts.h.in
+++ b/proxy/api/ts/ts.h.in
@@ -83,13 +83,9 @@ extern "C"
 #define TS_RES_MEM_PATH    TS_RES_PATH ("memory/")
 #define TS_MAX_USER_NAME_LEN 256
 
-#if __GNUC__ >= 3
 #ifndef TS_DEPRECATED
 #define TS_DEPRECATED __attribute__ ((deprecated))
 #endif
-#else
-#define TS_DEPRECATED
-#endif
 
   /**
       The following struct is used by TSPluginRegister(). It stores

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/proxy/http/HttpTunnel.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTunnel.cc b/proxy/http/HttpTunnel.cc
index 9db3df2..721ad20 100644
--- a/proxy/http/HttpTunnel.cc
+++ b/proxy/http/HttpTunnel.cc
@@ -230,11 +230,6 @@ ChunkedHandler::read_size()
 //   Use block reference method when there is a sufficient
 //   size to move.  Otherwise, uses memcpy method
 //
-
-// We redefine MIN here, with our own funky implementation.  TODO: Do we need this ?
-#undef MIN
-#define MIN(x,y) ((x) <= (y)) ? (x) : (y);
-
 int64_t
 ChunkedHandler::transfer_bytes()
 {
@@ -445,8 +440,6 @@ bool ChunkedHandler::generate_chunked_content()
   return false;
 }
 
-#undef MIN
-
 HttpTunnelProducer::HttpTunnelProducer()
   : consumer_list(), self_consumer(NULL),
     vc(NULL), vc_handler(NULL), read_vio(NULL), read_buffer(NULL),

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/965c40f2/proxy/logstats.cc
----------------------------------------------------------------------
diff --git a/proxy/logstats.cc b/proxy/logstats.cc
index 2553a38..d4eb377 100644
--- a/proxy/logstats.cc
+++ b/proxy/logstats.cc
@@ -53,16 +53,10 @@
 #include <functional>
 #include <fcntl.h>
 
-#if (__GNUC__ >= 3)
 #define _BACKWARD_BACKWARD_WARNING_H    // needed for gcc 4.3
 #include <ext/hash_map>
 #include <ext/hash_set>
 #undef _BACKWARD_BACKWARD_WARNING_H
-#else
-#include <hash_map>
-#include <hash_set>
-#include <map>
-#endif
 
 #ifndef _XOPEN_SOURCE
 #define _XOPEN_SOURCE 600


[20/51] git commit: Enable automake subdir-objects

Posted by zw...@apache.org.
Enable automake subdir-objects


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/13411cb9
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/13411cb9
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/13411cb9

Branch: refs/heads/3.3.x
Commit: 13411cb9596a6cdcfda62b209b772ffb9fc919f3
Parents: 66192fc
Author: James Peach <jp...@apache.org>
Authored: Wed Mar 20 21:17:03 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Wed Mar 20 21:17:03 2013 -0700

----------------------------------------------------------------------
 configure.ac           |    2 +-
 mgmt/utils/Makefile.am |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/13411cb9/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index fe1648a..652f327 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,7 +40,7 @@ AC_PREREQ([2.59])
 AC_CONFIG_AUX_DIR([build/aux])
 AC_CONFIG_SRCDIR([proxy/Main.cc])
 AC_CONFIG_MACRO_DIR([build])
-AM_INIT_AUTOMAKE([-Wall -Werror foreign no-installinfo no-installman 1.9.2])
+AM_INIT_AUTOMAKE([-Wall -Werror foreign no-installinfo no-installman subdir-objects 1.9.2])
 AC_CONFIG_HEADERS([lib/ts/ink_autoconf.h])
 
 # Configure with --disable-silent-rules to get verbose output. For more info, see

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/13411cb9/mgmt/utils/Makefile.am
----------------------------------------------------------------------
diff --git a/mgmt/utils/Makefile.am b/mgmt/utils/Makefile.am
index 145a4ba..7829b01 100644
--- a/mgmt/utils/Makefile.am
+++ b/mgmt/utils/Makefile.am
@@ -40,8 +40,8 @@ noinst_LIBRARIES = libutils_lm.a libutils_p.a
 
 libutils_lm_a_CPPFLAGS = $(ink_with_modules_local) $(AM_CPPFLAGS)
 libutils_lm_a_SOURCES = \
-  $(top_srcdir)/lib/ts/MatcherUtils.cc \
-  $(top_srcdir)/proxy/DiagsConfig.cc \
+  ../../lib/ts/MatcherUtils.cc \
+  ../../proxy/DiagsConfig.cc \
   EnvBlock.cc \
   EnvBlock.h \
   ExpandingArray.cc \


[11/51] git commit: TS-1750

Posted by zw...@apache.org.
TS-1750

lower cpu usage when ts can't cleanup resoure about down machine


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/11bfc1e1
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/11bfc1e1
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/11bfc1e1

Branch: refs/heads/3.3.x
Commit: 11bfc1e183ce61e6ce4de7936faff7478e3f8441
Parents: 732f1cc
Author: Chen Bin <ku...@taobao.com>
Authored: Tue Mar 19 13:33:59 2013 +0800
Committer: Chen Bin <ku...@taobao.com>
Committed: Tue Mar 19 13:33:59 2013 +0800

----------------------------------------------------------------------
 iocore/cluster/ClusterHandlerBase.cc |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/11bfc1e1/iocore/cluster/ClusterHandlerBase.cc
----------------------------------------------------------------------
diff --git a/iocore/cluster/ClusterHandlerBase.cc b/iocore/cluster/ClusterHandlerBase.cc
index c184e89..fddba69 100644
--- a/iocore/cluster/ClusterHandlerBase.cc
+++ b/iocore/cluster/ClusterHandlerBase.cc
@@ -1209,7 +1209,7 @@ ClusterHandler::protoZombieEvent(int event, Event * e)
   // after NO_RACE_DELAY
   //
   bool failed = false;
-  ink_hrtime delay = CLUSTER_RETRY;
+  ink_hrtime delay = CLUSTER_MEMBER_DELAY * 5;
   EThread *t = e ? e->ethread : this_ethread();
   head_p item;
 


[03/51] git commit: TS-1748: fix jtest build warnings

Posted by zw...@apache.org.
TS-1748: fix jtest build warnings


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/70f224da
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/70f224da
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/70f224da

Branch: refs/heads/3.3.x
Commit: 70f224da68b0d9f6f5d44ede156198d6d34e6c83
Parents: e8ad297
Author: James Peach <jp...@apache.org>
Authored: Fri Mar 15 16:39:27 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Fri Mar 15 16:39:27 2013 -0700

----------------------------------------------------------------------
 tools/jtest/jtest.cc |   35 ++++++++++++++++++++++-------------
 1 files changed, 22 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/70f224da/tools/jtest/jtest.cc
----------------------------------------------------------------------
diff --git a/tools/jtest/jtest.cc b/tools/jtest/jtest.cc
index d7e5408..b8e566b 100644
--- a/tools/jtest/jtest.cc
+++ b/tools/jtest/jtest.cc
@@ -1793,8 +1793,9 @@ static void get_path_from_req(char * buf,char ** purl_start, char ** purl_end)
   *purl_end = url_end;
 }
 
-static int send_response (int sock) {
-  int err, towrite;
+static int send_response (int sock)
+{
+  int err = 0, towrite;
 
   if (fd[sock].req_pos >= 0) {
     char header[1024], *url_end = NULL, *url_start = NULL;
@@ -2118,7 +2119,7 @@ static int send_compd_response(int sock) {
     unsigned int code;
     unsigned int len;
   } compd_header;
-  if (fd[sock].req_pos < sizeof(compd_header)) {
+  if (fd[sock].req_pos < (int)sizeof(compd_header)) {
     compd_header.code = 0;
     compd_header.len = htonl((fd[sock].length * 2) / 3);
     do {
@@ -2142,7 +2143,7 @@ static int send_compd_response(int sock) {
     fd[sock].response = response_buffer + (((fd[sock].length * 2) / 3) % 256);
   }
  
-  if (fd[sock].req_pos < ((fd[sock].length * 2) / 3) + sizeof(compd_header)) {
+  if (fd[sock].req_pos < ((fd[sock].length * 2) / 3) + (int)sizeof(compd_header)) {
     int towrite = cbuffersize;
     int desired = ((fd[sock].length * 2) / 3) + sizeof (compd_header) - fd[sock].req_pos;
     if (towrite > desired) {
@@ -2656,7 +2657,7 @@ static int gen_bfc_dist(double f = 10.0) {
   }
 
   int class_no;
-  int file_no;
+  int file_no = 0;
 
   if(rand < 0.35){
     class_no = 0;
@@ -2913,7 +2914,6 @@ static void compose_all_urls( const char * tag, char * buf, char * start, char *
 //
 static void extract_urls(char * buf, int buflen, char * base_url) {
   //if (verbose) printf("EXTRACT<<%s\n>>", buf);
-  char old;
   char *start = NULL;
   char *end = NULL;
   char old_base[512];
@@ -2935,7 +2935,6 @@ static void extract_urls(char * buf, int buflen, char * base_url) {
                !(ParseRules::is_ws(*rover) || *rover == '\'' 
                  || *rover == '\"'))
           rover++;
-        old = *rover;
         *rover = 0;
         compose_url(base_url,old_base,start);
         // fixup unqualified hostnames (e.g. http://internal/foo)
@@ -2961,8 +2960,9 @@ static void extract_urls(char * buf, int buflen, char * base_url) {
     const char *tags[] = { "src", "image", "object", "archive", "background", 
                      // "location", "code" 
     };
-    for (int i = 0 ; i < sizeof(tags)/sizeof(tags[0]) ; i++)
+    for (unsigned i = 0 ; i < sizeof(tags)/sizeof(tags[0]) ; i++) {
       compose_all_urls(tags[i], buf, start, end, buflen, base_url);
+    }
   }
 } // extract_urls
 
@@ -3687,7 +3687,7 @@ void interval_report() {
   _x[1] = (_t >> 8) & 0xFF;  \
   _x[2] = _t & 0xFF;
 
-#define MASK_TAG(_x)  (_x & ((1U << (BYTES_PER_ENTRY * 8)))-1)
+#define MASK_TAG(_x)  (_x & ((1U << (BYTES_PER_ENTRY * 8)) - 1))
 
 #define BEGIN_HASH_LOOP                                            \
     unsigned int bucket = (i % BUCKETS);                           \
@@ -3961,8 +3961,16 @@ static int make_url_client(const char * url,const char * base_url, bool seen,
   if (show_before) printf("%s\n", curl);
   if (urlsdump_fp) fprintf(urlsdump_fp, "%s\n", curl);
   if (show_headers) printf("Request to Proxy: {\n%s}\n",fd[sock].req_header);
-  fd[sock].binary = 
-    !strncasecmp(path - 3, "gif", 3) || !strncasecmp(path - 3, "jpg", 3);
+
+  {
+    const char * ext = strrchr(path, '.');
+
+    fd[sock].binary = 0;
+    if (ext) {
+      fd[sock].binary = !strncasecmp(ext, ".gif", 4) || !strncasecmp(ext, ".jpg", 4);
+    }
+  }
+
   fd[sock].response_length = 0;
   fd[sock].length = strlen(fd[sock].req_header);
   if (!fd[sock].response)
@@ -5042,7 +5050,8 @@ static int ink_web_unescapify_string(char *dest_in, char *src_in, int max_dest_l
 {
   char *src = src_in;
   char *dest = dest_in;
-  char *c1, *c2;
+  const char *c1;
+  const char *c2;
   int quit = 0;
   int dcount = 0;
   int num = 0;
@@ -5306,7 +5315,7 @@ static void process_arg(ArgumentDescription * argument_descriptions,
 
 
 #if 0
-XXX this is not used; maybe it's just debugging? -- jpeach
+// XXX this is not used; maybe it's just debugging? -- jpeach
 static void show_argument_configuration(ArgumentDescription * argument_descriptions,
                                  int n_argument_descriptions) 
 {


[14/51] git commit: TS-1749: one LOCAL record break the continuity of NODE records

Posted by zw...@apache.org.
TS-1749: one LOCAL record break the continuity of NODE records

All RECT_NODE Records must be placed continuously! The code depends on it to
calculate offset when reading RECT_NODE records received from other nodes in
the some cluster.

Signed-off-by: Yunkai Zhang <qi...@taobao.com>
Signed-off-by: Zhao Yongming <mi...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/4c6bff31
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/4c6bff31
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/4c6bff31

Branch: refs/heads/3.3.x
Commit: 4c6bff31cc4b6a60481acc3c3a369521974aa6cb
Parents: 8961f12
Author: Yunkai Zhang <qi...@taobao.com>
Authored: Tue Mar 19 14:53:48 2013 +0800
Committer: Zhao Yongming <mi...@gmail.com>
Committed: Wed Mar 20 11:29:47 2013 +0800

----------------------------------------------------------------------
 CHANGES                    |    3 +++
 mgmt/RecordsConfig.cc      |   27 +++++++++++++++------------
 mgmt/cluster/ClusterCom.cc |    4 ++++
 3 files changed, 22 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4c6bff31/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 10945ab..3f3389e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1749] Stats cluster values among nodes are not consistent.
+   Author: Yunkai Zhang <qi...@taobao.com>
+
   *) [TS-1758] Remove unused overviewPage aggregation functions.
    Author: Yunkai Zhang.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4c6bff31/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 1c2a88e..a09195d 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -1403,6 +1403,8 @@ RecordElement RecordsConfig[] = {
   //#
   //# <RECORD-TYPE> <NAME> <TYPE> <VALUE (till end of line)>
   //#
+  //# *NOTE*: All NODE Records must be placed continuously!
+  //#
   //# Add NODE       Records Here
   //##############################################################################
   {RECT_NODE, "proxy.node.num_processes", RECD_INT, "0", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
@@ -1441,18 +1443,6 @@ RecordElement RecordsConfig[] = {
   ,
 
   //#
-  //# SSL parent proxying info
-  //#
-  //# Set the value of this variable to 1 if this node
-  //#  is also the default parent for all ssl requests
-  //#  in a cluster. Setting the value to 1 will prevent
-  //#  SSL requests from this proxy to a parent from
-  //#  self-looping.
-  //#
-  {RECT_LOCAL, "proxy.local.http.parent_proxy.disable_connect_tunneling", RECD_INT, "0", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
-  ,
-
-  //#
   //# Dash Board Stats
   //#
   //# Valid Per Node - Can Not Sum For Cluster Stats
@@ -1848,6 +1838,19 @@ RecordElement RecordsConfig[] = {
   ,
   {RECT_CLUSTER, "proxy.cluster.current_server_connections", RECD_INT, "0", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,
+
+  //#
+  //# SSL parent proxying info
+  //#
+  //# Set the value of this variable to 1 if this node
+  //#  is also the default parent for all ssl requests
+  //#  in a cluster. Setting the value to 1 will prevent
+  //#  SSL requests from this proxy to a parent from
+  //#  self-looping.
+  //#
+  {RECT_LOCAL, "proxy.local.http.parent_proxy.disable_connect_tunneling", RECD_INT, "0", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
+  ,
+
   //# Add LOCAL Records Here
   {RECT_LOCAL, "proxy.local.incoming_ip_to_bind", RECD_STRING, NULL, RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4c6bff31/mgmt/cluster/ClusterCom.cc
----------------------------------------------------------------------
diff --git a/mgmt/cluster/ClusterCom.cc b/mgmt/cluster/ClusterCom.cc
index 451f77f..157b5dc 100644
--- a/mgmt/cluster/ClusterCom.cc
+++ b/mgmt/cluster/ClusterCom.cc
@@ -811,6 +811,10 @@ ClusterCom::handleMultiCastMessage(char *message)
     for (int j = 0; j < g_num_records; j++) {
       RecRecord *rec = &(g_records[j]);
 
+      /*
+       * The following code make sence only when RECT_NODE records
+       * defined in mgmt/RecordsConfig.cc are placed continuously.
+       */
       if (rec->rec_type == RECT_NODE) {
         p->node_rec_data.recs[cnt].rec_type = rec->rec_type;
         p->node_rec_data.recs[cnt].name = rec->name;


[10/51] git commit: more ignore for jtest

Posted by zw...@apache.org.
more ignore for jtest


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/732f1ccc
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/732f1ccc
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/732f1ccc

Branch: refs/heads/3.3.x
Commit: 732f1cccb5e0a4f2331abe1329c249a03f69f9ee
Parents: 369346e
Author: Zhao Yongming <mi...@gmail.com>
Authored: Tue Mar 19 13:29:26 2013 +0800
Committer: Zhao Yongming <mi...@gmail.com>
Committed: Tue Mar 19 13:29:26 2013 +0800

----------------------------------------------------------------------
 .gitignore |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/732f1ccc/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index be5c058..c32a79a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -113,6 +113,7 @@ lib/tsconfig/test-tsconfig
 
 tools/http_load/http_load
 tools/jtest/jtest
+tools/jtest/.dirstamp
 
 BUILDS
 DEBUG


[37/51] git commit: TS-1742: use __sync_val_compare_and_swap for atomic 16 byte reads

Posted by zw...@apache.org.
TS-1742: use __sync_val_compare_and_swap for atomic 16 byte reads

clang correctly emits cmpxchg16b for __sync_val_compare_and_swap(),
so let's use that instead of __sync_fetch_and_add().


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/18aadb0c
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/18aadb0c
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/18aadb0c

Branch: refs/heads/3.3.x
Commit: 18aadb0c7b1a7f74935107764696bba702608635
Parents: 6309835
Author: James Peach <jp...@apache.org>
Authored: Mon Mar 25 12:30:58 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Mon Mar 25 12:30:58 2013 -0700

----------------------------------------------------------------------
 lib/ts/ink_queue.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/18aadb0c/lib/ts/ink_queue.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_queue.h b/lib/ts/ink_queue.h
index 20fbf9a..8cd1cc9 100644
--- a/lib/ts/ink_queue.h
+++ b/lib/ts/ink_queue.h
@@ -72,7 +72,9 @@ extern "C"
 #endif
 
 #if TS_HAS_128BIT_CAS
-#define INK_QUEUE_LD(dst,src) *(__int128_t*)&(dst) = __sync_fetch_and_add((__int128_t*)&(src), 0)
+#define INK_QUEUE_LD(dst, src) do { \
+  *(__int128_t*)&(dst) = __sync_val_compare_and_swap((__int128_t*)&(src), 0, 0); \
+} while (0)
 #else
 #define INK_QUEUE_LD(dst,src) INK_QUEUE_LD64(dst,src)
 #endif


[06/51] git commit: Fix jtest compile, quickly

Posted by zw...@apache.org.
Fix jtest compile, quickly


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/7c5e5a68
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/7c5e5a68
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/7c5e5a68

Branch: refs/heads/3.3.x
Commit: 7c5e5a683ce2b04d4bea038bb59b33de7af7a841
Parents: a51a439
Author: Zhao Yongming <mi...@gmail.com>
Authored: Mon Mar 18 15:27:50 2013 +0800
Committer: Zhao Yongming <mi...@gmail.com>
Committed: Mon Mar 18 15:27:50 2013 +0800

----------------------------------------------------------------------
 tools/jtest/jtest.cc |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7c5e5a68/tools/jtest/jtest.cc
----------------------------------------------------------------------
diff --git a/tools/jtest/jtest.cc b/tools/jtest/jtest.cc
index b8e566b..f4e3a24 100644
--- a/tools/jtest/jtest.cc
+++ b/tools/jtest/jtest.cc
@@ -3801,7 +3801,7 @@ UrlHashTable::UrlHashTable() {
     // size as the size
     if (!len) 
       panic("zero size URL Hash Table\n");
-    if (len != URL_HASH_BYTES) {
+    if (len != (unsigned long)URL_HASH_BYTES) {
       fprintf(stderr, 
               "FATAL: hash file length (%lu) != URL_HASH_BYTES (%lu)\n",
               len, (unsigned long)URL_HASH_BYTES);


[42/51] git commit: TS-1623, TS-1635: better handling of host in field and not URL for logging.

Posted by zw...@apache.org.
TS-1623, TS-1635: better handling of host in field and not URL for logging.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/cf0e2f11
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/cf0e2f11
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/cf0e2f11

Branch: refs/heads/3.3.x
Commit: cf0e2f1151736bd74658c5a2bc3306c94ca6c038
Parents: da8ca56
Author: Alan M. Carroll <am...@network-geographics.com>
Authored: Fri Mar 22 11:04:17 2013 -0500
Committer: Alan M. Carroll <am...@network-geographics.com>
Committed: Tue Mar 26 09:12:15 2013 -0500

----------------------------------------------------------------------
 CHANGES                        |    2 +
 proxy/hdrs/HTTP.cc             |   13 ++++++++-
 proxy/hdrs/HTTP.h              |   51 ++++++++++++++++++++++++++++++++--
 proxy/hdrs/HdrTest.cc          |    3 +-
 proxy/hdrs/URL.cc              |    5 +++-
 proxy/logging/LogAccessHttp.cc |   50 ++++++++++++----------------------
 proxy/logging/LogAccessHttp.h  |    4 +-
 7 files changed, 88 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cf0e2f11/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 5559ab0..90b631b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
   Changes with Apache Traffic Server 3.3.2
 
+  *) [TS-1623, TS-1625] Fixes for logging where the host name was not handled
+    correctly because it was not in the URL.
 
   *) [TS-1754] Remove unecessary wWarnings from stats evaluation.
    Author: Yunkai Zhang.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cf0e2f11/proxy/hdrs/HTTP.cc
----------------------------------------------------------------------
diff --git a/proxy/hdrs/HTTP.cc b/proxy/hdrs/HTTP.cc
index 70c5d7c..3eea028 100644
--- a/proxy/hdrs/HTTP.cc
+++ b/proxy/hdrs/HTTP.cc
@@ -144,6 +144,8 @@ int HTTP_LEN_PUBLIC;
 int HTTP_LEN_S_MAXAGE;
 int HTTP_LEN_NEED_REVALIDATE_ONCE;
 
+Arena* const HTTPHdr::USE_HDR_HEAP_MAGIC = reinterpret_cast<Arena*>(1);
+
 /***********************************************************************
  *                                                                     *
  *                 U T I L I T Y    R O U T I N E S                    *
@@ -1510,6 +1512,11 @@ HTTPHdr::set_url_target_from_host_field(URL* url) {
 // need to either keep two versions of the URL (pristine
 // and effective) or URl would have to provide access to
 // the URL printer.
+
+// The use of a magic value for Arena to indicate the internal heap is
+// even uglier but it's less so than duplicating this entire method to
+// change that one thing.
+
 char*
 HTTPHdr::url_string_get(Arena* arena, int* length) {
   char *zret = 0;
@@ -1542,7 +1549,11 @@ HTTPHdr::url_string_get(Arena* arena, int* length) {
       should_reset_port = true;
     }
 
-    zret = m_url_cached.string_get(arena, length);
+    zret = (arena == USE_HDR_HEAP_MAGIC)
+      ? m_url_cached.string_get_ref(length)
+      : m_url_cached.string_get(arena, length)
+      ;
+
     if (should_reset_host) { ui->m_ptr_host = 0; ui->m_len_host = 0; }
     if (should_reset_port) { ui->m_ptr_port = 0; ui->m_len_port = 0; }
  }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cf0e2f11/proxy/hdrs/HTTP.h
----------------------------------------------------------------------
diff --git a/proxy/hdrs/HTTP.h b/proxy/hdrs/HTTP.h
index a654bb1..1323d8a 100644
--- a/proxy/hdrs/HTTP.h
+++ b/proxy/hdrs/HTTP.h
@@ -567,10 +567,22 @@ public:
     Arena* arena = 0, ///< Arena to use, or @c malloc if NULL.
     int* length = 0 ///< Store string length here.
   );
+  /** Get a string with the effective URL in it.
+      This is automatically allocated if needed in the request heap.
 
-  void url_set(URL *url);
-  void url_set_as_server_url(URL *url);
-  void url_set(const char *str, int length);
+      @see url_string_get
+   */
+  char* url_string_get_ref(
+    int* length = 0 ///< Store string length here.
+  );
+
+  /** Get the URL path.
+      This is a reference, not allocated.
+      @return A pointer to the path or @c NULL if there is no valid URL.
+  */
+  char const* path_get(
+		       int* length ///< Storage for path length.
+		       );
 
   /** Get the target host name.
       The length is returned in @a length if non-NULL.
@@ -587,6 +599,17 @@ public:
   */
   int port_get();
 
+  /** Get the URL scheme.
+      This is a reference, not allocated.
+      @return A pointer to the scheme or @c NULL if there is no valid URL.
+  */
+  char const* scheme_get(
+		       int* length ///< Storage for path length.
+		       );
+  void url_set(URL *url);
+  void url_set_as_server_url(URL *url);
+  void url_set(const char *str, int length);
+
   /// Check location of target host.
   /// @return @c true if the host was in the URL, @c false otherwise.
   /// @note This returns @c false if the host is missing.
@@ -636,6 +659,8 @@ protected:
   */
   void _test_and_fill_target_cache() const;
 
+  static Arena* const USE_HDR_HEAP_MAGIC;
+
 private:
   // No gratuitous copies!
   HTTPHdr(const HTTPHdr & m);
@@ -1218,6 +1243,26 @@ HTTPHdr::is_pragma_no_cache_set()
   return (get_cooked_pragma_no_cache());
 }
 
+inline char*
+HTTPHdr::url_string_get_ref(int* length)
+{
+  return this->url_string_get(USE_HDR_HEAP_MAGIC, length);
+}
+
+inline char const*
+HTTPHdr::path_get(int* length)
+{
+  URL* url = this->url_get();
+  return url ? url->path_get(length) : 0;
+}
+
+inline char const*
+HTTPHdr::scheme_get(int* length)
+{
+  URL* url = this->url_get();
+  return url ? url->scheme_get(length) : 0;
+}
+
 /*-------------------------------------------------------------------------
   -------------------------------------------------------------------------*/
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cf0e2f11/proxy/hdrs/HdrTest.cc
----------------------------------------------------------------------
diff --git a/proxy/hdrs/HdrTest.cc b/proxy/hdrs/HdrTest.cc
index 5f5b898..c73c170 100644
--- a/proxy/hdrs/HdrTest.cc
+++ b/proxy/hdrs/HdrTest.cc
@@ -419,7 +419,8 @@ HdrTest::test_url()
     "pnm://foo:bar@some.place:80/path;params?query#fragment",
     "rtsp://foo:bar@some.place:80/path;params?query#fragment",
     "rtspu://foo:bar@some.place:80/path;params?query#fragment",
-    "/finance/external/cbsm/*http://cbs.marketwatch.com/archive/19990713/news/current/net.htx?source=blq/yhoo&dist=yhoo"
+    "/finance/external/cbsm/*http://cbs.marketwatch.com/archive/19990713/news/current/net.htx?source=blq/yhoo&dist=yhoo",
+    "http://a.b.com/xx.jpg?newpath=http://bob.dave.com"
   };
   static int nstrs = sizeof(strs) / sizeof(strs[0]);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cf0e2f11/proxy/hdrs/URL.cc
----------------------------------------------------------------------
diff --git a/proxy/hdrs/URL.cc b/proxy/hdrs/URL.cc
index 9a9c754..b9d2b06 100644
--- a/proxy/hdrs/URL.cc
+++ b/proxy/hdrs/URL.cc
@@ -1066,7 +1066,10 @@ url_parse_scheme(HdrHeap * heap, URLImpl * url, const char **start, const char *
     if ((end - cur >= 5) && (((cur[0] ^ 'h') | (cur[1] ^ 't') | (cur[2] ^ 't') | (cur[3] ^ 'p') | (cur[4] ^ ':')) == 0)) {
       scheme_end = cur + 4;                   // point to colon
       url_scheme_set(heap, url, scheme_start, URL_WKSIDX_HTTP, 4, copy_strings_p);
-    } else { // some other scheme, try to parse it.
+    } else if ('/' != *cur) {
+      // For forward transparent mode, the URL for the method can just be a path,
+      // so don't scan that for a scheme, as we could find a false positive if there
+      // is a URL in the parameters (which is legal).
       while (':' != *cur && ++cur < end)
         ;
       if (cur < end) { // found a colon

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cf0e2f11/proxy/logging/LogAccessHttp.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogAccessHttp.cc b/proxy/logging/LogAccessHttp.cc
index cd945f6..c44a205 100644
--- a/proxy/logging/LogAccessHttp.cc
+++ b/proxy/logging/LogAccessHttp.cc
@@ -51,7 +51,7 @@
   -------------------------------------------------------------------------*/
 
 LogAccessHttp::LogAccessHttp(HttpSM * sm)
-:m_http_sm(sm), m_arena(), m_url(NULL), m_client_request(NULL), m_proxy_response(NULL), m_proxy_request(NULL), m_server_response(NULL), m_cache_response(NULL), m_client_req_url_str(NULL), m_client_req_url_len(0), m_client_req_url_canon_str(NULL), m_client_req_url_canon_len(0), m_client_req_unmapped_url_canon_str(NULL), m_client_req_unmapped_url_canon_len(-1),      // undetermined
+:m_http_sm(sm), m_arena(), m_client_request(NULL), m_proxy_response(NULL), m_proxy_request(NULL), m_server_response(NULL), m_cache_response(NULL), m_client_req_url_str(NULL), m_client_req_url_len(0), m_client_req_url_canon_str(NULL), m_client_req_url_canon_len(0), m_client_req_unmapped_url_canon_str(NULL), m_client_req_unmapped_url_canon_len(-1),      // undetermined
   m_client_req_unmapped_url_path_str(NULL), m_client_req_unmapped_url_path_len(-1),     // undetermined
   m_client_req_unmapped_url_host_str(NULL), m_client_req_unmapped_url_host_len(-1),
   m_client_req_url_path_str(NULL),
@@ -91,15 +91,13 @@ LogAccessHttp::init()
 
   if (hdr->client_request.valid()) {
     m_client_request = &(hdr->client_request);
-    m_url = m_client_request->url_get();
-    if (m_url) {
-      m_client_req_url_str = m_url->string_get_ref(&m_client_req_url_len);
-      m_client_req_url_canon_str = LogUtils::escapify_url(&m_arena,
-                                                          m_client_req_url_str, m_client_req_url_len,
-                                                          &m_client_req_url_canon_len);
-      m_client_req_url_path_str = (char *) m_url->path_get(&m_client_req_url_path_len);
-    }
+    m_client_req_url_str = m_client_request->url_string_get_ref(&m_client_req_url_len);
+    m_client_req_url_canon_str = LogUtils::escapify_url(&m_arena,
+                                                        m_client_req_url_str, m_client_req_url_len,
+                                                        &m_client_req_url_canon_len);
+    m_client_req_url_path_str = m_client_request->path_get(&m_client_req_url_path_len);
   }
+
   if (hdr->client_response.valid()) {
     m_proxy_response = &(hdr->client_response);
     MIMEField *field = m_proxy_response->field_find(MIME_FIELD_CONTENT_TYPE, MIME_LEN_CONTENT_TYPE);
@@ -382,17 +380,15 @@ LogAccessHttp::marshal_client_req_url_scheme(char *buf)
   int alen = 0;
   int plen = INK_MIN_ALIGN;
 
-  if (m_url) {
-    str = (char *) m_url->scheme_get(&alen);
+  str = (char *) m_client_request->scheme_get(&alen);
 
-    // calculate the the padded length only if the actual length
-    // is not zero. We don't want the padded length to be zero
-    // because marshal_mem should write the DEFAULT_STR to the
-    // buffer if str is nil, and we need room for this.
-    //
-    if (alen) {
-      plen = round_strlen(alen + 1);    // +1 for trailing 0
-    }
+  // calculate the the padded length only if the actual length
+  // is not zero. We don't want the padded length to be zero
+  // because marshal_mem should write the DEFAULT_STR to the
+  // buffer if str is nil, and we need room for this.
+  //
+  if (alen) {
+    plen = round_strlen(alen + 1);    // +1 for trailing 0
   }
 
   if (buf) {
@@ -706,25 +702,15 @@ LogAccessHttp::marshal_server_host_ip(char *buf)
 int
 LogAccessHttp::marshal_server_host_name(char *buf)
 {
-  char *str = NULL;
+  char const* str = NULL;
   int padded_len = INK_MIN_ALIGN;
   int actual_len = 0;
 
   if (m_client_request) {
-    MIMEField *field = m_client_request->field_find(MIME_FIELD_HOST,
-                                                    MIME_LEN_HOST);
+    str = m_client_request->host_get(&actual_len);
 
-    if (field) {
-      str = (char *) field->value_get(&actual_len);
+    if (str)
       padded_len = round_strlen(actual_len + 1);        // +1 for trailing 0
-    } else if (m_url) {
-      str = (char *) m_url->host_get(&actual_len);
-      padded_len = round_strlen(actual_len + 1);        // +1 for trailing 0
-    } else {
-      str = NULL;
-      actual_len = 0;
-      padded_len = INK_MIN_ALIGN;
-    }
   }
   if (buf) {
     marshal_mem(buf, str, actual_len, padded_len);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cf0e2f11/proxy/logging/LogAccessHttp.h
----------------------------------------------------------------------
diff --git a/proxy/logging/LogAccessHttp.h b/proxy/logging/LogAccessHttp.h
index 8692831..52212b2 100644
--- a/proxy/logging/LogAccessHttp.h
+++ b/proxy/logging/LogAccessHttp.h
@@ -138,7 +138,7 @@ private:
   HttpSM * m_http_sm;
 
   Arena m_arena;
-  URL *m_url;
+  //  URL *m_url;
 
   HTTPHdr *m_client_request;
   HTTPHdr *m_proxy_response;
@@ -156,7 +156,7 @@ private:
   int m_client_req_unmapped_url_path_len;
   char *m_client_req_unmapped_url_host_str;
   int m_client_req_unmapped_url_host_len;
-  char *m_client_req_url_path_str;
+  char const*m_client_req_url_path_str;
   int m_client_req_url_path_len;
   char *m_proxy_resp_content_type_str;
   int m_proxy_resp_content_type_len;


[51/51] git commit: TS-1764 Fix the builds after this cleanup.

Posted by zw...@apache.org.
TS-1764 Fix the builds after this cleanup.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/bc1b9d35
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/bc1b9d35
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/bc1b9d35

Branch: refs/heads/3.3.x
Commit: bc1b9d351582970fa0a320a854c81a2c957fc287
Parents: 0461073
Author: Leif Hedstrom <zw...@apache.org>
Authored: Sat Mar 30 19:01:17 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Sat Mar 30 19:01:17 2013 -0600

----------------------------------------------------------------------
 example/Makefile.am |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bc1b9d35/example/Makefile.am
----------------------------------------------------------------------
diff --git a/example/Makefile.am b/example/Makefile.am
index e7262fa..b10e1d5 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -16,8 +16,12 @@
 
 pkglibdir = ${pkglibexecdir}
 
-AM_CPPFLAGS = -I$(top_srcdir)/proxy/api \
-    -I$(top_builddir)/proxy/api
+AM_CPPFLAGS = \
+    -I$(top_srcdir)/proxy/api \
+    -I$(top_builddir)/proxy/api \
+    -I$(top_srcdir)/lib/ts \
+    -I$(top_builddir)/lib/ts
+    
 AM_LDFLAGS = -module -avoid-version -shared
 
 noinst_LTLIBRARIES = \


[15/51] git commit: TS-1763: add Arch Linux config.layout

Posted by zw...@apache.org.
TS-1763: add Arch Linux config.layout


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/1475f863
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/1475f863
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/1475f863

Branch: refs/heads/3.3.x
Commit: 1475f863aa4644c300b3258036273b4df8ca8e79
Parents: 4c6bff3
Author: Galen Sampson <ga...@gmail.com>
Authored: Wed Mar 20 16:05:23 2013 +0800
Committer: Zhao Yongming <mi...@gmail.com>
Committed: Wed Mar 20 16:06:52 2013 +0800

----------------------------------------------------------------------
 CHANGES       |    3 +++
 config.layout |   20 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1475f863/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 3f3389e..3c24117 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1763] add Arch Linux config.layout
+   Author: Galen Sampson <ga...@gmail.com>
+
   *) [TS-1749] Stats cluster values among nodes are not consistent.
    Author: Yunkai Zhang <qi...@taobao.com>
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1475f863/config.layout
----------------------------------------------------------------------
diff --git a/config.layout b/config.layout
index 73fcb18..7a208dd 100644
--- a/config.layout
+++ b/config.layout
@@ -257,3 +257,23 @@
     logdir:        ${prefix}/logs+
     cachedir:      ${datadir}
 </Layout>
+
+<Layout Arch>
+    prefix:        /usr
+    exec_prefix:   ${prefix}
+    bindir:        ${exec_prefix}/bin
+    sbindir:       ${exec_prefix}/sbin
+    libdir:        ${exec_prefix}/lib
+    libexecdir:    ${libdir}+
+    infodir:       ${prefix}/share/info
+    mandir:        ${prefix}/share/man
+    sysconfdir:    /etc+
+    datadir:       ${prefix}/share+
+    docdir:        ${prefix}/share/doc+
+    installbuilddir: ${datadir}/build
+    includedir:    ${prefix}/include
+    localstatedir: /run
+    runtimedir:    /run+
+    logdir:        /var/log+
+    cachedir:      /var/lib+
+</Layout>