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/04/15 22:46:08 UTC

[01/50] git commit: TS-1067 Remove the bandwidth management APIs, it is never used

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


TS-1067 Remove the bandwidth management APIs, it is never used


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

Branch: refs/heads/3.3.x
Commit: 959235e94dcb67201ed0a2ec24d2e3a4631b3471
Parents: 52e3fd8
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Mar 26 08:29:59 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:42 2013 -0600

----------------------------------------------------------------------
 iocore/net/I_UDPNet.h        |    9 ---
 iocore/net/P_UDPConnection.h |    1 -
 iocore/net/P_UDPNet.h        |    3 -
 iocore/net/UnixUDPNet.cc     |  104 +------------------------------------
 proxy/UglyLogStubs.cc        |    3 -
 5 files changed, 1 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/959235e9/iocore/net/I_UDPNet.h
----------------------------------------------------------------------
diff --git a/iocore/net/I_UDPNet.h b/iocore/net/I_UDPNet.h
index 5e558ec..d9dc38b 100644
--- a/iocore/net/I_UDPNet.h
+++ b/iocore/net/I_UDPNet.h
@@ -120,15 +120,6 @@ public:
   Action *recvfrom_re(Continuation * c, void *token, int fd,
                       sockaddr *fromaddr, socklen_t *fromaddrlen,
                       IOBufferBlock * buf, int len, bool useReadCont = true, int timeout = 0);
-  // Continuation is really a UDPConnection; due to the include mess, we stick in the
-  // base-class of UDPConnection.
-  bool AllocBandwidth(Continuation * udpConn, double desiredMbps);
-  bool ChangeBandwidth(Continuation * udpConn, double desiredMbps);
-  void FreeBandwidth(Continuation * udpConn);
-  double GetAvailableBandwidth();
-
-  virtual void UDPNetProcessor_is_abstract() = 0;
-
 };
 
 inkcoreapi extern UDPNetProcessor & udpNet;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/959235e9/iocore/net/P_UDPConnection.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_UDPConnection.h b/iocore/net/P_UDPConnection.h
index e1b5186..6c1c40d 100644
--- a/iocore/net/P_UDPConnection.h
+++ b/iocore/net/P_UDPConnection.h
@@ -100,7 +100,6 @@ UDPConnectionInternal::~UDPConnectionInternal()
   // TODO: This is not necessary, and should be removed with the
   // elimination of UDP bandwidth limiting (used by long since
   // removed UDP protocols). See bug TS-1067.
-  // udpNet.FreeBandwidth(this);
   continuation = NULL;
   mutex = NULL;
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/959235e9/iocore/net/P_UDPNet.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_UDPNet.h b/iocore/net/P_UDPNet.h
index 403152d..8a3cfb8 100644
--- a/iocore/net/P_UDPNet.h
+++ b/iocore/net/P_UDPNet.h
@@ -52,9 +52,6 @@ struct UDPNetProcessorInternal : public UDPNetProcessor
 
   off_t pollCont_offset;
   off_t udpNetHandler_offset;
-
-public:
-  virtual void UDPNetProcessor_is_abstract() {  }
 };
 
 extern UDPNetProcessorInternal udpNetInternal;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/959235e9/iocore/net/UnixUDPNet.cc
----------------------------------------------------------------------
diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc
index c939f0f..73dc0f6 100644
--- a/iocore/net/UnixUDPNet.cc
+++ b/iocore/net/UnixUDPNet.cc
@@ -682,112 +682,10 @@ Lerror:
   return ACTION_IO_ERROR;
 }
 
-bool
-UDPNetProcessor::AllocBandwidth(Continuation * udpConn, double desiredMbps)
-{
-  UDPConnectionInternal *udpIntConn = (UDPConnectionInternal *) udpConn;
-  int64_t desiredbps = (int64_t) (desiredMbps * 1024.0 * 1024.0);
-
-  if (G_inkPipeInfo.numPipes == 0) {
-    udpIntConn->flowRateBps = (desiredMbps * 1024.0 * 1024.0) / 8.0;
-    return true;
-  }
-
-  if ((udpIntConn->pipe_class == 0) ||
-      (G_inkPipeInfo.perPipeInfo[udpIntConn->pipe_class].bwAlloc + desiredbps >
-       G_inkPipeInfo.perPipeInfo[udpIntConn->pipe_class].bwLimit)) {
-    Debug("udpnet-admit", "Denying flow with %lf Mbps", desiredMbps);
-    return false;
-  }
-  udpIntConn->flowRateBps = (desiredMbps * 1024.0 * 1024.0) / 8.0;
-  udpIntConn->allocedbps = desiredbps;
-  ink_atomic_increment(&G_inkPipeInfo.perPipeInfo[udpIntConn->pipe_class].bwAlloc, desiredbps);
-  Debug("udpnet-admit", "Admitting flow with %lf Mbps (a=%" PRId64 ", lim=%" PRId64 ")",
-        desiredMbps,
-        G_inkPipeInfo.perPipeInfo[udpIntConn->pipe_class].bwAlloc,
-        G_inkPipeInfo.perPipeInfo[udpIntConn->pipe_class].bwLimit);
-  return true;
-}
-
-bool
-UDPNetProcessor::ChangeBandwidth(Continuation * udpConn, double desiredMbps)
-{
-  UDPConnectionInternal *udpIntConn = (UDPConnectionInternal *) udpConn;
-  int64_t desiredbps = (int64_t) (desiredMbps * 1024.0 * 1024.0);
-  int64_t oldbps = (int64_t) (udpIntConn->flowRateBps * 8.0);
-
-  if (G_inkPipeInfo.numPipes == 0) {
-    udpIntConn->flowRateBps = (desiredMbps * 1024.0 * 1024.0) / 8.0;
-    return true;
-  }
-  // arithmetic here is in bits-per-sec.
-  if ((udpIntConn->pipe_class == 0) ||
-      (G_inkPipeInfo.perPipeInfo[udpIntConn->pipe_class].bwAlloc +
-       desiredbps - oldbps) > G_inkPipeInfo.perPipeInfo[udpIntConn->pipe_class].bwLimit) {
-    Debug("udpnet-admit", "Unable to change b/w for flow to %lf Mbps", desiredMbps);
-    return false;
-  }
-  udpIntConn->flowRateBps = (desiredMbps * 1024.0 * 1024.0) / 8.0;
-  udpIntConn->allocedbps = desiredbps;
-  ink_atomic_increment(&G_inkPipeInfo.perPipeInfo[udpIntConn->pipe_class].bwAlloc, desiredbps - oldbps);
-  Debug("udpnet-admit", "Changing flow's b/w from %lf Mbps to %lf Mbps (a=%" PRId64 ", lim=%" PRId64 ")",
-        (double) oldbps / (1024.0 * 1024.0),
-        desiredMbps,
-        G_inkPipeInfo.perPipeInfo[udpIntConn->pipe_class].bwAlloc,
-        G_inkPipeInfo.perPipeInfo[udpIntConn->pipe_class].bwLimit);
-  return true;
-}
-
-void
-UDPNetProcessor::FreeBandwidth(Continuation * udpConn)
-{
-  UDPConnectionInternal *udpIntConn = (UDPConnectionInternal *) udpConn;
-  int64_t bps;
-
-  if (G_inkPipeInfo.numPipes == 0)
-    return;
-
-  Debug("udpnet-free", "Trying to releasing %lf (%" PRId64 ") Kbps", udpIntConn->flowRateBps, udpIntConn->allocedbps);
-
-  bps = udpIntConn->allocedbps;
-  if (bps <= 0)
-    return;
-
-  ink_atomic_increment(&G_inkPipeInfo.perPipeInfo[udpIntConn->pipe_class].bwAlloc, -bps);
-
-  Debug("udpnet-free", "Releasing %lf Kbps", bps / 1024.0);
-
-  if (G_inkPipeInfo.perPipeInfo[udpIntConn->pipe_class].bwAlloc < 0)
-    G_inkPipeInfo.perPipeInfo[udpIntConn->pipe_class].bwAlloc = 0;
-
-  udpIntConn->flowRateBps = 0.0;
-  udpIntConn->allocedbps = 0;
-}
-
-double
-UDPNetProcessor::GetAvailableBandwidth()
-{
-  int i;
-  double usedBw = 0.0;
-
-  if (G_inkPipeInfo.numPipes == 0)
-    // return 100Mbps if there are no pipes
-    return 100.0;
-
-  for (i = 0; i < G_inkPipeInfo.numPipes + 1; i++) {
-    usedBw += G_inkPipeInfo.perPipeInfo[i].bwUsed;
-  }
-  return G_inkPipeInfo.interfaceMbps - usedBw;
-}
 
 // send out all packets that need to be sent out as of time=now
 UDPQueue::UDPQueue()
-: last_report(0)
-, last_service(0)
-, last_byteperiod(0)
-, bytesSent(0)
-, packets(0)
-, added(0)
+  : last_report(0), last_service(0), last_byteperiod(0), bytesSent(0), packets(0), added(0)
 {
 }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/959235e9/proxy/UglyLogStubs.cc
----------------------------------------------------------------------
diff --git a/proxy/UglyLogStubs.cc b/proxy/UglyLogStubs.cc
index b68bf97..0456e2b 100644
--- a/proxy/UglyLogStubs.cc
+++ b/proxy/UglyLogStubs.cc
@@ -44,9 +44,6 @@ class FakeUDPNetProcessor : public UDPNetProcessor {
     ink_release_assert(false);
     return 0;
   };
-  virtual void UDPNetProcessor_is_abstract() {
-    ink_release_assert(false);
-  };
 } fakeUDPNet;
 
 UDPNetProcessor& udpNet = fakeUDPNet;


[37/50] git commit: TS-1806: bogus buffer sizing in CfgContextUtils.cc

Posted by zw...@apache.org.
TS-1806: bogus buffer sizing in CfgContextUtils.cc


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

Branch: refs/heads/3.3.x
Commit: af7472494eec1fe469dcba15ba9d75becdff8364
Parents: df462b3
Author: James Peach <jp...@apache.org>
Authored: Tue Apr 9 16:44:17 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:44 2013 -0600

----------------------------------------------------------------------
 CHANGES                     |    2 ++
 mgmt/api/CfgContextUtils.cc |    6 ++++--
 2 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/af747249/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 11b87e4..59a196b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1806] bogus buffer sizing in CfgContextUtils.cc
+
   *) [TS-1805] Fix stats ExpressionEval in stats xml.
    Author: Yunkai Zhang
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/af747249/mgmt/api/CfgContextUtils.cc
----------------------------------------------------------------------
diff --git a/mgmt/api/CfgContextUtils.cc b/mgmt/api/CfgContextUtils.cc
index 97c8ba3..32cb139 100644
--- a/mgmt/api/CfgContextUtils.cc
+++ b/mgmt/api/CfgContextUtils.cc
@@ -344,13 +344,15 @@ port_list_to_string(PortList * ports, const char *delimiter)
     if (port_ele->port_b != TS_INVALID_PORT) { //. is this a range
       // add in range delimiter & end of range
       if (pos < sizeof(buf) &&
-          (psize = snprintf(buf + pos, sizeof(buf) - pos, "%c%d", RANGE_DELIMITER, port_ele->port_b)) > 0)
+          (psize = snprintf(buf + pos, sizeof(buf) - pos, "%c%d", RANGE_DELIMITER, port_ele->port_b)) > 0) {
         pos += psize;
+      }
     }
 
     if (i != num_ports - 1) {
-      if (pos<sizeof(buf) && (psize = snprintf(buf + pos, sizeof(buf - pos), "%s", delimiter))> 0)
+      if (pos < sizeof(buf) && (psize = snprintf(buf + pos, sizeof(buf) - pos, "%s", delimiter))> 0) {
         pos += psize;
+      }
     }
 
     enqueue((LLQ *) ports, port_ele);   // return TSPortEle to list


[21/50] git commit: TS-1787 gcc 4.8 complains about uninitialized struct tm

Posted by zw...@apache.org.
TS-1787 gcc 4.8 complains about uninitialized struct tm


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

Branch: refs/heads/3.3.x
Commit: 662cd1a5f2c4f84cbadfb0d12cb410c8d13dae79
Parents: 35344c2
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu Mar 28 13:54:29 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

----------------------------------------------------------------------
 lib/ts/ink_time.cc          |  646 --------------------------------------
 lib/ts/ink_time.h           |   83 +-----
 proxy/congest/Congestion.cc |    2 +-
 3 files changed, 8 insertions(+), 723 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/662cd1a5/lib/ts/ink_time.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_time.cc b/lib/ts/ink_time.cc
index 6b11db4..20b5158 100644
--- a/lib/ts/ink_time.cc
+++ b/lib/ts/ink_time.cc
@@ -93,569 +93,7 @@ ink_time_wall_seconds()
   return ((double) s_val.tv_sec + 0.000001 * s_val.tv_usec);
 }                               /* End ink_time_wall_seconds */
 
-/*===========================================================================*
-
-                          High-Level Date Processing
-
- *===========================================================================*/
-
-/*---------------------------------------------------------------------------*
-
-  int ink_time_gmt_string_to_tm(char *string, struct tm *broken_down_time)
-
-  This routine takes an ASCII string representation of a date <string> in one
-  of several formats, converts the string to a calendar time, and stores the
-  calendar time through the pointer <broken_down_time>.
-
-  This routine currently attempts to support RFC 1123 format, RFC 850
-  format, and asctime() format.  The times are expected to be in GMT time.
-
-  If the string is successfully parsed and converted to a date, the number
-  of characters processed from the string is returned (useful for scanning
-  over a string), otherwise 0 is returned.
-
- *---------------------------------------------------------------------------*/
-int
-ink_time_gmt_string_to_tm(char *string, struct tm *bdt)
-{
-  char *result;
-
-  /* This declaration isn't being found in time.h for some reason */
-
-  result = NULL;
-
-  /* Try RFC 1123 Format */
-
-  if (!result)
-    result = strptime(string, (char *) "%a, %d %b %Y %T GMT", bdt);
-  if (!result)
-    result = strptime(string, (char *) "%a, %d %b %Y %T UTC", bdt);
-
-  /* Try RFC 850 Format */
-
-  if (!result)
-    result = strptime(string, (char *) "%A, %d-%b-%y %T GMT", bdt);
-  if (!result)
-    result = strptime(string, (char *) "%A, %d-%b-%y %T UTC", bdt);
-
-  /* Try asctime() Format */
-
-  if (!result)
-    result = strptime(string, (char *) "%a %b %d %T %Y", bdt);
-
-  bdt->tm_isdst = -1;
-
-  /* If No Success, You Lose, Pal */
-
-  if (!result)
-    return (0);
-
-  return (result - string);
-}                               /* End ink_time_gmt_string_to_tm */
-
-
-/*---------------------------------------------------------------------------*
-
-  int ink_time_gmt_tm_to_rfc1123_string(struct tm *t, char *string, int maxsize)
-
-  This routine takes a calendar time <tm> in universal time, and converts
-  the time to an RFC 1123 formatted string as in "Sun, 06 Nov 1994 08:49:37 GMT",
-  which is placed in the string <string> up to <maxsize> bytes.  1 is
-  returned on success, else 0.
-
- *---------------------------------------------------------------------------*/
-int
-ink_time_gmt_tm_to_rfc1123_string(struct tm *t, char *string, int maxsize)
-{
-  size_t size;
-
-  size = strftime(string, maxsize, "%a, %d %b %Y %T GMT", t);
-  if (size == 0) {
-    if (maxsize > 0)
-      string[0] = '\0';
-    return (0);
-  }
-  return (1);
-}                               /* End ink_time_gmt_tm_to_rfc1123_string */
-
-
-/*---------------------------------------------------------------------------*
-
-  InkTimeDayID ink_time_tm_to_dayid(struct tm *t)
-
-  This routine takes a broken-down time <t>, and converts it to an
-  InkTimeDayID <dayid>, representing an integer number of days since a base.
-
- *---------------------------------------------------------------------------*/
-InkTimeDayID
-ink_time_tm_to_dayid(struct tm * t)
-{
-  int m, dom, y;
-  InkTimeDayID dayid;
-
-  ink_time_tm_to_mdy(t, &m, &dom, &y);
-  dayid = ink_time_mdy_to_dayid(m, dom, y);
-  return (dayid);
-}                               /* End ink_time_tm_to_dayid */
-
-
-/*---------------------------------------------------------------------------*
-
-  void ink_time_dump_dayid(FILE *fp, InkTimeDayID dayid)
-
-  This routine prints an ASCII representation of <dayid> onto the file
-  pointer <fp>.
-
- *---------------------------------------------------------------------------*/
-void
-ink_time_dump_dayid(FILE * fp, InkTimeDayID dayid)
-{
-  int m, d, y;
-
-  ink_time_dayid_to_mdy(dayid, &m, &d, &y);
-  fprintf(fp, "dayid %d (%d/%d/%d)\n", dayid, m, d, y);
-}                               /* End ink_time_dump_dayid */
-
-
-/*---------------------------------------------------------------------------*
-
-  void ink_time_dayid_to_tm(InkTimeDayID dayid, struct tm *t)
-
-  This routine takes an InkTimeDayID <dayid>, representing an integer number
-  of days since a base, and computes a broken-down time <t>.
-
- *---------------------------------------------------------------------------*/
-void
-ink_time_dayid_to_tm(InkTimeDayID dayid, struct tm *t)
-{
-  int m, dom, y;
-
-  ink_time_dayid_to_mdy(dayid, &m, &dom, &y);
-  ink_time_mdy_to_tm(m, dom, y, t);
-}                               /* End ink_time_dayid_to_tm */
-
-
-/*---------------------------------------------------------------------------*
-
-  InkTimeDayRange ink_time_dayid_to_dayrange(InkTimeDayID dayid, unsigned int width)
-
-  This routine takes a <dayid> representing a particular day, and returns
-  an InkTimeDayRange object of width <width> that spans the day in question.
-
- *---------------------------------------------------------------------------*/
-InkTimeDayRange
-ink_time_dayid_to_dayrange(InkTimeDayID dayid, unsigned int width)
-{
-  InkTimeDayRange range;
-
-  range.base = dayid - (dayid % width);
-  range.width = width;
-  return (range);
-}                               /* End ink_time_dayid_to_dayrange */
-
-
-/*---------------------------------------------------------------------------*
-
-  InkTimeDayRange ink_time_chomp_off_mouthful_of_dayrange
-	(InkTimeDayRange *dayrange_ptr, unsigned int biggest_width)
-
-  This routine takes a dayrange pointer <dayrange_ptr>, and bites off the
-  biggest possible chunk of the dayrange pointed to by <dayrange_ptr>
-  which is less than or equal to <biggest_width> and whose chunk is
-  "chomp aligned", meaning that the start of the dayrange chunk starts on
-  a multiple of the width.
-
-  The value <biggest_width> must be a positive power of two.
-
-  On exit, the chunk chomped off will be returned, and the original
-  dayrange pointed to by <dayrange_ptr> will be modified to consist of
-  the data after the chunk that was chopped off.
-
-  If the dayrange pointed to by <dayrange_ptr> has no size, a dayrange
-  of size 0 is returned, and the original data is unmodified.
-
-  The purpose of this routine is to decompose a range of consecutive days
-  into a collection of variable-sized, disjoint day ranges which cover the
-  original space of days.
-
- *---------------------------------------------------------------------------*/
-InkTimeDayRange
-ink_time_chomp_off_mouthful_of_dayrange(InkTimeDayRange * dayrange_ptr, unsigned int biggest_width)
-{
-  unsigned int width;
-  InkTimeDayRange chomped_chunk;
-
-  chomped_chunk.base = dayrange_ptr->base;
-
-  for (width = biggest_width; width >= 1; width = width / 2) {
-    if ((width <= dayrange_ptr->width) && ((dayrange_ptr->base % width) == 0)) {
-      chomped_chunk.width = width;
-
-      dayrange_ptr->base += width;
-      dayrange_ptr->width -= width;
-
-      return (chomped_chunk);
-    }
-  }
-
-  chomped_chunk.width = 0;
-
-  return (chomped_chunk);
-}                               /* End ink_time_chomp_off_mouthful_of_dayrange */
-
-
-/*---------------------------------------------------------------------------*
-
-  char *ink_time_dayrange_to_string(InkTimeDayRange *dayrange_ptr, char *buf)
-
-  This routine take a day range pointer <dayrange_ptr>, and places a string
-  representation of the day range in the buffer <buf>.  The buffer must be
-  big enough to hold the representation of the dayrange.
-
-  Of course, you shouldn't have any idea what the representation is, so I
-  guess you're hosed.  Something like 64 characters is probably reasonable.
-
-  The pointer <buf> is returned.
-
- *---------------------------------------------------------------------------*/
-char *
-ink_time_dayrange_to_string(InkTimeDayRange * dayrange_ptr, char *buf, const size_t bufSize)
-{
-  if (bufSize > 0) {
-    buf[0] = '\0';
-  }
-
-  snprintf(buf, bufSize, "range_start_%d_width_%u", dayrange_ptr->base, dayrange_ptr->width);
-  return (buf);
-}                               /* End ink_time_dayrange_to_string */
-
-
-/*===========================================================================*
-
-                          Date Conversion Routines
-
-  Note that both the day of month and the month number start at 1 not zero,
-  so January 1 is <m=1,d=1> not <m=0,d=0>.
-
- *===========================================================================*/
-
-static int _base_day = 4;       /* 1/1/1970 is Thursday */
-static int _base_year = 1970;
-
-static int _base_daysinmonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
-
-static const char *_day_names[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
-static const char *_month_names[12] = {
-  "Jan", "Feb", "Mar", "Apr", "May", "Jun",
-  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
-};
-
-
-/*---------------------------------------------------------------------------*
-
-  void ink_time_current_mdy(int *m, int *dom, int *y)
-
-  Gets the current local date in GMT, and returns the month, day of month,
-  and year in GMT.
-
- *---------------------------------------------------------------------------*/
-void
-ink_time_current_mdy(int *m, int *dom, int *y)
-{
-  time_t c;
-  struct tm t;
-  c = time(0);
-  ink_gmtime_r(&c, &t);
-  ink_time_tm_to_mdy(&t, m, dom, y);
-}                               /* End ink_time_current_mdy */
-
-
-/*---------------------------------------------------------------------------*
-
-  void ink_time_tm_to_mdy(struct tm *t, int *m, int *dom, int *y)
-
-  Takes a broken down time pointer <t>, and returns the month, day of month,
-  and year.
-
- *---------------------------------------------------------------------------*/
-void
-ink_time_tm_to_mdy(struct tm *t, int *m, int *dom, int *y)
-{
-  *m = t->tm_mon + 1;
-  *dom = t->tm_mday;
-  *y = t->tm_year + 1900;
-}                               /* End ink_time_tm_to_mdy */
-
-
-/*---------------------------------------------------------------------------*
-
-  void ink_time_mdy_to_tm(int m, int dom, int y, struct tm *t)
-
-  Takes a month <m>, day of month <dom>, and year <y>, and places a
-  broken-down time in the structure pointed to by <t>.
-
- *---------------------------------------------------------------------------*/
-void
-ink_time_mdy_to_tm(int m, int dom, int y, struct tm *t)
-{
-  bzero((char *) t, sizeof(*t));
-  t->tm_mon = m - 1;
-  t->tm_mday = dom;
-  t->tm_year = y - 1900;
-  t->tm_wday = ink_time_mdy_to_dow(m, dom, y);
-  t->tm_yday = ink_time_mdy_to_doy(m, dom, y);
-}                               /* End ink_time_mdy_to_tm */
-
-
-/*---------------------------------------------------------------------------*
-
-  InkTimeDayID ink_time_mdy_to_dayid(int m, int dom, int y)
-
-  Return a single integer representing encoding of the day <m> <dom>, <y>.
-  The encoding is performed with respect to the base day.
-
- *---------------------------------------------------------------------------*/
-InkTimeDayID
-ink_time_mdy_to_dayid(int m, int dom, int y)
-{
-  int year, month;
-  InkTimeDayID dayid;
-
-  dayid = 0;
-  for (year = _base_year; year < y; year++)
-    dayid = dayid + ink_time_days_in_year(year);
-  for (month = 1; month < m; month++)
-    dayid = dayid + ink_time_days_in_month(month, year);
-  dayid = dayid + dom - 1;
-  return (dayid);
-}                               /* End ink_time_mdy_to_dayid */
-
-
-/*---------------------------------------------------------------------------*
-
-  InkTimeDayID ink_time_current_dayid()
-
-  Return a single integer representing encoding of the today's date.
-  The encoding is performed with respect to the base day.
-
- *---------------------------------------------------------------------------*/
-InkTimeDayID
-ink_time_current_dayid()
-{
-  InkTimeDayID today;
-  int today_m, today_d, today_y;
-
-  ink_time_current_mdy(&today_m, &today_d, &today_y);
-  today = ink_time_mdy_to_dayid(today_m, today_d, today_y);
-
-  return (today);
-}                               /* End ink_time_current_dayid */
-
-
-/*---------------------------------------------------------------------------*
-
-  void ink_time_dayid_to_mdy(InkTimeDayID dayid, int *mp, int *dp, int *yp)
-
-  Takes a single integer representation of the date, and convert to the
-  month <m>, day of month <dom>, and year <y>.
-
- *---------------------------------------------------------------------------*/
-void
-ink_time_dayid_to_mdy(InkTimeDayID dayid, int *mp, int *dp, int *yp)
-{
-  dayid = dayid + 1;
-  for (*yp = _base_year; ink_time_days_in_year(*yp) < dayid; (*yp)++)
-    dayid = dayid - ink_time_days_in_year(*yp);
-  for (*mp = 1; ink_time_days_in_month(*mp, *yp) < dayid; (*mp)++)
-    dayid = dayid - ink_time_days_in_month(*mp, *yp);
-  *dp = dayid;
-}                               /* End ink_time_dayid_to_mdy */
-
-
-/*---------------------------------------------------------------------------*
-
-  int ink_time_mdy_to_doy(int m, int dom, int y)
-
-  Takes a date <m> <dom> <y>, and returns the number of days into year <y>.
-
- *---------------------------------------------------------------------------*/
-int
-ink_time_mdy_to_doy(int m, int dom, int y)
-{
-  InkTimeDayID first, current;
-
-  first = ink_time_mdy_to_dayid(1, 1, y);
-  current = ink_time_mdy_to_dayid(m, dom, y);
-  return (current - first);
-}                               /* End ink_time_mdy_to_doy */
-
-
-/*---------------------------------------------------------------------------*
-
-  void ink_time_doy_to_mdy(int doy, int year, int *mon, int *dom, int *dow)
-
-  This routine take a <year>, and a zero-based <doy> within the year,
-  and determines the corresponding month, day of month, and day of week.
-
- *---------------------------------------------------------------------------*/
-void
-ink_time_doy_to_mdy(int doy, int year, int *mon, int *dom, int *dow)
-{
-  int month, daysinmonth, days_so_far, next_days_so_far;
-
-  days_so_far = 1;
-  for (month = 1; month <= 12; month++) {
-    daysinmonth = ink_time_days_in_month(month, year);
-    next_days_so_far = days_so_far + daysinmonth;
-    if (doy >= days_so_far && doy < next_days_so_far) {
-      *mon = month;
-      *dom = doy - days_so_far + 1;
-      *dow = ink_time_mdy_to_dow(month, *dom, year);
-      return;
-    }
-    days_so_far = next_days_so_far;
-  }
-}                               /* End ink_time_doy_to_mdy */
-
-
-/*---------------------------------------------------------------------------*
-
-  int ink_time_mdy_to_dow(int month, int dom, int year)
-
-  What day of the week does <month> <dom>, <year> fall on?
-
- *---------------------------------------------------------------------------*/
-int
-ink_time_mdy_to_dow(int month, int dom, int year)
-{
-  int i, base;
-
-  base = ink_time_first_day_of_year(year);
-  for (i = 0; i < month - 1; i++) {
-    base = (base + ink_time_days_in_month(i + 1, year)) % 7;
-  }
-  return ((base + dom - 1) % 7);
-}                               /* End ink_time_mdy_to_dow */
-
-
-/*---------------------------------------------------------------------------*
-
-  int ink_time_days_in_month(int month, int year)
-
-  This routine returns the number of days in a particular <month> and <year>.
-
- *---------------------------------------------------------------------------*/
-int
-ink_time_days_in_month(int month, int year)
-{
-  return (_base_daysinmonth[month - 1] + (month == 2 ? ink_time_leap_year_correction(year) : 0));
-}                               /* End ink_time_days_in_month */
-
-
-/*---------------------------------------------------------------------------*
-
-  int ink_time_days_in_year(int year)
-
-  This routine returns the number of days in the year <year>, compensating
-  for leap years.
-
- *---------------------------------------------------------------------------*/
-int
-ink_time_days_in_year(int year)
-{
-  return (365 + ink_time_leap_year_correction(year));
-}                               /* End ink_time_days_in_year */
-
-
-/*---------------------------------------------------------------------------*
-
-  int ink_time_first_day_of_year(int year)
-
-  What day is January 1 on in this year?
-
- *---------------------------------------------------------------------------*/
-int
-ink_time_first_day_of_year(int year)
-{
-  int i, base;
-
-  base = _base_day;
-  if (year > _base_year) {
-    for (i = _base_year; i < year; i++)
-      base = (base + ink_time_days_in_year(i)) % 7;
-  } else if (year < _base_year) {
-    for (i = _base_year - 1; i >= year; i--)
-      base = ((base - ink_time_days_in_year(i)) % 7 + 7) % 7;
-  }
-  return (base);
-}                               /* End ink_time_first_day_of_year */
-
-
-/*---------------------------------------------------------------------------*
-
-  void ink_time_day_to_string(int day, char *buffer)
-
-  This routine takes a day number and places a 3 character, NUL terminated
-  string representing this day in the buffer pointed to by <buffer>.
-
- *---------------------------------------------------------------------------*/
-void
-ink_time_day_to_string(int day, char *buffer, const size_t bufferSize)
-{
-  ink_strlcpy(buffer, _day_names[day], bufferSize);
-}                               /* End ink_time_day_to_string */
-
-
-/*---------------------------------------------------------------------------*
-
-  void ink_time_month_to_string(int month, char *buffer)
-
-  This routine takes a month number and places a 3 character, NUL terminated
-  string representing this day in the buffer pointed to by <buffer>.
-
- *---------------------------------------------------------------------------*/
-void
-ink_time_month_to_string(int month, char *buffer, const size_t bufferSize)
-{
-  ink_strlcpy(buffer, _month_names[month - 1], bufferSize);
-}                               /* End ink_time_month_to_string */
-
-
-/*---------------------------------------------------------------------------*
-
-  int ink_time_string_to_month(char *str)
 
-  This routine takes a name of a month <str>, and returns the corresponding
-  month number, else -1.
-
- *---------------------------------------------------------------------------*/
-int
-ink_time_string_to_month(char *str)
-{
-  int i;
-
-  for (i = 0; i < 12; i++) {
-    if (strcasecmp(str, _month_names[i]) == 0)
-      return (i + 1);
-  }
-  return (-1);
-}                               /* End ink_time_string_to_month */
-
-
-/*---------------------------------------------------------------------------*
-
-  int ink_time_leap_year_correction(int year)
-
-  Return 1 if <year> is a leap year, 0 if not, and -1 if negative leap year.
-
- *---------------------------------------------------------------------------*/
-int
-ink_time_leap_year_correction(int year)
-{
-  return (ink_time_is_4th_year(year) - ink_time_is_100th_year(year) + ink_time_is_400th_year(year));
-}                               /* End ink_time_leap_year_correction */
-
-/* asah #ifndef sun asah */
 struct dtconv
 {
   char *abbrev_month_names[12];
@@ -669,7 +107,6 @@ struct dtconv
   char *pm_string;
   char *ldate_format;
 };
-/* asah #endif asah */
 
 
 
@@ -703,89 +140,6 @@ cftime(char *s, char *format, const time_t * clock)
 
 #define DAYS_OFFSET  25508
 
-int
-ink_gmtime_r(const ink_time_t * clock, struct tm *res)
-{
-  static const char months[] = {
-    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4,
-    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5,
-    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
-    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6,
-    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
-    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7,
-    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-    7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8,
-    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-    8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9,
-    9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
-    9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
-    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
-    10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-    11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-    11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
-  };
-  static const int days[12] = {
-    305, 336, -1, 30, 60, 91, 121, 152, 183, 213, 244, 274
-  };
-
-  size_t t = *clock;
-
-  size_t d, dp;
-
-  size_t sec = t % 60;
-  t /= 60;
-  size_t min = t % 60;
-  t /= 60;
-  size_t hour = t % 24;
-  t /= 24;
-
-  /* Jan 1, 1970 was a Thursday */
-  size_t wday = (4 + t) % 7;
-
-  /* guess the year and refine the guess */
-  size_t yday = t;
-  size_t year = yday / 365 + 69;
-
-  d = dp = (year * 365) + (year / 4) - (year / 100) + (year / 100 + 3) / 4 - DAYS_OFFSET - 1;
-
-  while (dp < yday) {
-    d = dp;
-    year += 1;
-    dp = (year * 365) + (year / 4) - (year / 100) + (year / 100 + 3) / 4 - DAYS_OFFSET - 1;
-  }
-
-  /* convert the days */
-  d = yday - d;
-  if (d> 366)
-    return -1;
-
-  size_t month = months[d];
-  if (month > 1)
-    year -= 1;
-
-  size_t mday = d - days[month] - 1;
-  // year += 1900; real year
-
-  res->tm_sec = (int) sec;
-  res->tm_min = (int) min;
-  res->tm_hour = (int) hour;
-  res->tm_mday = (int) mday;
-  res->tm_mon = (int) month;
-  res->tm_year = (int) year;
-  res->tm_wday = (int) wday;
-  res->tm_yday = (int) yday;
-  res->tm_isdst = 0;
-
-  return 0;
-}
-
 ink_time_t
 convert_tm(const struct tm * tp)
 {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/662cd1a5/lib/ts/ink_time.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_time.h b/lib/ts/ink_time.h
index 41ae79e..daffd7a 100644
--- a/lib/ts/ink_time.h
+++ b/lib/ts/ink_time.h
@@ -47,14 +47,6 @@
 
 typedef time_t ink_time_t;
 
-typedef int InkTimeDayID;
-
-typedef struct
-{
-  InkTimeDayID base;
-  unsigned int width;
-} InkTimeDayRange;
-
 /*===========================================================================*
 
                                  Prototypes
@@ -69,65 +61,17 @@ typedef struct
 uint64_t ink_microseconds(int which);
 double ink_time_wall_seconds();
 
-int ink_time_gmt_string_to_tm(char *string, struct tm *bdt);
-int ink_time_gmt_tm_to_rfc1123_string(struct tm *t, char *string, int maxsize);
-
-InkTimeDayID ink_time_tm_to_dayid(struct tm *t);
-void ink_time_dump_dayid(FILE * fp, InkTimeDayID dayid);
-void ink_time_dayid_to_tm(InkTimeDayID dayid, struct tm *t);
-InkTimeDayRange ink_time_dayid_to_dayrange(InkTimeDayID dayid, unsigned int width);
-InkTimeDayRange ink_time_chomp_off_mouthful_of_dayrange(InkTimeDayRange * dayrange_ptr, unsigned int biggest_width);
-char *ink_time_dayrange_to_string(InkTimeDayRange * dayrange_ptr, char *buf);
-
-void ink_time_current_mdy(int *m, int *dom, int *y);
-void ink_time_tm_to_mdy(struct tm *t, int *m, int *dom, int *y);
-void ink_time_mdy_to_tm(int m, int dom, int y, struct tm *t);
-InkTimeDayID ink_time_mdy_to_dayid(int m, int dom, int y);
-InkTimeDayID ink_time_current_dayid();
-void ink_time_dayid_to_mdy(InkTimeDayID dayid, int *mp, int *dp, int *yp);
-int ink_time_mdy_to_doy(int m, int dom, int y);
-void ink_time_doy_to_mdy(int doy, int year, int *mon, int *dom, int *dow);
-int ink_time_mdy_to_dow(int month, int dom, int year);
-int ink_time_days_in_month(int month, int year);
-int ink_time_days_in_year(int year);
-int ink_time_first_day_of_year(int year);
-void ink_time_day_to_string(int day, char *buffer);
-void ink_time_month_to_string(int month, char *buffer);
-int ink_time_string_to_month(char *str);
-int ink_time_leap_year_correction(int year);
-
-/*===========================================================================*
-
-                              Inline Stuffage
-
- *===========================================================================*/
-
-static inline int
-ink_time_is_4th_year(int year)
-{
-  return ((year % 4) == 0);
-}                               /* End ink_time_is_4th_year */
-
-
-static inline int
-ink_time_is_100th_year(int year)
-{
-  return ((year % 100) == 0);
-}                               /* End ink_time_is_100th_year */
-
-
-static inline int
-ink_time_is_400th_year(int year)
-{
-  return ((year % 400) == 0);
-}                               /* End ink_time_is_400th_year */
-
 int cftime_replacement(char *s, int maxsize, const char *format, const time_t * clock);
 #define cftime(s, format, clock) cftime_replacement(s, 8192, format, clock)
 
-inkcoreapi int ink_gmtime_r(const ink_time_t * clock, struct tm *res);
 ink_time_t convert_tm(const struct tm *tp);
 
+inkcoreapi char *ink_ctime_r(const ink_time_t * clock, char *buf);
+inkcoreapi struct tm *ink_localtime_r(const ink_time_t * clock, struct tm *res);
+
+/*===========================================================================*
+                              Inline Stuffage
+ *===========================================================================*/
 #if defined(freebsd) || defined(openbsd)
 
 inline int
@@ -139,15 +83,6 @@ ink_timezone()
   return tzp.tz_minuteswest * 60;
 }
 
-/* vl: not used
-inline int ink_daylight() {
-  struct tm atm;
-  time_t t = time(NULL);
-  ink_assert(!localtime_r(&t, &atm));
-  return atm.tm_isdst;
-}
-*/
-
 #else  // non-freebsd, non-openbsd for the else
 
 inline int
@@ -156,10 +91,6 @@ ink_timezone()
   return timezone;
 }
 
-/* vl: not used - inline int ink_daylight() { return daylight; } */
-#endif
-
-inkcoreapi char *ink_ctime_r(const ink_time_t * clock, char *buf);
-inkcoreapi struct tm *ink_localtime_r(const ink_time_t * clock, struct tm *res);
+#endif /* #if defined(freebsd) || defined(openbsd) */
 
 #endif /* #ifndef _ink_time_h_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/662cd1a5/proxy/congest/Congestion.cc
----------------------------------------------------------------------
diff --git a/proxy/congest/Congestion.cc b/proxy/congest/Congestion.cc
index f790134..af27304 100644
--- a/proxy/congest/Congestion.cc
+++ b/proxy/congest/Congestion.cc
@@ -709,7 +709,7 @@ CongestionEntry::sprint(char *buf, int buflen, int format)
       if (congestionControlLocalTime) {
         ink_localtime_r(&seconds, &time);
       } else {
-        ink_gmtime_r(&seconds, &time);
+        gmtime_r(&seconds, &time);
       }
       snprintf(str_time, sizeof(str_time), "%04d/%02d/%02d %02d:%02d:%02d",
                    time.tm_year + 1900, time.tm_mon + 1, time.tm_mday, time.tm_hour, time.tm_min, time.tm_sec);


[10/50] git commit: TS-1791: remove m_mutex acquire&release to avoid deadlock

Posted by zw...@apache.org.
TS-1791: remove m_mutex acquire&release to avoid deadlock


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

Branch: refs/heads/3.3.x
Commit: 20c6a459fd943b9460052af427bf7a54701ae9ae
Parents: 3c1e58a
Author: Gang Li <qu...@taobao.com>
Authored: Mon Apr 1 16:35:31 2013 +0800
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:42 2013 -0600

----------------------------------------------------------------------
 CHANGES                    |    3 +++
 proxy/logging/LogBuffer.cc |    4 +---
 2 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/20c6a459/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 8a5218a..9883ad7 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1791] remove m_mutex acquire&release to avoid deadlock in
+   ~LogBufferList(). Author: Gang Li <qu...@taobao.com>.
+   
   *) [TS-1713] SRV support refine. Now the srv option is able to enable, with
    no crash. Be care, the hostdb.storage_size or ostdb.size need check.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/20c6a459/proxy/logging/LogBuffer.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogBuffer.cc b/proxy/logging/LogBuffer.cc
index 937247b..5cfab2a 100644
--- a/proxy/logging/LogBuffer.cc
+++ b/proxy/logging/LogBuffer.cc
@@ -764,12 +764,10 @@ LogBufferList::LogBufferList()
 LogBufferList::~LogBufferList()
 {
   LogBuffer *lb;
-  ink_mutex_acquire(&m_mutex);
-  m_size = 0;
   while ((lb = get()) != NULL) {
       delete lb;
   }
-  ink_mutex_release(&m_mutex);
+  m_size = 0;
   ink_mutex_destroy(&m_mutex);
 }
 


[12/50] git commit: TS-1766: Add iocore/eventsystem tests to the build

Posted by zw...@apache.org.
TS-1766: Add iocore/eventsystem tests 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/67c7bf40
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/67c7bf40
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/67c7bf40

Branch: refs/heads/3.3.x
Commit: 67c7bf4068ced8f1f100495b67b1720a6a3e0624
Parents: 8e94fa7
Author: James Peach <jp...@apache.org>
Authored: Wed Mar 27 12:09:42 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:42 2013 -0600

----------------------------------------------------------------------
 iocore/eventsystem/I_IOBuffer.h   |    2 +-
 iocore/eventsystem/Makefile.am    |   32 ++++++
 iocore/eventsystem/test_Buffer.cc |   43 ++++----
 iocore/eventsystem/test_Event.cc  |  175 ++++++++++++++++++++++++++++++++
 iocore/eventsystem/test_Event.i   |  174 -------------------------------
 5 files changed, 230 insertions(+), 196 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67c7bf40/iocore/eventsystem/I_IOBuffer.h
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/I_IOBuffer.h b/iocore/eventsystem/I_IOBuffer.h
index 23a2ddc..3a8ab08 100644
--- a/iocore/eventsystem/I_IOBuffer.h
+++ b/iocore/eventsystem/I_IOBuffer.h
@@ -793,7 +793,7 @@ public:
   the center of all IOCore data transfer. MIOBuffers are the data
   buffers used to transfer data to and from VConnections. A MIOBuffer
   points to a list of IOBufferBlocks which in turn point to IOBufferData
-  stucutres that in turn point to the actual data. MIOBuffer allows one
+  structures that in turn point to the actual data. MIOBuffer allows one
   producer and multiple consumers. The buffer fills up according the
   amount of data outstanding for the slowest consumer. Thus, MIOBuffer
   implements automatic flow control between readers of different speeds.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67c7bf40/iocore/eventsystem/Makefile.am
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/Makefile.am b/iocore/eventsystem/Makefile.am
index 0e002c1..59a8a24 100644
--- a/iocore/eventsystem/Makefile.am
+++ b/iocore/eventsystem/Makefile.am
@@ -22,6 +22,7 @@ AM_CPPFLAGS = \
   -I$(top_srcdir)/lib/ts
 
 DEFS += @IOCORE_MODULARIZED_DEFS@
+TESTS = $(check_PROGRAMS)
 
 noinst_LIBRARIES = libinkevent.a
 
@@ -67,3 +68,34 @@ libinkevent_a_SOURCES = \
   Inline.cc \
   Tasks.cc \
   I_Tasks.h
+
+check_PROGRAMS = test_Buffer test_Event
+
+test_CXXFLAGS = \
+  $(iocore_include_dirs) \
+  -I$(top_builddir)/proxy \
+  -I$(top_builddir)/proxy/api/ts \
+  -I$(top_srcdir)/proxy/api \
+  -I$(top_srcdir)/proxy \
+  -I$(top_srcdir)/proxy/hdrs \
+  -I$(top_srcdir)/proxy/http \
+  -I$(top_srcdir)/proxy/logging \
+  -I$(top_srcdir)/mgmt \
+  -I$(top_srcdir)/mgmt/utils
+
+test_LDADD = \
+  libinkevent.a \
+  $(top_builddir)/lib/records/librecprocess.a \
+  $(top_builddir)/mgmt/libmgmt_p.a \
+  $(top_builddir)/mgmt/utils/libutils_p.a \
+  $(top_builddir)/iocore/eventsystem/libinkevent.a \
+  $(top_builddir)/lib/ts/libtsutil.la
+
+test_Buffer_SOURCES = ../../proxy/UglyLogStubs.cc test_Buffer.cc
+test_Event_SOURCES = ../../proxy/UglyLogStubs.cc test_Event.cc
+test_Buffer_CXXFLAGS = $(test_CXXFLAGS)
+test_Event_CXXFLAGS = $(test_CXXFLAGS)
+
+test_Buffer_LDADD = $(test_LDADD)
+test_Event_LDADD = $(test_LDADD)
+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67c7bf40/iocore/eventsystem/test_Buffer.cc
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/test_Buffer.cc b/iocore/eventsystem/test_Buffer.cc
index e0b8f23..5638368 100644
--- a/iocore/eventsystem/test_Buffer.cc
+++ b/iocore/eventsystem/test_Buffer.cc
@@ -22,14 +22,18 @@
  */
 
 #include "I_EventSystem.h"
+#include "I_Layout.h"
 
 #define TEST_TIME_SECOND 60
 #define TEST_THREADS     2
 
-int count;
 Diags *diags;
 #define DIAGS_LOG_FILE "diags.log"
 
+void syslog_thr_init(void)
+{
+}
+
 //////////////////////////////////////////////////////////////////////////////
 //
 //      void reconfigure_diags()
@@ -45,7 +49,6 @@ reconfigure_diags()
   int i;
   DiagsConfigState c;
 
-
   // initial value set to 0 or 1 based on command line tags
   c.enabled[DiagsTagType_Debug] = (diags->base_debug_tags != NULL);
   c.enabled[DiagsTagType_Action] = (diags->base_action_tags != NULL);
@@ -54,7 +57,6 @@ reconfigure_diags()
   c.enabled[DiagsTagType_Action] = 1;
   diags->show_location = 1;
 
-
   // read output routing values
   for (i = 0; i < DiagsLevel_Count; i++) {
 
@@ -91,10 +93,8 @@ reconfigure_diags()
 
 }
 
-
-
 static void
-init_diags(char *bdt, char *bat)
+init_diags(const char *bdt, const char *bat)
 {
   FILE *diags_log_fp;
   char diags_logpath[500];
@@ -113,41 +113,42 @@ init_diags(char *bdt, char *bat)
   diags = NEW(new Diags(bdt, bat, diags_log_fp));
 
   if (diags_log_fp == NULL) {
-    SrcLoc loc(__FILE__, __FUNCTION__, __LINE__);
-
-    diags->print(NULL, DL_Warning, NULL, &loc,
-                 "couldn't open diags log file '%s', " "will not log to this file", diags_logpath);
+    Warning("couldn't open diags log file '%s', " "will not log to this file", diags_logpath);
   }
 
-  diags->print(NULL, DL_Status, "STATUS", NULL, "opened %s", diags_logpath);
+  Status("opened %s", diags_logpath);
   reconfigure_diags();
 
 }
 
-
 int
-main()
+main(int argc, const char *argv[])
 {
   RecModeT mode_type = RECM_STAND_ALONE;
-  count = 0;
+
+  Layout::create();
+  init_diags("", NULL);
   RecProcessInit(mode_type);
 
   ink_event_system_init(EVENT_SYSTEM_MODULE_VERSION);
   eventProcessor.start(TEST_THREADS);
 
-  for (int i = 0; i < 100; i++) {
+  for (unsigned i = 0; i < 100; ++i) {
     MIOBuffer *b1 = new_MIOBuffer(default_large_iobuffer_size);
     IOBufferReader *b1reader = b1->alloc_reader();
-    b1->fill(1024 * 3);
+    b1->fill(b1->write_avail());
+
     MIOBuffer *b2 = new_MIOBuffer(default_large_iobuffer_size);
     IOBufferReader *b2reader = b2->alloc_reader();
-    b2->fill(1024 * 3);
+    b2->fill(b2->write_avail());
+
     //b1->write(b2reader, 2*1024);
+
     free_MIOBuffer(b2);
-    /* leak this */
-    b1 = NULL;
-    if ((i % 20) == 0)
-      xdump_to_file(stderr);
+    free_MIOBuffer(b1);
+
+    NOWARN_UNUSED(b1reader);
+    NOWARN_UNUSED(b2reader);
   }
 
   exit(0);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67c7bf40/iocore/eventsystem/test_Event.cc
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/test_Event.cc b/iocore/eventsystem/test_Event.cc
new file mode 100644
index 0000000..cc4b9db
--- /dev/null
+++ b/iocore/eventsystem/test_Event.cc
@@ -0,0 +1,175 @@
+/** @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.
+ */
+
+#include "I_EventSystem.h"
+#include "I_Layout.h"
+
+#define TEST_TIME_SECOND 60
+#define TEST_THREADS     2
+
+int count;
+Diags *diags;
+#define DIAGS_LOG_FILE "diags.log"
+
+void syslog_thr_init(void)
+{
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//      void reconfigure_diags()
+//
+//      This function extracts the current diags configuration settings from
+//      records.config, and rebuilds the Diags data structures.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+static void
+reconfigure_diags()
+{
+  int i;
+  DiagsConfigState c;
+
+  // initial value set to 0 or 1 based on command line tags
+  c.enabled[DiagsTagType_Debug] = (diags->base_debug_tags != NULL);
+  c.enabled[DiagsTagType_Action] = (diags->base_action_tags != NULL);
+
+  c.enabled[DiagsTagType_Debug] = 1;
+  c.enabled[DiagsTagType_Action] = 1;
+  diags->show_location = 1;
+
+  // read output routing values
+  for (i = 0; i < DiagsLevel_Count; i++) {
+
+    c.outputs[i].to_stdout = 0;
+    c.outputs[i].to_stderr = 1;
+    c.outputs[i].to_syslog = 1;
+    c.outputs[i].to_diagslog = 1;
+  }
+
+  //////////////////////////////
+  // clear out old tag tables //
+  //////////////////////////////
+
+  diags->deactivate_all(DiagsTagType_Debug);
+  diags->deactivate_all(DiagsTagType_Action);
+
+  //////////////////////////////////////////////////////////////////////
+  //                     add new tag tables
+  //////////////////////////////////////////////////////////////////////
+
+  if (diags->base_debug_tags)
+    diags->activate_taglist(diags->base_debug_tags, DiagsTagType_Debug);
+  if (diags->base_action_tags)
+    diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action);
+
+  ////////////////////////////////////
+  // change the diags config values //
+  ////////////////////////////////////
+#if !defined(__GNUC__) && !defined(hpux)
+  diags->config = c;
+#else
+  memcpy(((void *) &diags->config), ((void *) &c), sizeof(DiagsConfigState));
+#endif
+
+}
+
+static void
+init_diags(const char *bdt, const char *bat)
+{
+  FILE *diags_log_fp;
+  char diags_logpath[500];
+  strcpy(diags_logpath, DIAGS_LOG_FILE);
+
+  diags_log_fp = fopen(diags_logpath, "w");
+  if (diags_log_fp) {
+    int status;
+    status = setvbuf(diags_log_fp, NULL, _IOLBF, 512);
+    if (status != 0) {
+      fclose(diags_log_fp);
+      diags_log_fp = NULL;
+    }
+  }
+
+  diags = NEW(new Diags(bdt, bat, diags_log_fp));
+
+  if (diags_log_fp == NULL) {
+    Warning("couldn't open diags log file '%s', " "will not log to this file", diags_logpath);
+  }
+
+  Status("opened %s", diags_logpath);
+  reconfigure_diags();
+
+}
+
+struct alarm_printer:public Continuation
+{
+  alarm_printer(ProxyMutex * m):Continuation(m)
+  {
+    SET_HANDLER(&alarm_printer::dummy_function);
+  }
+  int dummy_function(int event, Event * e)
+  {
+    ink_atomic_increment((int *) &count, 1);
+    printf("Count = %d\n", count);
+    return 0;
+  }
+};
+struct process_killer:public Continuation
+{
+  process_killer(ProxyMutex * m):Continuation(m)
+  {
+    SET_HANDLER(&process_killer::kill_function);
+  }
+  int kill_function(int event, Event * e)
+  {
+    printf("Count is %d \n", count);
+    if (count <= 0)
+      exit(1);
+    if (count > TEST_TIME_SECOND * TEST_THREADS)
+      exit(1);
+    exit(0);
+    return 0;
+  }
+};
+
+int
+main(int argc, const char *argv[])
+{
+  RecModeT mode_type = RECM_STAND_ALONE;
+  count = 0;
+
+  Layout::create();
+  init_diags("", NULL);
+  RecProcessInit(mode_type);
+
+  ink_event_system_init(EVENT_SYSTEM_MODULE_VERSION);
+  eventProcessor.start(TEST_THREADS);
+
+  alarm_printer *alrm = new alarm_printer(new_ProxyMutex());
+  process_killer *killer = new process_killer(new_ProxyMutex());
+  eventProcessor.schedule_in(killer, HRTIME_SECONDS(10));
+  eventProcessor.schedule_every(alrm, HRTIME_SECONDS(1));
+  this_thread()->execute();
+  return 0;
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67c7bf40/iocore/eventsystem/test_Event.i
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/test_Event.i b/iocore/eventsystem/test_Event.i
deleted file mode 100644
index 3370047..0000000
--- a/iocore/eventsystem/test_Event.i
+++ /dev/null
@@ -1,174 +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.
- */
-
-#define TEST_TIME_SECOND 60
-#define TEST_THREADS     2
-
-int count;
-Diags *diags;
-#define DIAGS_LOG_FILE "diags.log"
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//      void reconfigure_diags()
-//
-//      This function extracts the current diags configuration settings from
-//      records.config, and rebuilds the Diags data structures.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-static void
-reconfigure_diags()
-{
-  int i;
-  DiagsConfigState c;
-
-
-  // initial value set to 0 or 1 based on command line tags
-  c.enabled[DiagsTagType_Debug] = (diags->base_debug_tags != NULL);
-  c.enabled[DiagsTagType_Action] = (diags->base_action_tags != NULL);
-
-  c.enabled[DiagsTagType_Debug] = 1;
-  c.enabled[DiagsTagType_Action] = 1;
-  diags->show_location = 1;
-
-
-  // read output routing values
-  for (i = 0; i < DiagsLevel_Count; i++) {
-
-    c.outputs[i].to_stdout = 0;
-    c.outputs[i].to_stderr = 1;
-    c.outputs[i].to_syslog = 1;
-    c.outputs[i].to_diagslog = 1;
-  }
-
-  //////////////////////////////
-  // clear out old tag tables //
-  //////////////////////////////
-
-  diags->deactivate_all(DiagsTagType_Debug);
-  diags->deactivate_all(DiagsTagType_Action);
-
-  //////////////////////////////////////////////////////////////////////
-  //                     add new tag tables 
-  //////////////////////////////////////////////////////////////////////
-
-  if (diags->base_debug_tags)
-    diags->activate_taglist(diags->base_debug_tags, DiagsTagType_Debug);
-  if (diags->base_action_tags)
-    diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action);
-
-  ////////////////////////////////////
-  // change the diags config values //
-  ////////////////////////////////////
-#if !defined(__GNUC__) && !defined(hpux)
-  diags->config = c;
-#else
-  memcpy(((void *) &diags->config), ((void *) &c), sizeof(DiagsConfigState));
-#endif
-
-}
-
-
-
-static void
-init_diags(char *bdt, char *bat)
-{
-  FILE *diags_log_fp;
-  char diags_logpath[500];
-  strcpy(diags_logpath, DIAGS_LOG_FILE);
-
-  diags_log_fp = fopen(diags_logpath, "w");
-  if (diags_log_fp) {
-    int status;
-    status = setvbuf(diags_log_fp, NULL, _IOLBF, 512);
-    if (status != 0) {
-      fclose(diags_log_fp);
-      diags_log_fp = NULL;
-    }
-  }
-
-  diags = NEW(new Diags(bdt, bat, diags_log_fp));
-
-  if (diags_log_fp == NULL) {
-    SrcLoc loc(__FILE__, __FUNCTION__, __LINE__);
-
-    diags->print(NULL, DL_Warning, NULL, &loc,
-                 "couldn't open diags log file '%s', " "will not log to this file", diags_logpath);
-  }
-
-  diags->print(NULL, DL_Status, "STATUS", NULL, "opened %s", diags_logpath);
-  reconfigure_diags();
-
-}
-
-struct alarm_printer:public Continuation
-{
-  alarm_printer(ProxyMutex * m):Continuation(m)
-  {
-    SET_HANDLER(&alarm_printer::dummy_function);
-  }
-  int dummy_function(int event, Event * e)
-  {
-    ink_atomic_increment((int *) &count, 1);
-    printf("Count = %d\n", count);
-    return 0;
-  }
-};
-struct process_killer:public Continuation
-{
-  process_killer(ProxyMutex * m):Continuation(m)
-  {
-    SET_HANDLER(&process_killer::kill_function);
-  }
-  int kill_function(int event, Event * e)
-  {
-    printf("Count is %d \n", count);
-    if (count <= 0)
-      exit(1);
-    if (count > TEST_TIME_SECOND * TEST_THREADS)
-      exit(1);
-    exit(0);
-    return 0;
-  }
-};
-
-
-
-int
-main(int argc, char *argv[])
-{
-  RecModeT mode_type = RECM_STAND_ALONE;
-  count = 0;
-  RecProcessInit(mode_type);
-
-  ink_event_system_init(EVENT_SYSTEM_MODULE_VERSION);
-  eventProcessor.start(TEST_THREADS);
-
-  alarm_printer *alrm = new alarm_printer(new_ProxyMutex());
-  process_killer *killer = new process_killer(new_ProxyMutex());
-  eventProcessor.schedule_in(killer, HRTIME_SECONDS(60));
-  eventProcessor.schedule_every(alrm, HRTIME_SECONDS(1));
-  this_thread()->execute();
-  return 0;
-}


[40/50] git commit: Turn the vagrant file back into actual ruby

Posted by zw...@apache.org.
Turn the vagrant file back into actual ruby


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

Branch: refs/heads/3.3.x
Commit: c3508099e928cfc64bfb329fb0498cfe9ba4eabc
Parents: 4423f0b
Author: James Peach <jp...@apache.org>
Authored: Thu Apr 4 11:43:08 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:44 2013 -0600

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c3508099/Vagrantfile
----------------------------------------------------------------------
diff --git a/Vagrantfile b/Vagrantfile
index f98f415..babfca6 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -15,13 +15,13 @@
 #  limitations under the License.
 
 $network = {
-  raring64: "192.168.100.1",
-  quantal4: "192.168.100.2",
-  precise64:"192.168.100.3",
-  lucid64:  "192.168.100.4",
-  centos63: "192.168.100.5",
-  freebsd:  "192.168.100.6",
-  omnios:   "192.168.100.7",
+  "raring64"  => "192.168.100.1",
+  "quantal64" => "192.168.100.2",
+  "precise64" => "192.168.100.3",
+  "lucid64"   => "192.168.100.4",
+  "centos63"  => "192.168.100.5",
+  "freebsd"   => "192.168.100.6",
+  "omnios"    => "192.168.100.7",
 }
 
 Vagrant.configure("2") do |config|


[31/50] git commit: Clean up --enable-luajit help string

Posted by zw...@apache.org.
Clean up --enable-luajit help string


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

Branch: refs/heads/3.3.x
Commit: f85dc193fee15d48cf9be2b818c5edfa849adabc
Parents: 8487fe9
Author: James Peach <jp...@apache.org>
Authored: Wed Apr 3 09:53:51 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:44 2013 -0600

----------------------------------------------------------------------
 configure.ac |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f85dc193/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 7a6145a..dbf1679 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1198,13 +1198,12 @@ AX_LIB_READLINE
 #
 # Check for Lua, at least version 5.1, sets LUA_CFLAGS and LUA_LIBS. We support both standard
 # Lua and LuaJIT, preferring LuaJIT if the user did not indicate a preference.
-AC_ARG_ENABLE([luajit], [
-  AS_HELP_STRING([--enable-luajit], [enable LuaJIT support @<:@default=check@:>@])
-], [
-  enable_luajit="${enableval}"
-], [
-  enable_luajit=check
-])
+AC_MSG_CHECKING([whether to enable Linux LuaJIT support])
+AC_ARG_ENABLE([luajit],
+  [AS_HELP_STRING([--enable-luajit], [enable LuaJIT support @<:@default=check@:>@])],
+  [enable_luajit="${enableval}"],
+  [enable_luajit=check]
+)
 
 PKG_CHECK_MODULES([luajit], [luajit], [have_luajit=yes], [have_luajit=no])
 CHECK_LUA([have_lua=yes], [have_lua=no])


[22/50] git commit: TS-1067 Remove a few more unused variables, to get builds going

Posted by zw...@apache.org.
TS-1067 Remove a few more unused variables, to get builds going


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

Branch: refs/heads/3.3.x
Commit: 35344c26de2297f9718892df6ab5aa0eda0faf13
Parents: ba740e8
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Apr 2 15:43:06 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

----------------------------------------------------------------------
 iocore/net/UnixUDPNet.cc |   10 ----------
 1 files changed, 0 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/35344c26/iocore/net/UnixUDPNet.cc
----------------------------------------------------------------------
diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc
index ca428cb..f7b6eca 100644
--- a/iocore/net/UnixUDPNet.cc
+++ b/iocore/net/UnixUDPNet.cc
@@ -640,9 +640,6 @@ UDPQueue::service(UDPNetHandler * nh)
   uint64_t pktSendStartTime;
   UDPPacketInternal *p;
   ink_hrtime pktSendTime;
-  double minPktSpacing;
-  uint32_t pktSize;
-  int64_t pktLen;
 
   p = (UDPPacketInternal *) ink_atomiclist_popall(&atomicQueue);
   if (p) {
@@ -663,12 +660,9 @@ UDPQueue::service(UDPNetHandler * nh)
       ink_assert(p->link.next == NULL);
       // insert into our queue.
       Debug("udp-send", "Adding %p", p);
-      pktLen = p->getPktLength();
       if (p->conn->lastPktStartTime == 0) {
         pktSendStartTime = MAX(now, p->delivery_time);
       } else {
-        pktSize = MAX(INK_ETHERNET_MTU_SIZE, pktLen);
-        minPktSpacing = 0.0;
         pktSendTime = p->delivery_time;
         pktSendStartTime = MAX(MAX(now, pktSendTime), p->delivery_time);
       }
@@ -701,10 +695,6 @@ UDPQueue::SendPackets()
   int32_t bytesThisSlot = INT_MAX, bytesUsed = 0;
   int32_t bytesThisPipe, sentOne;
   int64_t pktLen;
-  ink_hrtime timeDelta = 0;
-
-  if (now > last_service)
-    timeDelta = ink_hrtime_to_msec(now - last_service);
 
   bytesThisSlot = INT_MAX;
 


[27/50] git commit: TS-1067 Remove -UDPNetProcessor::UDPClassifyConnection class

Posted by zw...@apache.org.
TS-1067 Remove -UDPNetProcessor::UDPClassifyConnection class


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

Branch: refs/heads/3.3.x
Commit: 7217e782983fca136c267cc0cea40c246d0bf74f
Parents: c49295c
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Mar 26 09:07:14 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

----------------------------------------------------------------------
 iocore/net/I_UDPNet.h    |    3 ---
 iocore/net/UnixUDPNet.cc |   32 --------------------------------
 2 files changed, 0 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7217e782/iocore/net/I_UDPNet.h
----------------------------------------------------------------------
diff --git a/iocore/net/I_UDPNet.h b/iocore/net/I_UDPNet.h
index 5497fbd..847e2c1 100644
--- a/iocore/net/I_UDPNet.h
+++ b/iocore/net/I_UDPNet.h
@@ -81,9 +81,6 @@ public:
   */
   inkcoreapi Action *UDPBind(Continuation * c, sockaddr const* addr, int send_bufsize = 0, int recv_bufsize = 0);
 
-  // The mess again: the complier won't let me stick UDPConnection here.
-  void UDPClassifyConnection(Continuation * udpConn, IpAddr const& addr);
-
   // Regarding sendto_re, sendmsg_re, recvfrom_re:
   // * You may be called back on 'c' with completion or error status.
   // * 'token' is an opaque which can be used by caller to match up the I/O

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7217e782/iocore/net/UnixUDPNet.cc
----------------------------------------------------------------------
diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc
index 79dd8da..ccf1fde 100644
--- a/iocore/net/UnixUDPNet.cc
+++ b/iocore/net/UnixUDPNet.cc
@@ -575,38 +575,6 @@ HardError:
   return false;
 }
 
-void
-UDPNetProcessor::UDPClassifyConnection(
-  Continuation * udpConn,
-  IpAddr const& destIP
-) {
-  int i;
-  UDPConnectionInternal *p = static_cast<UDPConnectionInternal *>(udpConn);
-
-  if (G_inkPipeInfo.numPipes == 0) {
-    p->pipe_class = 0;
-    return;
-  }
-  p->pipe_class = -1;
-  // find a match: 0 is best-effort
-  for (i = 0; i < G_inkPipeInfo.numPipes + 1; i++)
-    if (G_inkPipeInfo.perPipeInfo[i].destIP == destIP)
-      p->pipe_class = i;
-  // no match; set it to the null class
-  if (p->pipe_class == -1) {
-    IpAddr null; // default constructed -> invalid value.
-    for (i = 0; i < G_inkPipeInfo.numPipes + 1; ++i)
-      if (G_inkPipeInfo.perPipeInfo[i].destIP == null) {
-        p->pipe_class = i;
-        break;
-      }
-  }
-  Debug("udpnet-pipe", "Pipe class = %d", p->pipe_class);
-  ink_debug_assert(p->pipe_class != -1);
-  if (p->pipe_class == -1)
-    p->pipe_class = 0;
-  G_inkPipeInfo.perPipeInfo[p->pipe_class].count++;
-}
 
 Action *
 UDPNetProcessor::UDPBind(Continuation * cont, sockaddr const* addr, int send_bufsize, int recv_bufsize)


[46/50] git commit: TS-1805: fix uninitialized result_type in NodeStatEval()

Posted by zw...@apache.org.
TS-1805: fix uninitialized result_type in NodeStatEval()

BTW, refine the output when call Fatal() in statVarSet().

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/93049169
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/93049169
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/93049169

Branch: refs/heads/3.3.x
Commit: 930491697f135ff4954653c408e01fc56375864c
Parents: a4ad3e8
Author: Yunkai Zhang <qi...@taobao.com>
Authored: Mon Apr 8 13:23:06 2013 +0800
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:44 2013 -0600

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/93049169/mgmt/stats/StatType.cc
----------------------------------------------------------------------
diff --git a/mgmt/stats/StatType.cc b/mgmt/stats/StatType.cc
index efdde92..868a2f4 100644
--- a/mgmt/stats/StatType.cc
+++ b/mgmt/stats/StatType.cc
@@ -252,7 +252,7 @@ bool StatExprToken::statVarSet(RecDataT type, RecData value)
       else if (type == RECD_FLOAT || type == RECD_CONST)
         converted_value.rec_int = (RecInt)value.rec_float;
       else
-        Fatal("invalid value type:%d\n", m_token_type);
+        Fatal("%s, invalid value type:%d\n", m_token_name, type);
       break;
     case RECD_FLOAT:
       if (type == RECD_NULL)
@@ -262,10 +262,10 @@ bool StatExprToken::statVarSet(RecDataT type, RecData value)
       else if (type == RECD_FLOAT || type == RECD_CONST)
         converted_value.rec_float = value.rec_float;
       else
-        Fatal("invalid value type:%d\n", m_token_type);
+        Fatal("%s, invalid value type:%d\n", m_token_name, type);
       break;
     default:
-      Fatal("unsupported token type:%d\n", m_token_type);
+      Fatal("%s, unsupported token type:%d\n", m_token_name, m_token_type);
     }
   } else {
     converted_value = value;
@@ -673,6 +673,8 @@ RecData StatObject::NodeStatEval(RecDataT *result_type, bool cluster)
   RecData tempValue;
   RecDataClear(RECD_NULL, &tempValue);
 
+  *result_type = RECD_NULL;
+
   /* Express checkout lane -- Stat. object with on 1 source variable */
   if (m_postfix->count() == 1) {
     StatExprToken * src = m_postfix->top();


[28/50] git commit: TS-1067 Remove get_allocatedBandwidth()

Posted by zw...@apache.org.
TS-1067 Remove get_allocatedBandwidth()


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

Branch: refs/heads/3.3.x
Commit: c49295c24c218ca3e3f36dfa51eba3aacbc1a318
Parents: dc7c12f
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Mar 26 08:58:34 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

----------------------------------------------------------------------
 iocore/net/I_UDPConnection.h |    2 --
 iocore/net/P_UDPConnection.h |   10 ----------
 2 files changed, 0 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c49295c2/iocore/net/I_UDPConnection.h
----------------------------------------------------------------------
diff --git a/iocore/net/I_UDPConnection.h b/iocore/net/I_UDPConnection.h
index 045f376..91fe2b3 100644
--- a/iocore/net/I_UDPConnection.h
+++ b/iocore/net/I_UDPConnection.h
@@ -55,8 +55,6 @@ public:
 
   void destroy();
   int shouldDestroy();
-  /* Returns the b/w allocated to this UDP connection in Mbps */
-  double get_allocatedBandwidth();
   /**
      <p>
      <b>Callbacks:</b><br>

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c49295c2/iocore/net/P_UDPConnection.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_UDPConnection.h b/iocore/net/P_UDPConnection.h
index 6c1c40d..aacea6d 100644
--- a/iocore/net/P_UDPConnection.h
+++ b/iocore/net/P_UDPConnection.h
@@ -97,9 +97,6 @@ UDPConnectionInternal::UDPConnectionInternal()
 TS_INLINE
 UDPConnectionInternal::~UDPConnectionInternal()
 {
-  // TODO: This is not necessary, and should be removed with the
-  // elimination of UDP bandwidth limiting (used by long since
-  // removed UDP protocols). See bug TS-1067.
   continuation = NULL;
   mutex = NULL;
 }
@@ -127,13 +124,6 @@ UDPConnection::getBinding(struct sockaddr *s)
   return p->binding_valid;
 }
 
-// return the b/w allocated to this UDPConnection in Mbps
-TS_INLINE double
-UDPConnection::get_allocatedBandwidth()
-{
-  return (((UDPConnectionInternal *) this)->flowRateBps * 8.0) / (1024.0 * 1024.0);
-}
-
 TS_INLINE void
 UDPConnection::destroy()
 {


[11/50] git commit: TS-1766: add TCL libs to unit tests

Posted by zw...@apache.org.
TS-1766: add TCL libs to unit tests


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

Branch: refs/heads/3.3.x
Commit: 7f7c388dd8257ee3082b2a920fa0bedaa2c527d9
Parents: 67c7bf4
Author: James Peach <jp...@apache.org>
Authored: Tue Apr 2 11:50:09 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:42 2013 -0600

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7f7c388d/iocore/eventsystem/Makefile.am
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/Makefile.am b/iocore/eventsystem/Makefile.am
index 59a8a24..1eac3d1 100644
--- a/iocore/eventsystem/Makefile.am
+++ b/iocore/eventsystem/Makefile.am
@@ -89,7 +89,8 @@ test_LDADD = \
   $(top_builddir)/mgmt/libmgmt_p.a \
   $(top_builddir)/mgmt/utils/libutils_p.a \
   $(top_builddir)/iocore/eventsystem/libinkevent.a \
-  $(top_builddir)/lib/ts/libtsutil.la
+  $(top_builddir)/lib/ts/libtsutil.la \
+  @LIBTCL@
 
 test_Buffer_SOURCES = ../../proxy/UglyLogStubs.cc test_Buffer.cc
 test_Event_SOURCES = ../../proxy/UglyLogStubs.cc test_Event.cc


[30/50] git commit: TS-1067 Remove the InkPipeInfo wrapper, step one towards removing the global

Posted by zw...@apache.org.
TS-1067 Remove the InkPipeInfo wrapper, step one towards removing the global


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

Branch: refs/heads/3.3.x
Commit: 0c57ad7ab265f19d86c9340f0234c1f49d77a49a
Parents: 0f2d659
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Mar 26 09:56:32 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

----------------------------------------------------------------------
 iocore/net/P_UDPNet.h    |    7 +-----
 iocore/net/UnixUDPNet.cc |   49 +++++++++++++---------------------------
 proxy/Main.cc            |    3 +-
 3 files changed, 18 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0c57ad7a/iocore/net/P_UDPNet.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_UDPNet.h b/iocore/net/P_UDPNet.h
index 239ab34..44917f2 100644
--- a/iocore/net/P_UDPNet.h
+++ b/iocore/net/P_UDPNet.h
@@ -373,11 +373,6 @@ struct InkSinglePipeInfo
   PacketQueue *queue;
 };
 
-struct InkPipeInfo
-{
-  InkSinglePipeInfo *perPipeInfo;
-};
-
-extern InkPipeInfo G_inkPipeInfo;
+extern InkSinglePipeInfo G_inkPipeInfo;
 
 #endif //__P_UDPNET_H_

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0c57ad7a/iocore/net/UnixUDPNet.cc
----------------------------------------------------------------------
diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc
index 029d8cc..e0e3cd7 100644
--- a/iocore/net/UnixUDPNet.cc
+++ b/iocore/net/UnixUDPNet.cc
@@ -59,8 +59,7 @@ int32_t g_udp_numSendRetries;
 // Public functions
 // See header for documentation
 //
-
-InkPipeInfo G_inkPipeInfo;
+InkSinglePipeInfo G_inkPipeInfo;
 
 int G_bwGrapherFd;
 sockaddr_in6 G_bwGrapherLoc;
@@ -656,7 +655,6 @@ UDPQueue::service(UDPNetHandler * nh)
   double minPktSpacing;
   uint32_t pktSize;
   int64_t pktLen;
-  bool addToGuaranteedQ;
 
   (void) nh;
   static ink_hrtime lastPrintTime = ink_get_hrtime_internal();
@@ -690,21 +688,13 @@ UDPQueue::service(UDPNetHandler * nh)
       }
       // insert into our queue.
       Debug("udp-send", "Adding %p", p);
-      addToGuaranteedQ = ((p->conn->pipe_class > 0) && (p->conn->flowRateBps > 10.0));
       pktLen = p->getPktLength();
       if (p->conn->lastPktStartTime == 0) {
         p->pktSendStartTime = MAX(now, p->delivery_time);
       } else {
         pktSize = MAX(INK_ETHERNET_MTU_SIZE, pktLen);
-        if (addToGuaranteedQ) {
-          // NOTE: this is flow rate in Bytes per sec.; convert to milli-sec.
-          minPktSpacing = 1000.0 / (p->conn->flowRateBps / p->conn->avgPktSize);
-
-          pktSendTime = p->conn->lastPktStartTime + ink_hrtime_from_msec((uint32_t) minPktSpacing);
-        } else {
-          minPktSpacing = 0.0;
-          pktSendTime = p->delivery_time;
-        }
+        minPktSpacing = 0.0;
+        pktSendTime = p->delivery_time;
         p->pktSendStartTime = MAX(MAX(now, pktSendTime), p->delivery_time);
         if (p->conn->flowRateBps > 25600.0)
           Debug("udpnet-pkt", "Pkt size = %.1lf now = %" PRId64 ", send = %" PRId64 ", del = %" PRId64 ", Delay delta = %" PRId64 "; delta = %" PRId64 "",
@@ -720,14 +710,7 @@ UDPQueue::service(UDPNetHandler * nh)
       p->conn->nBytesTodo += pktLen;
 
       g_udp_bytesPending += pktLen;
-
-      if (addToGuaranteedQ)
-        G_inkPipeInfo.perPipeInfo[p->conn->pipe_class].queue->addPacket(p, now);
-      else {
-        // stick in the best-effort queue: either it was a best-effort flow or
-        // the thingy wasn't alloc'ed bandwidth
-        G_inkPipeInfo.perPipeInfo[0].queue->addPacket(p, now);
-      }
+      G_inkPipeInfo.queue->addPacket(p, now);
     }
   }
 
@@ -739,7 +722,7 @@ UDPQueue::service(UDPNetHandler * nh)
     lastPrintTime = now;
   }
 
-  G_inkPipeInfo.perPipeInfo[0].queue->advanceNow(now);
+  G_inkPipeInfo.queue->advanceNow(now);
   SendPackets();
 
   timeSpent = ink_hrtime_to_msec(now - last_report);
@@ -752,12 +735,12 @@ UDPQueue::service(UDPNetHandler * nh)
       totalBw = 1.0;
 
     // bw is in Mbps
-    bw = (G_inkPipeInfo.perPipeInfo[0].bytesSent * 8.0 * 1000.0) / (timeSpent * 1024.0 * 1024.0);
+    bw = (G_inkPipeInfo.bytesSent * 8.0 * 1000.0) / (timeSpent * 1024.0 * 1024.0);
 
     // use a weighted estimator of current usage
-    G_inkPipeInfo.perPipeInfo[0].bwUsed = (4.0 * G_inkPipeInfo.perPipeInfo[0].bwUsed / 5.0) + (bw / 5.0);
-    G_inkPipeInfo.perPipeInfo[0].bytesSent = 0;
-    G_inkPipeInfo.perPipeInfo[0].pktsSent = 0;
+    G_inkPipeInfo.bwUsed = (4.0 * G_inkPipeInfo.bwUsed / 5.0) + (bw / 5.0);
+    G_inkPipeInfo.bytesSent = 0;
+    G_inkPipeInfo.pktsSent = 0;
 
     bytesSent = 0;
     last_report = now;
@@ -809,10 +792,10 @@ UDPQueue::SendPackets()
 sendPackets:
   sentOne = false;
   send_threshold_time = now + SLOT_TIME;
-  bytesThisPipe = (int32_t) (bytesThisSlot * G_inkPipeInfo.perPipeInfo[0].wt);
+  bytesThisPipe = (int32_t) (bytesThisSlot * G_inkPipeInfo.wt);
 
-  while ((bytesThisPipe > 0) && (G_inkPipeInfo.perPipeInfo[0].queue->firstPacket(send_threshold_time))) {
-    p = G_inkPipeInfo.perPipeInfo[0].queue->getFirstPacket();
+  while ((bytesThisPipe > 0) && (G_inkPipeInfo.queue->firstPacket(send_threshold_time))) {
+    p = G_inkPipeInfo.queue->getFirstPacket();
     pktLen = p->getPktLength();
     g_udp_bytesPending -= pktLen;
 
@@ -823,7 +806,7 @@ sendPackets:
     if (p->conn->GetSendGenerationNumber() != p->reqGenerationNum)
       goto next_pkt;
 
-    G_inkPipeInfo.perPipeInfo[0].bytesSent += pktLen;
+    G_inkPipeInfo.bytesSent += pktLen;
     SendUDPPacket(p, pktLen);
     bytesUsed += pktLen;
     bytesThisPipe -= pktLen;
@@ -840,8 +823,8 @@ sendPackets:
   if ((bytesThisSlot > 0) && (sentOne)) {
     // redistribute the slack...
     now = ink_get_hrtime_internal();
-    if (G_inkPipeInfo.perPipeInfo[0].queue->firstPacket(now) == NULL) {
-      G_inkPipeInfo.perPipeInfo[0].queue->advanceNow(now);
+    if (G_inkPipeInfo.queue->firstPacket(now) == NULL) {
+      G_inkPipeInfo.queue->advanceNow(now);
     }
     goto sendPackets;
   }
@@ -851,7 +834,7 @@ sendPackets:
     uint64_t nbytes = g_udp_bytesPending;
     ink_hrtime startTime = ink_get_hrtime_internal(), endTime;
 
-    G_inkPipeInfo.perPipeInfo[0].queue->FreeCancelledPackets(g_udp_periodicCleanupSlots);
+    G_inkPipeInfo.queue->FreeCancelledPackets(g_udp_periodicCleanupSlots);
     endTime = ink_get_hrtime_internal();
     Debug("udp-pending-packets", "Did cleanup of %d buckets: %" PRId64 " bytes in %" PRId64 " m.sec",
           g_udp_periodicCleanupSlots, nbytes - g_udp_bytesPending, (int64_t)ink_hrtime_to_msec(endTime - startTime));

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0c57ad7a/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index a22098e..dfde9c8 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -1523,8 +1523,7 @@ main(int argc, char **argv)
 
   // This was the default when we had no bandwidth_mgmt.filename to load
   // but I don't know for sure if we still need this.
-  G_inkPipeInfo.perPipeInfo = NEW(new InkSinglePipeInfo[1]);
-  G_inkPipeInfo.perPipeInfo[0].wt = 1.0;
+  G_inkPipeInfo.wt = 1.0;
 
   init_http_header();
 


[02/50] git commit: TS-1713 just make ts can build on clang

Posted by zw...@apache.org.
TS-1713 just make ts can build on clang


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

Branch: refs/heads/3.3.x
Commit: b4f366a455ad40bad777593b538df54b6854aeb8
Parents: 5c04d4a
Author: weijin <ta...@taobao.com>
Authored: Tue Apr 2 11:47:29 2013 +0800
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:42 2013 -0600

----------------------------------------------------------------------
 iocore/hostdb/I_HostDBProcessor.h |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4f366a4/iocore/hostdb/I_HostDBProcessor.h
----------------------------------------------------------------------
diff --git a/iocore/hostdb/I_HostDBProcessor.h b/iocore/hostdb/I_HostDBProcessor.h
index 1408810..28f1647 100644
--- a/iocore/hostdb/I_HostDBProcessor.h
+++ b/iocore/hostdb/I_HostDBProcessor.h
@@ -355,11 +355,12 @@ struct HostDBRoundRobin
   unsigned short length;
   ink_time_t timed_rr_ctime;
 
-  HostDBInfo info[];
+  HostDBInfo info[1];
 
   static int size(int nn, int srv_len = 0)
   {
-    return INK_ALIGN((int) (sizeof(HostDBRoundRobin) + nn * sizeof(HostDBInfo) + srv_len), 8);
+    ink_assert(nn > 0);
+    return INK_ALIGN((int) (sizeof(HostDBRoundRobin) + (nn-1) * sizeof(HostDBInfo) + srv_len), 8);
   }
 
   /** Find the index of @a addr in member @a info.


[17/50] git commit: TS-1067 Fix the global variable that we read periodic_cleanup into.

Posted by zw...@apache.org.
TS-1067 Fix the global variable that we read periodic_cleanup into.


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

Branch: refs/heads/3.3.x
Commit: 5a025615b8c946b596429ec2a7dae4c6741bcfe9
Parents: 5b5c869
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Mar 26 22:21:07 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

----------------------------------------------------------------------
 iocore/net/UnixUDPNet.cc |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5a025615/iocore/net/UnixUDPNet.cc
----------------------------------------------------------------------
diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc
index fc9c31d..446e349 100644
--- a/iocore/net/UnixUDPNet.cc
+++ b/iocore/net/UnixUDPNet.cc
@@ -69,16 +69,14 @@ initialize_thread_for_udp_net(EThread * thread)
   new((ink_dummy_for_new *) get_UDPPollCont(thread)) PollCont(thread->mutex);
   new((ink_dummy_for_new *) get_UDPNetHandler(thread)) UDPNetHandler;
 
-  // These are hidden variables that control the amount of memory used by UDP
-  // packets.  As usual, defaults are in RecordsConfig.cc
-
   // This variable controls how often we cleanup the cancelled packets.
   // If it is set to 0, then cleanup never occurs.
   REC_ReadConfigInt32(g_udp_periodicFreeCancelledPkts, "proxy.config.udp.free_cancelled_pkts_sec");
+
   // This variable controls how many "slots" of the udp calendar queue we cleanup.
   // If it is set to 0, then cleanup never occurs.  This value makes sense
   // only if the above variable is set.
-  REC_ReadConfigInt32(g_udp_periodicFreeCancelledPkts, "proxy.config.udp.periodic_cleanup");
+  REC_ReadConfigInt32(g_udp_periodicCleanupSlots, "proxy.config.udp.periodic_cleanup");
 
   // UDP sends can fail with errno=EAGAIN.  This variable determines the # of
   // times the UDP thread retries before giving up.  Set to 0 to keep trying forever.


[50/50] git commit: TS-621 Allow caching of empty docs (currently only if a header Content-Length: 0 is in the response). New config option is named proxy.config.http.cache.allow_empty_doc, and is disabled by default.

Posted by zw...@apache.org.
TS-621 Allow caching of empty docs (currently only if a header
Content-Length: 0 is in the response). New config option is named
proxy.config.http.cache.allow_empty_doc, and is disabled by default.

We are aware this doesn't fully fix the problem, but is "good enough"
for now.

Reviews and minor cosmetic cleanup changes: James and Leif.


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

Branch: refs/heads/3.3.x
Commit: b5b1323835428335696db98db1378c41d11f76c1
Parents: b7b6851
Author: weijin <ta...@taobao.com>
Authored: Fri Apr 12 15:23:46 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:45 2013 -0600

----------------------------------------------------------------------
 CHANGES                                |    4 ++++
 iocore/cache/Cache.cc                  |   12 ++++++++++++
 iocore/cache/CacheWrite.cc             |   20 ++++++++++++++++----
 iocore/cache/P_CacheInternal.h         |    3 +++
 iocore/cache/P_CacheVol.h              |    2 +-
 mgmt/RecordsConfig.cc                  |    4 ++++
 proxy/config/records.config.default.in |    3 +++
 7 files changed, 43 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b5b13238/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 3444721..dd1dcb5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,10 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-621] Allow caching of empty docs (currently only if a header
+   Content-Length: 0 is in the response). New config option is named
+   proxy.config.http.cache.allow_empty_doc, and is disabled by default.
+
   *) [TS-1778] Remove vestigal extensions.config support
 
   *) [TS-1806] bogus buffer sizing in CfgContextUtils.cc

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b5b13238/iocore/cache/Cache.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
index d5ba29f..319aca3 100644
--- a/iocore/cache/Cache.cc
+++ b/iocore/cache/Cache.cc
@@ -79,6 +79,9 @@ int cache_config_alt_rewrite_max_size = 4096;
 int cache_config_read_while_writer = 0;
 char cache_system_config_directory[PATH_NAME_MAX + 1];
 int cache_config_mutex_retry_delay = 2;
+#ifdef HTTP_CACHE
+static int enable_cache_empty_http_doc = 0;
+#endif
 
 // Globals
 
@@ -458,6 +461,14 @@ CacheVC::set_http_info(CacheHTTPInfo *ainfo)
     ainfo->object_key_set(earliest_key);
     // don't know the total len yet
   }
+  if (enable_cache_empty_http_doc) {
+    MIMEField *field = ainfo->m_alt->m_response_hdr.field_find(MIME_FIELD_CONTENT_LENGTH, MIME_LEN_CONTENT_LENGTH);
+    if (field && !field->value_get_int64()) 
+      f.allow_empty_doc = 1;
+    else
+      f.allow_empty_doc = 0;
+  } else 
+    f.allow_empty_doc = 0;
   alternate.copy_shallow(ainfo);
   ainfo->clear();
 }
@@ -2819,6 +2830,7 @@ ink_cache_init(ModuleVersion v)
   //  # 1 - MMH hash
   REC_EstablishStaticConfigInt32(url_hash_method, "proxy.config.cache.url_hash_method");
   Debug("cache_init", "proxy.config.cache.url_hash_method = %d", url_hash_method);
+  REC_EstablishStaticConfigInt32(enable_cache_empty_http_doc, "proxy.config.http.cache.allow_empty_doc");
 #endif
 
   REC_EstablishStaticConfigInt32(cache_config_max_disk_errors, "proxy.config.cache.max_disk_errors");

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b5b13238/iocore/cache/CacheWrite.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/CacheWrite.cc b/iocore/cache/CacheWrite.cc
index b93839d..5160eff 100644
--- a/iocore/cache/CacheWrite.cc
+++ b/iocore/cache/CacheWrite.cc
@@ -779,7 +779,11 @@ agg_copy(char *p, CacheVC *vc)
     }
 
     if (vc->f.use_first_key) {
-      if (doc->data_len())
+      if (doc->data_len()
+#ifdef HTTP_CACHE
+                  || vc->f.allow_empty_doc
+#endif
+                  )
         doc->key = vc->earliest_key;
       else // the vector is being written by itself
         prev_CacheKey(&doc->key, &vc->earliest_key);
@@ -1122,7 +1126,11 @@ CacheVC::openWriteCloseDir(int event, Event *e)
   // one, two and three or more fragments. This is because for
   // updates we dont decrement the variable corresponding the old
   // size of the document
-  if ((closed == 1) && (total_len > 0)) {
+  if ((closed == 1) && (total_len > 0
+#ifdef HTTP_CACHE
+                  || f.allow_empty_doc
+#endif
+                  )) {
     DDebug("cache_stats", "Fragment = %d", fragment);
     switch (fragment) {
       case 0: CACHE_INCREMENT_DYN_STAT(cache_single_fragment_document_count_stat); break;
@@ -1270,10 +1278,14 @@ CacheVC::openWriteClose(int event, Event *e)
     if (!io.ok())
       return openWriteCloseDir(event, e);
   }
-  if (closed > 0) {
+  if (closed > 0
+#ifdef HTTP_CACHE
+                  || f.allow_empty_doc
+#endif
+                  ) {
     if (total_len == 0) {
 #ifdef HTTP_CACHE
-      if (f.update) {
+      if (f.update || f.allow_empty_doc) {
         return updateVector(event, e);
       } else {
         // If we've been CLOSE'd but nothing has been written then

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b5b13238/iocore/cache/P_CacheInternal.h
----------------------------------------------------------------------
diff --git a/iocore/cache/P_CacheInternal.h b/iocore/cache/P_CacheInternal.h
index b65cb65..634a1bc 100644
--- a/iocore/cache/P_CacheInternal.h
+++ b/iocore/cache/P_CacheInternal.h
@@ -485,6 +485,9 @@ struct CacheVC: public CacheVConnection
 #ifdef HIT_EVACUATE
       unsigned int hit_evacuate:1;
 #endif
+#ifdef HTTP_CACHE
+      unsigned int allow_empty_doc:1; // used for cache empty http document
+#endif
     } f;
   };
   // BTF optimization used to skip reading stuff in cache partition that doesn't contain any

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b5b13238/iocore/cache/P_CacheVol.h
----------------------------------------------------------------------
diff --git a/iocore/cache/P_CacheVol.h b/iocore/cache/P_CacheVol.h
index dc183a7..4df3f0f 100644
--- a/iocore/cache/P_CacheVol.h
+++ b/iocore/cache/P_CacheVol.h
@@ -423,7 +423,7 @@ Doc::data_len()
 TS_INLINE int
 Doc::single_fragment()
 {
-  return (total_len && (data_len() == total_len));
+  return (data_len() == total_len);
 }
 
 TS_INLINE char *

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b5b13238/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 55b0cb8..3185e2c 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -629,6 +629,10 @@ RecordElement RecordsConfig[] = {
   //        #################
   {RECT_CONFIG, "proxy.config.http.cache.http", RECD_INT, "1", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
   ,
+  // Enabling this setting allows the proxy to cache empty documents. This currently requires
+  // that the response has a Content-Length: header, with a value of "0".
+  {RECT_CONFIG, "proxy.config.http.cache.allow_empty_doc", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_NULL, "[0-1]", RECA_NULL }
+  ,
   {RECT_CONFIG, "proxy.config.http.cache.cluster_cache_local", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
   ,
   {RECT_CONFIG, "proxy.config.http.cache.ignore_client_no_cache", RECD_INT, "1", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b5b13238/proxy/config/records.config.default.in
----------------------------------------------------------------------
diff --git a/proxy/config/records.config.default.in b/proxy/config/records.config.default.in
index 9e396f0..7b39d07 100644
--- a/proxy/config/records.config.default.in
+++ b/proxy/config/records.config.default.in
@@ -218,6 +218,9 @@ CONFIG proxy.config.http.push_method_enabled INT 0
    # cache control #
    #################
 CONFIG proxy.config.http.cache.http INT 1
+   # Enabling this setting allows the proxy to cache empty documents. This currently
+   # requires that the response has a Content-Length: header, with a value of "0".
+CONFIG proxy.config.http.cache.allow_empty_doc INT 0
 CONFIG proxy.config.http.cache.ignore_client_no_cache INT 1
 CONFIG proxy.config.http.cache.ims_on_client_no_cache INT 1
 CONFIG proxy.config.http.cache.ignore_server_no_cache INT 0


[34/50] git commit: Remove obsolete mgr.cnf config file

Posted by zw...@apache.org.
Remove obsolete mgr.cnf config file


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

Branch: refs/heads/3.3.x
Commit: df462b3f3b058c6e4458c026b5aea1947c7144b1
Parents: 9304916
Author: James Peach <jp...@apache.org>
Authored: Mon Apr 8 14:21:23 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:44 2013 -0600

----------------------------------------------------------------------
 mgmt/Main.cc                 |    3 ---
 proxy/config/Makefile.am     |    1 -
 proxy/config/mgr.cnf.default |    9 ---------
 3 files changed, 0 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/df462b3f/mgmt/Main.cc
----------------------------------------------------------------------
diff --git a/mgmt/Main.cc b/mgmt/Main.cc
index 06f3e6a..da80cad 100644
--- a/mgmt/Main.cc
+++ b/mgmt/Main.cc
@@ -1068,9 +1068,6 @@ fileUpdated(char *fname)
   } else if (strcmp(fname, "hosting.config") == 0) {
     lmgmt->signalFileChange("proxy.config.cache.hosting_filename");
 
-  } else if (strcmp(fname, "mgr.cnf") == 0) {
-    mgmt_log(stderr, "[fileUpdated] mgr.cnf file has been modified\n");
-
   } else if (strcmp(fname, "log_hosts.config") == 0) {
     lmgmt->signalFileChange("proxy.config.log.hosts_config_file");
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/df462b3f/proxy/config/Makefile.am
----------------------------------------------------------------------
diff --git a/proxy/config/Makefile.am b/proxy/config/Makefile.am
index 19de021..21f7f72 100644
--- a/proxy/config/Makefile.am
+++ b/proxy/config/Makefile.am
@@ -35,7 +35,6 @@ dist_sysconf_DATA =	\
   ip_allow.config.default \
   log_hosts.config.default \
   logs_xml.config.default \
-  mgr.cnf.default \
   parent.config.default \
   volume.config.default \
   plugin.config.default \

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/df462b3f/proxy/config/mgr.cnf.default
----------------------------------------------------------------------
diff --git a/proxy/config/mgr.cnf.default b/proxy/config/mgr.cnf.default
deleted file mode 100644
index 0f909cd..0000000
--- a/proxy/config/mgr.cnf.default
+++ /dev/null
@@ -1,9 +0,0 @@
-#Entry type: usmUserEntry
-#Format:  usmUserEngineID  (octetString)
-#         usmUserName  (text)
-#         usmUserAuthProtocol  (OID)
-#         usmUserPrivProtocol  (OID)
-#         usmUserStorageType  (nonVolatile, permanent, readOnly)
-#         usmTargetTag  (text)
-usmUserEntry  localSnmpID rootNoAuthTemplate usmNoAuthProtocol \
-    usmNoPrivProtocol readOnly -


[19/50] git commit: TS-1067 Add a new config option, proxy.config.ssl.number.threads, and code

Posted by zw...@apache.org.
TS-1067 Add a new config option, proxy.config.ssl.number.threads, and code


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

Branch: refs/heads/3.3.x
Commit: 3da95a18b65eccb4e40459bf0ad150ee504bbfe2
Parents: 9c2993a
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed Mar 27 12:08:43 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

----------------------------------------------------------------------
 mgmt/RecordsConfig.cc |    2 ++
 proxy/Main.cc         |   23 +++++++++++++----------
 2 files changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3da95a18/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 6926a40..bf9e56a 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -281,6 +281,8 @@ RecordElement RecordsConfig[] = {
   ,
   {RECT_CONFIG, "proxy.config.udp.send_retries", RECD_INT, "0", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,
+  {RECT_CONFIG, "proxy.config.udp.threads", RECD_INT, "0", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
+  ,
 
   //##############################################################################
   //#

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3da95a18/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index addbeeb..05c3bc4 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -97,11 +97,6 @@ extern "C" int plock(int);
 //
 // Global Data
 //
-#define DEFAULT_NUMBER_OF_THREADS         ink_number_of_processors()
-#define DEFAULT_NUMBER_OF_UDP_THREADS     1
-#define DEFAULT_NUMBER_OF_SSL_THREADS     0
-#define DEFAULT_NUM_ACCEPT_THREADS        0
-#define DEFAULT_NUM_TASK_THREADS          0
 #define DEFAULT_HTTP_ACCEPT_PORT_NUMBER   0
 #define DEFAULT_COMMAND_FLAG              0
 #define DEFAULT_LOCK_PROCESS              0
@@ -123,11 +118,13 @@ static void * mgmt_restart_shutdown_callback(void *, char *, int data_len);
 static int version_flag = DEFAULT_VERSION_FLAG;
 
 static int const number_of_processors = ink_number_of_processors();
-static int num_of_net_threads = DEFAULT_NUMBER_OF_THREADS;
+static int num_of_net_threads = number_of_processors;
+static int num_of_udp_threads = 0;
+static int num_accept_threads  = 0;
+static int num_task_threads = 0;
+
 extern int num_of_cluster_threads;
-static int num_of_udp_threads = DEFAULT_NUMBER_OF_UDP_THREADS;
-static int num_accept_threads  = DEFAULT_NUM_ACCEPT_THREADS;
-static int num_task_threads = DEFAULT_NUM_TASK_THREADS;
+
 #if TS_HAS_TESTS
 static int run_test_hook = 0;
 #endif
@@ -1639,7 +1636,13 @@ main(int argc, char **argv)
     HttpProxyPort::loadDefaultIfEmpty();
 
     cacheProcessor.start();
-    udpNet.start(num_of_udp_threads);
+
+    // UDP net-threads are turned off by default.
+    if (!num_of_udp_threads)
+      TS_ReadConfigInteger(num_of_udp_threads, "proxy.config.ssl.number.threads");
+    if (num_of_udp_threads)
+      udpNet.start(num_of_udp_threads);
+
     sslNetProcessor.start(getNumSSLThreads());
 
 #ifndef INK_NO_LOG


[05/50] git commit: TS-1067 Remove the bandwidth_mgmt config file, and corresponding parser code

Posted by zw...@apache.org.
TS-1067 Remove the bandwidth_mgmt config file, and corresponding parser code


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

Branch: refs/heads/3.3.x
Commit: 52e3fd873e7ccb1f6f4c9fc66aa6ce6b3d96c671
Parents: dbe4241
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Mar 26 08:22:02 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:42 2013 -0600

----------------------------------------------------------------------
 mgmt/RecordsConfig.cc |    8 ----
 proxy/Main.cc         |   96 +++-----------------------------------------
 2 files changed, 6 insertions(+), 98 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/52e3fd87/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 9bdad55..6926a40 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -284,14 +284,6 @@ RecordElement RecordsConfig[] = {
 
   //##############################################################################
   //#
-  //# Bandwith Management file
-  //#
-  //##############################################################################
-  {RECT_CONFIG, "proxy.config.bandwidth_mgmt.filename", RECD_STRING, "bandwidth_mgmt_xml.config", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
-  ,
-
-  //##############################################################################
-  //#
   //# Process Manager
   //#
   //##############################################################################

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/52e3fd87/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index 9271770..5337748 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -119,7 +119,6 @@ extern "C" int plock(int);
 #define DEFAULT_REMOTE_MANAGEMENT_FLAG    0
 
 static void * mgmt_restart_shutdown_callback(void *, char *, int data_len);
-static bool xmlBandwidthSchemaRead(XMLNode * node);
 
 static int version_flag = DEFAULT_VERSION_FLAG;
 
@@ -1522,27 +1521,17 @@ main(int argc, char **argv)
   TS_ReadConfigInteger(history_info_enabled, "proxy.config.history_info_enabled");
   TS_ReadConfigInteger(res_track_memory, "proxy.config.res_track_memory");
 
-  {
-    XMLDom schema;
-    //char *configPath = TS_ConfigReadString("proxy.config.config_dir");
-    char *filename = TS_ConfigReadString("proxy.config.bandwidth_mgmt.filename");
-    char bwFilename[PATH_NAME_MAX];
-
-    snprintf(bwFilename, sizeof(bwFilename), "%s/%s", system_config_directory, filename);
-    ats_free(filename);
-
-    Debug("bw-mgmt", "Looking to read: %s for bw-mgmt", bwFilename);
-    schema.LoadFile(bwFilename);
-    xmlBandwidthSchemaRead(&schema);
-  }
-
+  // This was the default when we had no bandwidth_mgmt.filename to load
+  // but I don't know for sure if we still need this.
+  G_inkPipeInfo.perPipeInfo = NEW(new InkSinglePipeInfo[1]);
+  G_inkPipeInfo.perPipeInfo[0].wt = 1.0;
+  G_inkPipeInfo.numPipes = 0;
+  G_inkPipeInfo.interfaceMbps = 0.0;
 
   init_http_header();
 
   // Sanity checks
-  //  if (!lock_process) check_for_root_uid();
   check_fd_limit();
-
   command_flag = command_flag || *command_string;
 
   // Set up store
@@ -1789,79 +1778,6 @@ main(int argc, char **argv)
 }
 
 
-static bool
-xmlBandwidthSchemaRead(XMLNode * node)
-{
-  XMLNode *child, *c2;
-  int i, j, k;
-  unsigned char *p;
-  char *ip;
-
-  // file doesn't exist
-  if (node->getNodeName() == NULL) {
-    // alloc 1-elt array to store stuff for best-effort traffic
-    G_inkPipeInfo.perPipeInfo = NEW(new InkSinglePipeInfo[1]);
-    G_inkPipeInfo.perPipeInfo[0].wt = 1.0;
-    G_inkPipeInfo.numPipes = 0;
-    G_inkPipeInfo.interfaceMbps = 0.0;
-    return true;
-  }
-
-  if (strcmp(node->getNodeName(), "interface") != 0) {
-    Debug("bw-mgmt", "Root node should be an interface tag!\n");
-    return false;
-  }
-  // First entry G_inkPipeInfo.perPipeInfo[0] is the one for "best-effort" traffic.
-  G_inkPipeInfo.perPipeInfo = NEW(new InkSinglePipeInfo[node->getChildCount() + 1]);
-  G_inkPipeInfo.perPipeInfo[0].wt = 1.0;
-  G_inkPipeInfo.numPipes = 0;
-  G_inkPipeInfo.reliabilityMbps = 1.0;
-  G_inkPipeInfo.interfaceMbps = 30.0;
-  for (i = 0; i < node->getChildCount(); i++) {
-    if ((child = node->getChildNode(i))) {
-      if (strcmp(child->getNodeName(), "pipe") == 0) {
-        G_inkPipeInfo.numPipes++;
-        for (k = 0; k < child->getChildCount(); k++) {
-          c2 = child->getChildNode(k);
-          for (int l = 0; l < c2->m_nACount; l++) {
-            if (strcmp(c2->m_pAList[l].pAName, "weight") == 0) {
-              G_inkPipeInfo.perPipeInfo[G_inkPipeInfo.numPipes].wt = atof(c2->m_pAList[l].pAValue);
-              G_inkPipeInfo.perPipeInfo[0].wt -= G_inkPipeInfo.perPipeInfo[G_inkPipeInfo.numPipes].wt;
-            } else if (strcmp(c2->m_pAList[l].pAName, "dest_ip") == 0) {
-              p = (unsigned char *) &(G_inkPipeInfo.perPipeInfo[G_inkPipeInfo.numPipes].destIP);
-              ip = c2->m_pAList[l].pAValue;
-              for (j = 0; j < 4; j++) {
-                p[j] = atoi(ip);
-                while (ip && *ip && (*ip != '.'))
-                  ip++;
-                ip++;
-              }
-            }
-          }
-        }
-      } else if (strcmp(child->getNodeName(), "bandwidth") == 0) {
-        for (j = 0; j < child->m_nACount; j++) {
-          if (strcmp(child->m_pAList[j].pAName, "limit_mbps") == 0) {
-            G_inkPipeInfo.interfaceMbps = atof(child->m_pAList[j].pAValue);
-          } else if (strcmp(child->m_pAList[j].pAName, "reliability_mbps") == 0) {
-            G_inkPipeInfo.reliabilityMbps = atof(child->m_pAList[j].pAValue);
-          }
-        }
-      }
-    }
-  }
-  Debug("bw-mgmt", "Read in: limit_mbps = %lf\n", G_inkPipeInfo.interfaceMbps);
-  for (i = 0; i < G_inkPipeInfo.numPipes + 1; i++) {
-    G_inkPipeInfo.perPipeInfo[i].bwLimit =
-      (int64_t) (G_inkPipeInfo.perPipeInfo[i].wt * G_inkPipeInfo.interfaceMbps * 1024.0 * 1024.0);
-    p = (unsigned char *) &(G_inkPipeInfo.perPipeInfo[i].destIP);
-    Debug("bw-mgmt", "Pipe [%d]: wt = %lf, dest ip = %d.%d.%d.%d\n",
-          i, G_inkPipeInfo.perPipeInfo[i].wt, p[0], p[1], p[2], p[3]);
-  }
-  return true;
-}
-
-
 #if TS_HAS_TESTS
 //////////////////////////////
 // Unit Regresion Test Hook //


[33/50] git commit: TS-1760: Option to use Linux native AIO

Posted by zw...@apache.org.
TS-1760: Option to use Linux native AIO

to enable the Linux Native AIO, be sure to check Linux kernel AIO
supporting and use '--use_linux_native_aio' configure directive.

in the Linux Native AIO, all the IO is managed by system, so
proxy.config.cache.threads_per_disk have no meaning anymore.


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

Branch: refs/heads/3.3.x
Commit: ba091981cc693b091aa22ab5147d48e2335d0afc
Parents: fa3ae7e
Author: weijin <ta...@taobao.com>
Authored: Wed Apr 3 14:59:48 2013 +0800
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:44 2013 -0600

----------------------------------------------------------------------
 configure.ac             |   19 +++++
 iocore/aio/AIO.cc        |  146 +++++++++++++++++++++++++++++++++++++++--
 iocore/aio/I_AIO.h       |  129 ++++++++++++++++++++++++++++++++++++-
 iocore/aio/P_AIO.h       |   59 +++++++++++++++--
 iocore/cache/Cache.cc    |   74 ++++++++++++++++++++-
 iocore/cache/CacheVol.cc |    2 +-
 lib/ts/ink_aiocb.h       |    4 +-
 lib/ts/ink_config.h.in   |    1 +
 proxy/InkAPI.cc          |    4 +
 9 files changed, 421 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ba091981/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 7b30f26..72e60b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -398,6 +398,25 @@ TS_ARG_ENABLE_VAR([use], [reclaimable_freelist])
 AC_SUBST(use_reclaimable_freelist)
 
 #
+# If the OS is linux, we can use '--use_linux_native_aio' option to
+# replace the aio thread mode. Effective only on the linux system.
+#
+
+if test "x${host_os_def}" = "xlinux"; then
+  AC_MSG_CHECKING([whether to use native aio or not])
+  AC_ARG_ENABLE([linux_native_aio],
+    [AS_HELP_STRING([--enable-linux-native-aio],
+      [turn on linux native aio, only effective on linux system])],
+    [],
+    [enable_linux_native_aio="yes"])
+  AC_MSG_RESULT([$enable_linux_native_aio])
+else
+  enable_linux_native_aio="no"
+fi
+TS_ARG_ENABLE_VAR([use], [linux_native_aio])
+AC_SUBST(use_linux_native_aio)
+
+
 # Configure how many stats to allocate for plugins. Default is 512.
 #
 AC_ARG_WITH([max-api-stats],

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ba091981/iocore/aio/AIO.cc
----------------------------------------------------------------------
diff --git a/iocore/aio/AIO.cc b/iocore/aio/AIO.cc
index 3086f0c..40bf1b1 100644
--- a/iocore/aio/AIO.cc
+++ b/iocore/aio/AIO.cc
@@ -27,6 +27,10 @@
 
 #include "P_AIO.h"
 
+#if AIO_MODE == AIO_MODE_NATIVE
+#define AIO_PERIOD                                -HRTIME_MSECONDS(4)
+#else
+
 #define MAX_DISKS_POSSIBLE 100
 
 // globals
@@ -36,24 +40,24 @@ int ts_config_with_inkdiskio = 0;
 AIO_Reqs *aio_reqs[MAX_DISKS_POSSIBLE];
 /* number of unique file descriptors in the aio_reqs array */
 volatile int num_filedes = 1;
-RecRawStatBlock *aio_rsb = NULL;
+
 // acquire this mutex before inserting a new entry in the aio_reqs array.
 // Don't need to acquire this for searching the array
 static ink_mutex insert_mutex;
-Continuation *aio_err_callbck = 0;
+
 RecInt cache_config_threads_per_disk = 12;
 RecInt api_config_threads_per_disk = 12;
 int thread_is_created = 0;
+#endif // AIO_MODE == AIO_MODE_NATIVE
 
-
+RecRawStatBlock *aio_rsb = NULL;
+Continuation *aio_err_callbck = 0;
 // AIO Stats
 uint64_t aio_num_read = 0;
 uint64_t aio_bytes_read = 0;
 uint64_t aio_num_write = 0;
 uint64_t aio_bytes_written = 0;
 
-static void aio_move(AIO_Reqs *req);
-
 /*
  * Stats
  */
@@ -156,10 +160,12 @@ ink_aio_init(ModuleVersion v)
   RecRegisterRawStat(aio_rsb, RECT_PROCESS,
                      "proxy.process.cache.KB_write_per_sec",
                      RECD_FLOAT, RECP_NULL, (int) AIO_STAT_KB_WRITE_PER_SEC, aio_stats_cb);
+#if AIO_MODE != AIO_MODE_NATIVE
   memset(&aio_reqs, 0, MAX_DISKS_POSSIBLE * sizeof(AIO_Reqs *));
   ink_mutex_init(&insert_mutex, NULL);
 
   REC_ReadConfigInteger(cache_config_threads_per_disk, "proxy.config.cache.threads_per_disk");
+#endif
 }
 
 int
@@ -172,6 +178,7 @@ ink_aio_start()
   return 0;
 }
 
+#if  AIO_MODE != AIO_MODE_NATIVE
 
 static void *aio_thread_main(void *arg);
 
@@ -534,3 +541,132 @@ aio_thread_main(void *arg)
   }
   return 0;
 }
+#else
+int
+DiskHandler::startAIOEvent(int event, Event *e) {
+  SET_HANDLER(&DiskHandler::mainAIOEvent);
+  e->schedule_every(AIO_PERIOD);
+  trigger_event = e;
+  return EVENT_CONT;
+}
+
+int
+DiskHandler::mainAIOEvent(int event, Event *e) {
+  AIOCallback *op = NULL;
+Lagain:
+  int ret = io_getevents(ctx, 0, MAX_AIO_EVENTS, events, NULL);
+  //printf("%d\n", ret);
+  for (int i = 0; i < ret; i++) {
+    op = (AIOCallback *) events[i].data;
+    op->aio_result = events[i].res;
+    ink_assert(op->action.continuation);
+    complete_list.enqueue(op);
+    //op->handleEvent(event, e);
+  }
+  if (ret == MAX_AIO_EVENTS)
+    goto Lagain;
+  if (ret < 0)
+    perror("io_getevents");
+
+  ink_aiocb_t *cbs[MAX_AIO_EVENTS];
+  int num = 0;
+  for (; num < MAX_AIO_EVENTS && ((op = ready_list.dequeue()) != NULL); ++num) {
+    cbs[num] = &op->aiocb;
+    ink_debug_assert(op->action.continuation);
+  }
+  if (num > 0) {
+    int ret;
+    do {
+      ret = io_submit(ctx, num, cbs);
+    } while (ret < 0 && errno == EAGAIN);
+
+    if (ret != num) {
+      if (ret < 0)
+        perror("io_submit error");
+      else {
+        fprintf(stderr, "could not sumbit IOs");
+        ink_debug_assert(0);
+      }
+    }
+  }
+
+  while ((op = complete_list.dequeue()) != NULL) {
+    op->handleEvent(event, e);
+  }
+  return EVENT_CONT;
+}
+
+int
+ink_aio_read(AIOCallback *op, int fromAPI) {
+  op->aiocb.aio_reqprio = AIO_DEFAULT_PRIORITY;
+  op->aiocb.aio_lio_opcode = IOCB_CMD_PREAD;
+  op->aiocb.aio_data = op;
+  this_ethread()->diskHandler->ready_list.enqueue(op);
+
+  return 1;
+}
+
+int
+ink_aio_write(AIOCallback *op, int fromAPI) {
+  op->aiocb.aio_reqprio = AIO_DEFAULT_PRIORITY;
+  op->aiocb.aio_lio_opcode = IOCB_CMD_PWRITE;
+  op->aiocb.aio_data = op;
+  this_ethread()->diskHandler->ready_list.enqueue(op);
+
+  return 1;
+}
+
+int
+ink_aio_readv(AIOCallback *op, int fromAPI) {
+  DiskHandler *dh = this_ethread()->diskHandler;
+  AIOCallback *io = op;
+  int sz = 0;
+
+  while (io) {
+    io->aiocb.aio_reqprio = AIO_DEFAULT_PRIORITY;
+    io->aiocb.aio_lio_opcode = IOCB_CMD_PREAD;
+    io->aiocb.aio_data = io;
+    dh->ready_list.enqueue(io);
+    ++sz;
+    io = io->then;
+  }
+
+  if (sz > 1) {
+    ink_debug_assert(op->action.continuation);
+    AIOVec *vec = new AIOVec(sz, op->action.continuation);
+    vec->action = op->action.continuation;
+    while (--sz >= 0) {
+      op->action = vec;
+      op = op->then;
+    }
+  }
+  return 1;
+}
+
+int
+ink_aio_writev(AIOCallback *op, int fromAPI) {
+  DiskHandler *dh = this_ethread()->diskHandler;
+  AIOCallback *io = op;
+  int sz = 0;
+
+  while (io) {
+    io->aiocb.aio_reqprio = AIO_DEFAULT_PRIORITY;
+    io->aiocb.aio_lio_opcode = IOCB_CMD_PWRITE;
+    io->aiocb.aio_data = io;
+    dh->ready_list.enqueue(io);
+    ++sz;
+    io = io->then;
+  }
+
+  if (sz > 1) {
+    ink_debug_assert(op->action.continuation);
+    AIOVec *vec = new AIOVec(sz, op->action.continuation);
+    vec->action = op->action.continuation;
+    while (--sz >= 0) {
+      op->action = vec;
+      op = op->then;
+    }
+  }
+  return 1;
+}
+#endif // AIO_MODE != AIO_MODE_NATIVE

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ba091981/iocore/aio/I_AIO.h
----------------------------------------------------------------------
diff --git a/iocore/aio/I_AIO.h b/iocore/aio/I_AIO.h
index 8d4cd2b..ccdc078 100644
--- a/iocore/aio/I_AIO.h
+++ b/iocore/aio/I_AIO.h
@@ -46,8 +46,114 @@
 #define AIO_MODE_AIO             0
 #define AIO_MODE_SYNC            1
 #define AIO_MODE_THREAD          2
+#define AIO_MODE_NATIVE          3
+#if use_linux_native_aio
+#define AIO_MODE                 AIO_MODE_NATIVE
+#else
 #define AIO_MODE                 AIO_MODE_THREAD
+#endif
+
+#if AIO_MODE == AIO_MODE_NATIVE
+
+#include <sys/syscall.h>  /* for __NR_* definitions */
+#include <linux/aio_abi.h>  /* for AIO types and constants */
+#define MAX_AIO_EVENTS 1024
+
+#if defined(__LITTLE_ENDIAN)
+#if (SIZEOF_VOID_POINTER == 4)
+#define PADDEDPtr(x, y) x; unsigned y
+#define PADDEDul(x, y) unsigned long x; unsigned y
+#elif (SIZEOF_VOID_POINTER == 8)
+#define PADDEDPtr(x, y) x
+#define PADDEDul(x, y) unsigned long x
+#endif
+#elif defined(__BIG_ENDIAN)
+#if (SIZEOF_VOID_POINTER == 4)
+#define PADDEDPtr(x, y) unsigned y; x
+#define PADDEDul(x, y) unsigned y; unsigned long y
+#elif (SIZEOF_VOID_POINTER == 8)
+#define PADDEDPtr(x, y) x
+#define PADDEDul(x, y) unsigned long x
+#endif
+#else
+#error edit for your odd byteorder.
+#endif
+
+typedef struct ink_iocb {
+  /* these are internal to the kernel/libc. */
+  PADDEDPtr(void *aio_data, _pad1); /* data to be returned in event's data */
+  unsigned PADDED(aio_key, aio_reserved1);
+        /* the kernel sets aio_key to the req # */
+
+  /* common fields */
+  short aio_lio_opcode; /* see IOCB_CMD_ above */
+  short aio_reqprio;
+  int aio_fildes;
+
+  PADDEDPtr(void *aio_buf, _pad2);
+  PADDEDul(aio_nbytes, _pad3);
+  int64_t aio_offset;
+
+  /* extra parameters */
+  uint64_t aio_reserved2;  /* TODO: use this for a (struct sigevent *) */
+
+  /* flags for the "struct iocb" */
+  int aio_flags;
+
+  /*
+   * if the IOCB_FLAG_RESFD flag of "aio_flags" is set, this is an
+   * eventfd to signal AIO readiness to
+   */
+  int aio_resfd;
+
+} ink_aiocb_t;
+
+typedef struct ink_io_event {
+  PADDEDPtr(void *data, _pad1);   /* the data field from the iocb */
+  PADDEDPtr(ink_aiocb_t *obj, _pad2);    /* what iocb this event came from */
+  PADDEDul(res, _pad3);    /* result code for this event */
+  PADDEDul(res2, _pad4);   /* secondary result */
+} ink_io_event_t;
+
+TS_INLINE int io_setup(unsigned nr, aio_context_t *ctxp)
+{
+  return syscall(__NR_io_setup, nr, ctxp);
+}
+
+TS_INLINE int io_destroy(aio_context_t ctx)
+{
+  return syscall(__NR_io_destroy, ctx);
+}
+
+TS_INLINE int io_submit(aio_context_t ctx, long nr,  ink_aiocb_t **iocbpp)
+{
+  return syscall(__NR_io_submit, ctx, nr, iocbpp);
+}
+
+TS_INLINE int io_getevents(aio_context_t ctx, long min_nr, long max_nr,
+    ink_io_event_t *events, struct timespec *timeout)
+{
+  return syscall(__NR_io_getevents, ctx, min_nr, max_nr, events, timeout);
+}
+
+struct AIOVec: public Continuation
+{
+  Action action;
+  int size;
+  int completed;
+
+  AIOVec(int sz, Continuation *c): Continuation(new_ProxyMutex()), size(sz), completed(0)
+  {
+    action = c;
+    SET_HANDLER(&AIOVec::mainEvent);
+  }
 
+  int mainEvent(int event, Event *e);
+};
+#else
+typedef ink_aiocb ink_aiocb_t;
+bool ink_aio_thread_num_set(int thread_num);
+#endif
 // AIOCallback::thread special values
 #define AIO_CALLBACK_THREAD_ANY ((EThread*)0) // any regular event thread
 #define AIO_CALLBACK_THREAD_AIO ((EThread*)-1)
@@ -71,12 +177,33 @@ struct AIOCallback: public Continuation
   }
 };
 
+#if AIO_MODE == AIO_MODE_NATIVE
+struct DiskHandler: public Continuation
+{
+  Event *trigger_event;
+  aio_context_t ctx;
+  ink_io_event_t events[MAX_AIO_EVENTS];
+  Que(AIOCallback, link) ready_list;
+  Que(AIOCallback, link) complete_list;
+  int startAIOEvent(int event, Event *e);
+  int mainAIOEvent(int event, Event *e);
+  DiskHandler() {
+    SET_HANDLER(&DiskHandler::startAIOEvent);
+    memset(&ctx, 0, sizeof(aio_context_t));
+    int ret = io_setup(MAX_AIO_EVENTS, &ctx);
+    if (ret < 0) {
+      perror("io_setup error");
+    }
+  }
+};
+#endif
 void ink_aio_init(ModuleVersion version);
 int ink_aio_start();
 void ink_aio_set_callback(Continuation * error_callback);
 
 int ink_aio_read(AIOCallback *op, int fromAPI = 0);   // fromAPI is a boolean to indicate if this is from a API call such as upload proxy feature
 int ink_aio_write(AIOCallback *op, int fromAPI = 0);
-bool ink_aio_thread_num_set(int thread_num);
+int ink_aio_readv(AIOCallback *op, int fromAPI = 0);   // fromAPI is a boolean to indicate if this is from a API call such as upload proxy feature
+int ink_aio_writev(AIOCallback *op, int fromAPI = 0);
 AIOCallback *new_AIOCallback(void);
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ba091981/iocore/aio/P_AIO.h
----------------------------------------------------------------------
diff --git a/iocore/aio/P_AIO.h b/iocore/aio/P_AIO.h
index 2d686e3..9e3321c 100644
--- a/iocore/aio/P_AIO.h
+++ b/iocore/aio/P_AIO.h
@@ -41,6 +41,58 @@
 #define AIO_MODULE_VERSION        makeModuleVersion(AIO_MODULE_MAJOR_VERSION,\
 						    AIO_MODULE_MINOR_VERSION,\
 						    PRIVATE_MODULE_HEADER)
+
+TS_INLINE int
+AIOCallback::ok()
+{
+  return (off_t) aiocb.aio_nbytes == (off_t) aio_result;
+}
+
+#if AIO_MODE == AIO_MODE_NATIVE
+
+extern Continuation *aio_err_callbck;
+
+struct AIOCallbackInternal: public AIOCallback
+{
+  int io_complete(int event, void *data);
+  AIOCallbackInternal()
+  {
+    memset ((char *) &(this->aiocb), 0, sizeof(this->aiocb));
+    SET_HANDLER(&AIOCallbackInternal::io_complete);
+  }
+};
+
+TS_INLINE int
+AIOCallbackInternal::io_complete(int event, void *data)
+{
+  (void) event;
+  (void) data;
+
+  if (!ok() && aio_err_callbck)
+    eventProcessor.schedule_imm(aio_err_callbck, ET_CALL, AIO_EVENT_DONE);
+  mutex = action.mutex;
+  MUTEX_LOCK(lock, mutex, this_ethread());
+  if (!action.cancelled)
+    action.continuation->handleEvent(AIO_EVENT_DONE, this);
+  return EVENT_DONE;
+}
+
+TS_INLINE int
+AIOVec::mainEvent(int event, Event *e) {
+  ++completed;
+  if (completed < size)
+    return EVENT_CONT;
+  else if (completed == size) {
+    MUTEX_LOCK(lock, action.mutex, this_ethread());
+    if (!action.cancelled)
+      action.continuation->handleEvent(AIO_EVENT_DONE, this);
+    delete this;
+    return EVENT_DONE;
+  }
+  ink_assert(!"AIOVec mainEvent err");
+  return EVENT_ERROR;
+}
+#else
 struct AIO_Reqs;
 
 struct AIOCallbackInternal: public AIOCallback
@@ -61,12 +113,6 @@ struct AIOCallbackInternal: public AIOCallback
 };
 
 TS_INLINE int
-AIOCallback::ok()
-{
-  return (off_t) aiocb.aio_nbytes == (off_t) aio_result;
-}
-
-TS_INLINE int
 AIOCallbackInternal::io_complete(int event, void *data)
 {
   (void) event;
@@ -92,6 +138,7 @@ struct AIO_Reqs
   volatile int requests_queued;
 };
 
+#endif // AIO_MODE == AIO_MODE_NATIVE
 #ifdef AIO_STATS
 class AIOTestData:public Continuation
 {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ba091981/iocore/cache/Cache.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
index 1232a11..d5ba29f 100644
--- a/iocore/cache/Cache.cc
+++ b/iocore/cache/Cache.cc
@@ -146,6 +146,51 @@ struct VolInitInfo
   }
 };
 
+#if AIO_MODE == AIO_MODE_NATIVE
+struct VolInit : public Continuation
+{
+  Vol *vol;
+  char *path;
+  off_t blocks;
+  int64_t offset;
+  bool vol_clear;
+
+  int mainEvent(int event, Event *e) {
+    vol->init(path, blocks, offset, vol_clear);
+    mutex.clear();
+    delete this;
+    return EVENT_DONE;
+  }
+
+  VolInit(Vol *v, char *p, off_t b, int64_t o, bool c) : Continuation(v->mutex),
+    vol(v), path(p), blocks(b), offset(o), vol_clear(c) {
+    SET_HANDLER(&VolInit::mainEvent);
+  }
+};
+
+struct DiskInit : public Continuation
+{
+  CacheDisk *disk;
+  char *s;
+  off_t blocks;
+  off_t askip;
+  int ahw_sector_size;
+  int fildes;
+  bool clear;
+
+  int mainEvent(int event, Event *e) {
+    disk->open(s, blocks, askip, ahw_sector_size, fildes, clear);
+    mutex.clear();
+    delete this;
+    return EVENT_DONE;
+  }
+
+  DiskInit(CacheDisk *d, char *str, off_t b, off_t skip, int sector, int f, bool c) : Continuation(d->mutex),
+      disk(d), s(str), blocks(b), askip(skip), ahw_sector_size(sector), fildes(f), clear(c) {
+    SET_HANDLER(&DiskInit::mainEvent);
+  }
+};
+#endif
 void cplist_init();
 static void cplist_update();
 int cplist_reconfigure();
@@ -530,6 +575,16 @@ CacheProcessor::start_internal(int flags)
   verify_cache_api();
 #endif
 
+#if AIO_MODE == AIO_MODE_NATIVE
+  int etype = ET_NET;
+  int n_netthreads = eventProcessor.n_threads_for_type[etype];
+  EThread **netthreads = eventProcessor.eventthread[etype];
+  for (int i = 0; i < n_netthreads; ++i) {
+    netthreads[i]->diskHandler = new DiskHandler();
+    netthreads[i]->schedule_imm(netthreads[i]->diskHandler);
+  }
+#endif
+
   start_internal_flags = flags;
   clear = !!(flags & PROCESSOR_RECONFIGURE) || auto_clear_flag;
   fix = !!(flags & PROCESSOR_FIX);
@@ -593,7 +648,11 @@ CacheProcessor::start_internal(int flags)
         }
         off_t skip = ROUND_TO_STORE_BLOCK((sd->offset < START_POS ? START_POS + sd->alignment : sd->offset));
         blocks = blocks - ROUND_TO_STORE_BLOCK(sd->offset + skip);
+#if AIO_MODE == AIO_MODE_NATIVE
+        eventProcessor.schedule_imm(NEW(new DiskInit(gdisks[gndisks], path, blocks, skip, sector_size, fd, clear)));
+#else
         gdisks[gndisks]->open(path, blocks, skip, sector_size, fd, clear);
+#endif
         gndisks++;
       }
     } else {
@@ -1109,8 +1168,11 @@ Vol::init(char *s, off_t blocks, off_t dir_skip, bool clear)
     aio->thread = AIO_CALLBACK_THREAD_ANY;
     aio->then = (i < 3) ? &(init_info->vol_aio[i + 1]) : 0;
   }
-
+#if AIO_MODE == AIO_MODE_NATIVE
+  ink_assert(ink_aio_readv(init_info->vol_aio));
+#else
   ink_assert(ink_aio_read(init_info->vol_aio));
+#endif
   return 0;
 }
 
@@ -1440,7 +1502,11 @@ Ldone:{
     init_info->vol_aio[2].aiocb.aio_offset = ss + dirlen - footerlen;
 
     SET_HANDLER(&Vol::handle_recover_write_dir);
+#if AIO_MODE == AIO_MODE_NATIVE
+    ink_assert(ink_aio_writev(init_info->vol_aio));
+#else
     ink_assert(ink_aio_write(init_info->vol_aio));
+#endif
     return EVENT_CONT;
   }
 
@@ -1812,7 +1878,11 @@ Cache::open(bool clear, bool fix) {
             blocks = q->b->len;
 
             bool vol_clear = clear || d->cleared || q->new_block;
+#if AIO_MODE == AIO_MODE_NATIVE
+            eventProcessor.schedule_imm(NEW(new VolInit(cp->vols[vol_no], d->path, blocks, q->b->offset, vol_clear)));
+#else
             cp->vols[vol_no]->init(d->path, blocks, q->b->offset, vol_clear);
+#endif
             vol_no++;
             cache_size += blocks;
           }
@@ -1926,7 +1996,7 @@ CacheVC::handleReadDone(int event, Event *e) {
         if (checksum != doc->checksum) {
           Note("cache: checksum error for [%" PRIu64 " %" PRIu64 "] len %d, hlen %d, disk %s, offset %" PRIu64 " size %zu",
                doc->first_key.b[0], doc->first_key.b[1],
-               doc->len, doc->hlen, vol->path, io.aiocb.aio_offset, io.aiocb.aio_nbytes);
+               doc->len, doc->hlen, vol->path, io.aiocb.aio_offset, (size_t)io.aiocb.aio_nbytes);
           doc->magic = DOC_CORRUPT;
           okay = 0;
         }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ba091981/iocore/cache/CacheVol.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/CacheVol.cc b/iocore/cache/CacheVol.cc
index bf4fad9..ccd2009 100644
--- a/iocore/cache/CacheVol.cc
+++ b/iocore/cache/CacheVol.cc
@@ -365,7 +365,7 @@ Lread:
   offset = 0;
   ink_assert(ink_aio_read(&io) >= 0);
   Debug("cache_scan_truss", "read %p:scanObject %" PRId64 " %zu", this,
-        (int64_t)io.aiocb.aio_offset, io.aiocb.aio_nbytes);
+        (int64_t)io.aiocb.aio_offset, (size_t)io.aiocb.aio_nbytes);
   return EVENT_CONT;
 
 Ldone:

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ba091981/lib/ts/ink_aiocb.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_aiocb.h b/lib/ts/ink_aiocb.h
index 1cf9d38..543243b 100644
--- a/lib/ts/ink_aiocb.h
+++ b/lib/ts/ink_aiocb.h
@@ -39,7 +39,7 @@
 #define	LIO_READ	0x1
 #define	LIO_WRITE	0x2
 
-typedef struct ink_aiocb
+struct ink_aiocb
 {
   int aio_fildes;
 #if	defined(__STDC__)
@@ -58,6 +58,6 @@ typedef struct ink_aiocb
   //    aio_result_t    aio_resultp;    /* results */
   int aio_state;                /* state flag for List I/O */
   int aio__pad[1];              /* extension padding */
-} ink_aiocb_t;
+};
 
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ba091981/lib/ts/ink_config.h.in
----------------------------------------------------------------------
diff --git a/lib/ts/ink_config.h.in b/lib/ts/ink_config.h.in
index 6b0525c..93e393c 100644
--- a/lib/ts/ink_config.h.in
+++ b/lib/ts/ink_config.h.in
@@ -122,6 +122,7 @@
 #define TS_USE_RECLAIMABLE_FREELIST    @use_reclaimable_freelist@
 #define TS_USE_TLS_NPN                 @use_tls_npn@
 #define TS_USE_TLS_SNI                 @use_tls_sni@
+#define TS_USE_LINUX_NATIVE_AIO        @use_linux_native_aio@
 
 /* OS API definitions */
 #define GETHOSTBYNAME_R_HOSTENT_DATA   @gethostbyname_r_hostent_data@

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ba091981/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 661a2d0..fd8258e 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -7324,10 +7324,14 @@ TSAIOWrite(int fd, off_t offset, char* buf, const size_t bufSize, TSCont contp)
 TSReturnCode
 TSAIOThreadNumSet(int thread_num)
 {
+#if AIO_MODE == AIO_MODE_NATIVE
+  return TS_SUCCESS;
+#else
   if (ink_aio_thread_num_set(thread_num))
     return TS_SUCCESS;
 
   return TS_ERROR;
+#endif
 }
 
 void


[23/50] git commit: TS-1783 Eliminate the wpad.dat configuration option (it's unused).

Posted by zw...@apache.org.
TS-1783 Eliminate the wpad.dat configuration option (it's unused).


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

Branch: refs/heads/3.3.x
Commit: 900cc391b9bc49aca8365a233b32c8b9c5f8e5d0
Parents: cf1550d
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Apr 2 17:05:36 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/900cc391/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index b8321b1..3ee67b2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1783] Eliminate the wpad.dat configuration option (it's unused).
+
   *) [TS-1787] Eliminate old ink_time code (was probably only used by the
    now obsolete Web UI). This fixes compiling with gcc 4.8 as well.
 


[14/50] git commit: TS-1067 More cleanup of unused code

Posted by zw...@apache.org.
TS-1067 More cleanup of unused code


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

Branch: refs/heads/3.3.x
Commit: 5b5c869f7c6e94a5b8fbab4f9c46355ebfdf1ff7
Parents: f7da693
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Mar 26 21:59:11 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

----------------------------------------------------------------------
 iocore/net/I_UDPPacket.h |   15 ++--
 iocore/net/P_UDPNet.h    |    4 -
 iocore/net/P_UDPPacket.h |   35 +--------
 iocore/net/UnixUDPNet.cc |  158 ++++++++++++++++-------------------------
 4 files changed, 70 insertions(+), 142 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b5c869f/iocore/net/I_UDPPacket.h
----------------------------------------------------------------------
diff --git a/iocore/net/I_UDPPacket.h b/iocore/net/I_UDPPacket.h
index 09826dc..08dfa88 100644
--- a/iocore/net/I_UDPPacket.h
+++ b/iocore/net/I_UDPPacket.h
@@ -45,24 +45,22 @@ class UDPPacket
 
 public:
 
-  virtual ~ UDPPacket()
-  {
-  };
-  virtual void free();          // fast deallocate
+  virtual ~UDPPacket()
+  { }
 
+  virtual void free();          // fast deallocate
   void setContinuation(Continuation * c);
   void setConnection(UDPConnection * c);
   UDPConnection *getConnection();
-  void setArrivalTime(ink_hrtime t);
   IOBufferBlock *getIOBlockChain();
   int64_t getPktLength();
+
   /**
      Add IOBufferBlock (chain) to end of packet.
      @param block block chain to add.
 
    */
   inkcoreapi void append_block(IOBufferBlock * block);
-  virtual void UDPPacket_is_abstract() = 0;
 
   IpEndpoint from;    // what address came from
   IpEndpoint to;      // what address to send to
@@ -94,8 +92,9 @@ extern UDPPacket *new_UDPPacket(struct sockaddr const* to, ink_hrtime when = 0,
    for packet
    @param len # of bytes to reference from block
  */
-extern UDPPacket *new_UDPPacket(struct sockaddr const* to,
-                                    ink_hrtime when = 0, IOBufferBlock * block = NULL, int len = 0);
+
+TS_INLINE UDPPacket *new_UDPPacket(struct sockaddr const* to, ink_hrtime when = 0,
+                                   IOBufferBlock * block = NULL, int len = 0);
 /**
    Create a new packet to be sent over UDPConnection.  Packet has no
    destination or data.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b5c869f/iocore/net/P_UDPNet.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_UDPNet.h b/iocore/net/P_UDPNet.h
index 9c564f3..9cba1b3 100644
--- a/iocore/net/P_UDPNet.h
+++ b/iocore/net/P_UDPNet.h
@@ -70,7 +70,6 @@ public:
   // Interface exported to the outside world
   void send(UDPPacket * p);
 
-  Queue<UDPPacketInternal> reliabilityPktQueue;
   InkAtomicList atomicQueue;
   ink_hrtime last_report;
   ink_hrtime last_service;
@@ -81,8 +80,6 @@ public:
   ~UDPQueue();
 };
 
-#ifdef PACKETQUEUE_IMPL_AS_RING
-
 // 20 ms slots; 2048 slots  => 40 sec. into the future
 #define SLOT_TIME_MSEC 20
 #define SLOT_TIME HRTIME_MSECONDS(SLOT_TIME_MSEC)
@@ -296,7 +293,6 @@ private:
   void kill_cancelled_events()
   { }
 };
-#endif
 
 void initialize_thread_for_udp_net(EThread * thread);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b5c869f/iocore/net/P_UDPPacket.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_UDPPacket.h b/iocore/net/P_UDPPacket.h
index a93f083..f56e0b9 100644
--- a/iocore/net/P_UDPPacket.h
+++ b/iocore/net/P_UDPPacket.h
@@ -26,7 +26,6 @@
   P_UDPPacket.h
   Implementation of UDPPacket
 
-
  ****************************************************************************/
 
 
@@ -35,9 +34,6 @@
 
 #include "I_UDPNet.h"
 
-//#define PACKETQUEUE_IMPL_AS_PQLIST
-#define PACKETQUEUE_IMPL_AS_RING
-
 class UDPPacketInternal:public UDPPacket
 {
 
@@ -51,43 +47,32 @@ public:
 
   SLINK(UDPPacketInternal, alink);  // atomic link
   // packet scheduling stuff: keep it a doubly linked list
-  uint64_t pktSendStartTime;
-  uint64_t pktSendFinishTime;
   uint64_t pktLength;
 
   int reqGenerationNum;
   ink_hrtime delivery_time;   // when to deliver packet
-  ink_hrtime arrival_time;    // when packet arrived
 
   Ptr<IOBufferBlock> chain;
   Continuation *cont;         // callback on error
   UDPConnectionInternal *conn;        // connection where packet should be sent to.
 
-#if defined(PACKETQUEUE_IMPL_AS_PQLIST) || defined(PACKETQUEUE_IMPL_AS_RING)
   int in_the_priority_queue;
   int in_heap;
-#endif
-
-  virtual void UDPPacket_is_abstract() { }
 };
 
 inkcoreapi extern ClassAllocator<UDPPacketInternal> udpPacketAllocator;
 
 TS_INLINE
 UDPPacketInternal::UDPPacketInternal()
-  : pktSendStartTime(0), pktSendFinishTime(0), pktLength(0),
-    reqGenerationNum(0), delivery_time(0), arrival_time(0), cont(NULL) , conn(NULL)
-#if defined(PACKETQUEUE_IMPL_AS_PQLIST) || defined(PACKETQUEUE_IMPL_AS_RING)
-  ,in_the_priority_queue(0), in_heap(0)
-#endif
+  : pktLength(0), reqGenerationNum(0), delivery_time(0), cont(NULL),
+    conn(NULL), in_the_priority_queue(0), in_heap(0)
 {
   memset(&from, '\0', sizeof(from));
   memset(&to, '\0', sizeof(to));
 }
 
 TS_INLINE
-UDPPacketInternal::~
-UDPPacketInternal()
+UDPPacketInternal::~UDPPacketInternal()
 {
   chain = NULL;
 }
@@ -181,21 +166,13 @@ UDPPacket::getConnection(void)
   return ((UDPPacketInternal *) this)->conn;
 }
 
-TS_INLINE void
-UDPPacket::setArrivalTime(ink_hrtime t)
-{
-  ((UDPPacketInternal *) this)->arrival_time = t;
-}
-
 TS_INLINE UDPPacket *
 new_UDPPacket(struct sockaddr const* to, ink_hrtime when, char *buf, int len)
 {
   UDPPacketInternal *p = udpPacketAllocator.alloc();
 
-#if defined(PACKETQUEUE_IMPL_AS_PQLIST) || defined(PACKETQUEUE_IMPL_AS_RING)
   p->in_the_priority_queue = 0;
   p->in_heap = 0;
-#endif
   p->delivery_time = when;
   ats_ip_copy(&p->to, to);
 
@@ -217,10 +194,8 @@ new_UDPPacket(struct sockaddr const* to, ink_hrtime when, IOBufferBlock * buf, i
   UDPPacketInternal *p = udpPacketAllocator.alloc();
   IOBufferBlock *body;
 
-#if defined(PACKETQUEUE_IMPL_AS_PQLIST) || defined(PACKETQUEUE_IMPL_AS_RING)
   p->in_the_priority_queue = 0;
   p->in_heap = 0;
-#endif
   p->delivery_time = when;
   ats_ip_copy(&p->to, to);
 
@@ -237,10 +212,8 @@ new_UDPPacket(struct sockaddr const* to, ink_hrtime when, Ptr<IOBufferBlock> buf
 {
   UDPPacketInternal *p = udpPacketAllocator.alloc();
 
-#if defined(PACKETQUEUE_IMPL_AS_PQLIST) || defined(PACKETQUEUE_IMPL_AS_RING)
   p->in_the_priority_queue = 0;
   p->in_heap = 0;
-#endif
   p->delivery_time = when;
   if (to)
     ats_ip_copy(&p->to, to);
@@ -259,10 +232,8 @@ new_incoming_UDPPacket(struct sockaddr * from, char *buf, int len)
 {
   UDPPacketInternal *p = udpPacketAllocator.alloc();
 
-#if defined(PACKETQUEUE_IMPL_AS_PQLIST) || defined(PACKETQUEUE_IMPL_AS_RING)
   p->in_the_priority_queue = 0;
   p->in_heap = 0;
-#endif
   p->delivery_time = 0;
   ats_ip_copy(&p->from, from);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b5c869f/iocore/net/UnixUDPNet.cc
----------------------------------------------------------------------
diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc
index a20c93f..fc9c31d 100644
--- a/iocore/net/UnixUDPNet.cc
+++ b/iocore/net/UnixUDPNet.cc
@@ -136,8 +136,6 @@ UDPNetProcessorInternal::udp_read_from_net(UDPNetHandler * nh,
     // create packet
     UDPPacket *p = new_incoming_UDPPacket(ats_ip_sa_cast(&fromaddr), buf, r);
     p->setConnection(uc);
-    // XXX: is this expensive?  I] really want to know this information
-    p->setArrivalTime(ink_get_hrtime_internal());
     // queue onto the UDPConnection
     ink_atomiclist_push(&uc->inQueue, p);
     iters++;
@@ -189,18 +187,21 @@ public:
   ~UDPReadContinuation();
   inline void free(void);
   inline void init_token(Event * completionToken);
+  inline void init_read(int fd, IOBufferBlock * buf, int len, struct sockaddr *fromaddr, socklen_t *fromaddrlen);
 
-  inline void init_read(int fd, IOBufferBlock * buf, int len, struct sockaddr *fromaddr, socklen_t *fromaddrlen);     // start up polling
   void set_timer(int seconds)
   {
     timeout_interval = HRTIME_SECONDS(seconds);
   }
+
   void cancel();
   int readPollEvent(int event, Event * e);
+
   Action *getAction()
   {
     return event;
   }
+
   void setupPollDescriptor();
 
 private:
@@ -222,8 +223,8 @@ ClassAllocator<UDPReadContinuation> udpReadContAllocator("udpReadContAllocator")
 #define UNINITIALIZED_EVENT_PTR (Event *)0xdeadbeef
 
 UDPReadContinuation::UDPReadContinuation(Event * completionToken)
-: Continuation(NULL), event(completionToken), readbuf(NULL),
-  readlen(0), fromaddrlen(0), fd(-1), ifd(-1), period(0), elapsed_time(0), timeout_interval(0)
+  : Continuation(NULL), event(completionToken), readbuf(NULL), readlen(0), fromaddrlen(0), fd(-1),
+    ifd(-1), period(0), elapsed_time(0), timeout_interval(0)
 {
   if (completionToken->continuation)
     this->mutex = completionToken->continuation->mutex;
@@ -232,10 +233,9 @@ UDPReadContinuation::UDPReadContinuation(Event * completionToken)
 }
 
 UDPReadContinuation::UDPReadContinuation()
-: Continuation(NULL), event(UNINITIALIZED_EVENT_PTR), readbuf(NULL),
-  readlen(0), fromaddrlen(0), fd(-1), ifd(-1), period(0), elapsed_time(0), timeout_interval(0)
-{
-}
+  : Continuation(NULL), event(UNINITIALIZED_EVENT_PTR), readbuf(NULL), readlen(0), fromaddrlen(0), fd(-1),
+    ifd(-1), period(0), elapsed_time(0), timeout_interval(0)
+{ }
 
 inline void
 UDPReadContinuation::free(void)
@@ -345,40 +345,39 @@ UDPReadContinuation::readPollEvent(int event_, Event * e)
   //ink_assert(ifd < 0 || event_ == EVENT_INTERVAL || (event_ == EVENT_POLL && pc->pollDescriptor->nfds > ifd && pc->pollDescriptor->pfd[ifd].fd == fd));
   //if (ifd < 0 || event_ == EVENT_INTERVAL || (pc->pollDescriptor->pfd[ifd].revents & POLLIN)) {
   ink_debug_assert(!"incomplete");
+  c = completionUtil::getContinuation(event);
+  // do read
+  socklen_t tmp_fromlen = *fromaddrlen;
+  int rlen = socketManager.recvfrom(fd, readbuf->end(), readlen, 0, ats_ip_sa_cast(fromaddr), &tmp_fromlen);
+
+  completionUtil::setThread(event, e->ethread);
+  // call back user with their event
+  if (rlen > 0) {
+    // do callback if read is successful
+    *fromaddrlen = tmp_fromlen;
+    completionUtil::setInfo(event, fd, readbuf, rlen, errno);
+    readbuf->fill(rlen);
+    // TODO: Should we deal with the return code?
+    c->handleEvent(NET_EVENT_DATAGRAM_READ_COMPLETE, event);
+    e->cancel();
+    free();
+    // delete this;
+    return EVENT_DONE;
+  } else if (rlen < 0 && rlen != -EAGAIN) {
+    // signal error.
+    *fromaddrlen = tmp_fromlen;
+    completionUtil::setInfo(event, fd, (IOBufferBlock *) readbuf, rlen, errno);
     c = completionUtil::getContinuation(event);
-    // do read
-    socklen_t tmp_fromlen = *fromaddrlen;
-    int rlen = socketManager.recvfrom(fd, readbuf->end(), readlen,
-                                      0,        // default flags
-                                      ats_ip_sa_cast(fromaddr), &tmp_fromlen);
-    completionUtil::setThread(event, e->ethread);
-    // call back user with their event
-    if (rlen > 0) {
-      // do callback if read is successful
-      *fromaddrlen = tmp_fromlen;
-      completionUtil::setInfo(event, fd, readbuf, rlen, errno);
-      readbuf->fill(rlen);
-      // TODO: Should we deal with the return code?
-      c->handleEvent(NET_EVENT_DATAGRAM_READ_COMPLETE, event);
-      e->cancel();
-      free();
-      // delete this;
-      return EVENT_DONE;
-    } else if (rlen < 0 && rlen != -EAGAIN) {
-      // signal error.
-      *fromaddrlen = tmp_fromlen;
-      completionUtil::setInfo(event, fd, (IOBufferBlock *) readbuf, rlen, errno);
-      c = completionUtil::getContinuation(event);
-      // TODO: Should we deal with the return code?
-      c->handleEvent(NET_EVENT_DATAGRAM_READ_ERROR, event);
-      e->cancel();
-      free();
-      //delete this;
-      return EVENT_DONE;
-    } else {
-      completionUtil::setThread(event, NULL);
-    }
-//}
+    // TODO: Should we deal with the return code?
+    c->handleEvent(NET_EVENT_DATAGRAM_READ_ERROR, event);
+    e->cancel();
+    free();
+    //delete this;
+    return EVENT_DONE;
+  } else {
+    completionUtil::setThread(event, NULL);
+  }
+
   if (event->cancelled) {
     e->cancel();
     free();
@@ -417,10 +416,11 @@ UDPNetProcessor::recvfrom_re(Continuation * cont,
   ink_assert(buf->write_avail() >= len);
   int actual;
   Event *event = completionUtil::create();
+
   completionUtil::setContinuation(event, cont);
   completionUtil::setHandle(event, token);
-  actual = socketManager.recvfrom(fd, buf->end(), len, 0,       // default flags
-                                  fromaddr, fromaddrlen);
+  actual = socketManager.recvfrom(fd, buf->end(), len, 0, fromaddr, fromaddrlen);
+
   if (actual > 0) {
     completionUtil::setThread(event, this_ethread());
     completionUtil::setInfo(event, fd, buf, actual, errno);
@@ -458,6 +458,7 @@ UDPNetProcessor::sendmsg_re(Continuation * cont, void *token, int fd, struct msg
 {
   int actual;
   Event *event = completionUtil::create();
+
   completionUtil::setContinuation(event, cont);
   completionUtil::setHandle(event, token);
 
@@ -489,13 +490,13 @@ UDPNetProcessor::sendmsg_re(Continuation * cont, void *token, int fd, struct msg
  *
  */
 Action *
-UDPNetProcessor::sendto_re(Continuation * cont,
-                           void *token, int fd, struct sockaddr const* toaddr, int toaddrlen, IOBufferBlock * buf, int len)
+UDPNetProcessor::sendto_re(Continuation * cont, void *token, int fd, struct sockaddr const* toaddr, int toaddrlen,
+                           IOBufferBlock * buf, int len)
 {
   (void) token;
   ink_assert(buf->read_avail() >= len);
-  int nbytes_sent = socketManager.sendto(fd, buf->start(), len, 0,
-                                         toaddr, toaddrlen);
+  int nbytes_sent = socketManager.sendto(fd, buf->start(), len, 0, toaddr, toaddrlen);
+
   if (nbytes_sent >= 0) {
     ink_assert(nbytes_sent == len);
     buf->consume(nbytes_sent);
@@ -509,14 +510,9 @@ UDPNetProcessor::sendto_re(Continuation * cont,
 
 
 bool
-UDPNetProcessor::CreateUDPSocket(
-  int *resfd,
-  sockaddr const* remote_addr,
-  sockaddr* local_addr,
-  int *local_addr_len,
-  Action ** status, 
-  int send_bufsize, int recv_bufsize
-) {
+UDPNetProcessor::CreateUDPSocket(int *resfd, sockaddr const* remote_addr, sockaddr* local_addr,
+                                 int *local_addr_len, Action ** status, int send_bufsize, int recv_bufsize)
+{
   int res = 0, fd = -1;
 
   ink_assert(ats_ip_are_compatible(remote_addr, local_addr));
@@ -630,15 +626,10 @@ Lerror:
 // send out all packets that need to be sent out as of time=now
 UDPQueue::UDPQueue()
   : last_report(0), last_service(0), packets(0), added(0)
-{
-}
+{ }
 
 UDPQueue::~UDPQueue()
 {
-  UDPPacketInternal *p;
-
-  while ((p = reliabilityPktQueue.dequeue()) != NULL)
-    p->free();
 }
 
 /*
@@ -647,26 +638,18 @@ UDPQueue::~UDPQueue()
 void
 UDPQueue::service(UDPNetHandler * nh)
 {
+  (void) nh;
   ink_hrtime now = ink_get_hrtime_internal();
   uint64_t timeSpent = 0;
+  uint64_t pktSendStartTime;
   UDPPacketInternal *p;
   ink_hrtime pktSendTime;
   double minPktSpacing;
   uint32_t pktSize;
   int64_t pktLen;
 
-  (void) nh;
-  static ink_hrtime lastPrintTime = ink_get_hrtime_internal();
-  static ink_hrtime lastSchedTime = ink_get_hrtime_internal();
-  static uint32_t schedJitter = 0;
-  static uint32_t numTimesSched = 0;
-
-  schedJitter += ink_hrtime_to_msec(now - lastSchedTime);
-  numTimesSched++;
-
   p = (UDPPacketInternal *) ink_atomiclist_popall(&atomicQueue);
   if (p) {
-
     UDPPacketInternal *pnext = NULL;
     Queue<UDPPacketInternal> stk;
 
@@ -676,6 +659,7 @@ UDPQueue::service(UDPNetHandler * nh)
       stk.push(p);
       p = pnext;
     }
+
     // walk backwards down list since this is actually an atomic stack.
     while (stk.head) {
       p = stk.pop();
@@ -685,27 +669,20 @@ UDPQueue::service(UDPNetHandler * nh)
       Debug("udp-send", "Adding %p", p);
       pktLen = p->getPktLength();
       if (p->conn->lastPktStartTime == 0) {
-        p->pktSendStartTime = MAX(now, p->delivery_time);
+        pktSendStartTime = MAX(now, p->delivery_time);
       } else {
         pktSize = MAX(INK_ETHERNET_MTU_SIZE, pktLen);
         minPktSpacing = 0.0;
         pktSendTime = p->delivery_time;
-        p->pktSendStartTime = MAX(MAX(now, pktSendTime), p->delivery_time);
+        pktSendStartTime = MAX(MAX(now, pktSendTime), p->delivery_time);
       }
-      p->conn->lastPktStartTime = p->pktSendStartTime;
-      p->delivery_time = p->pktSendStartTime;
+      p->conn->lastPktStartTime = pktSendStartTime;
+      p->delivery_time = pktSendStartTime;
 
       G_inkPipeInfo.addPacket(p, now);
     }
   }
 
-  if ((now - lastPrintTime) > ink_hrtime_from_sec(30)) {
-    Debug("udp-sched-jitter", "avg. udp sched jitter: %f", (double) schedJitter / numTimesSched);
-    schedJitter = 0;
-    numTimesSched = 0;
-    lastPrintTime = now;
-  }
-
   G_inkPipeInfo.advanceNow(now);
   SendPackets();
 
@@ -733,21 +710,6 @@ UDPQueue::SendPackets()
   if (now > last_service)
     timeDelta = ink_hrtime_to_msec(now - last_service);
 
-  while ((p = reliabilityPktQueue.dequeue()) != NULL) {
-    pktLen = p->getPktLength();
-    if (p->conn->shouldDestroy())
-      goto next_pkt_3;
-    if (p->conn->GetSendGenerationNumber() != p->reqGenerationNum)
-      goto next_pkt_3;
-
-    SendUDPPacket(p, pktLen);
-    bytesThisSlot -= pktLen;
-    if (bytesThisSlot < 0)
-      break;
-  next_pkt_3:
-    p->free();
-  }
-
   bytesThisSlot = INT_MAX;
 
 sendPackets:


[03/50] git commit: TS-1796 remove cluster connection number change handle

Posted by zw...@apache.org.
TS-1796  remove cluster connection number change handle


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

Branch: refs/heads/3.3.x
Commit: 5c04d4aac4cd34be94d0dab4d376a30937653c08
Parents: 9e57b8a
Author: Chen Bin <ku...@taobao.com>
Authored: Tue Apr 2 11:22:04 2013 +0800
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:42 2013 -0600

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5c04d4aa/iocore/cluster/ClusterHandlerBase.cc
----------------------------------------------------------------------
diff --git a/iocore/cluster/ClusterHandlerBase.cc b/iocore/cluster/ClusterHandlerBase.cc
index a8ee01c..ee8070c 100644
--- a/iocore/cluster/ClusterHandlerBase.cc
+++ b/iocore/cluster/ClusterHandlerBase.cc
@@ -1038,28 +1038,13 @@ ClusterHandler::startClusterEvent(int event, Event * e)
             CLUSTER_INCREMENT_DYN_STAT(CLUSTER_NODES_STAT);
             this_cluster()->configurations.push(cconf);
           } else {
-            if (m->num_connections > machine->num_connections) {
-              // close old needlessness connection if new num_connections < old num_connections
-              for (int i = machine->num_connections; i < m->num_connections; i++) {
-                if (m->clusterHandlers[i])
-                  m->clusterHandlers[i]->downing = true;
-              }
-              m->free_connections -= (m->num_connections - machine->num_connections);
-              m->num_connections = machine->num_connections;
-              // delete_this
+            // close new connection if old connections is exist
+            if (id >= m->num_connections || m->clusterHandlers[id]) {
               failed = -2;
               MUTEX_UNTAKE_LOCK(the_cluster_config_mutex, this_ethread());
               goto failed;
-            } else {
-              m->num_connections = machine->num_connections;
-              // close new connection if old connections is exist
-              if (id >= m->num_connections || m->clusterHandlers[id]) {
-                failed = -2;
-                MUTEX_UNTAKE_LOCK(the_cluster_config_mutex, this_ethread());
-                goto failed;
-              }
-              machine = m;
             }
+            machine = m;
           }
           machine->now_connections++;
           machine->clusterHandlers[id] = this;


[36/50] git commit: TS-1805: fix conversion when pass value to statVarSet()

Posted by zw...@apache.org.
TS-1805: fix conversion when pass value to statVarSet()

The result from NodeStatEval()/ClusterStatEval() could have different type
compare to the token type of m_node_dest/m_cluster_dest.

So we should do conversion in statVarSet() when they are different.

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/a4ad3e8d
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/a4ad3e8d
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/a4ad3e8d

Branch: refs/heads/3.3.x
Commit: a4ad3e8d7758d923d69fa17deb939508916d6666
Parents: b18645b
Author: Yunkai Zhang <qi...@taobao.com>
Authored: Sun Apr 7 20:55:32 2013 +0800
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:44 2013 -0600

----------------------------------------------------------------------
 CHANGES                     |    3 +
 mgmt/stats/StatProcessor.cc |    3 +-
 mgmt/stats/StatType.cc      |   82 +++++++++++++++++++++++++++-----------
 mgmt/stats/StatType.h       |    6 +-
 4 files changed, 67 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a4ad3e8d/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 3ee67b2..11b87e4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1805] Fix stats ExpressionEval in stats xml.
+   Author: Yunkai Zhang
+
   *) [TS-1783] Eliminate the wpad.dat configuration option (it's unused).
 
   *) [TS-1787] Eliminate old ink_time code (was probably only used by the

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a4ad3e8d/mgmt/stats/StatProcessor.cc
----------------------------------------------------------------------
diff --git a/mgmt/stats/StatProcessor.cc b/mgmt/stats/StatProcessor.cc
index 98ce28d..26e8c2a 100644
--- a/mgmt/stats/StatProcessor.cc
+++ b/mgmt/stats/StatProcessor.cc
@@ -312,11 +312,12 @@ StatProcessor::processStat()
 RecData
 ExpressionEval(char *exprString)
 {
+  RecDataT result_type;
   StatObject statObject;
 
   char content[BUFSIZ * 10];
   XML_extractContent(exprString, content, BUFSIZ * 10);
 
   statObject.assignExpr(content);
-  return statObject.NodeStatEval(false);
+  return statObject.NodeStatEval(&result_type, false);
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a4ad3e8d/mgmt/stats/StatType.cc
----------------------------------------------------------------------
diff --git a/mgmt/stats/StatType.cc b/mgmt/stats/StatType.cc
index 7a283cc..efdde92 100644
--- a/mgmt/stats/StatType.cc
+++ b/mgmt/stats/StatType.cc
@@ -156,10 +156,6 @@ bool StatExprToken::assignTokenType()
     m_token_type = RECD_FX;
   }
 
-  if (m_token_type == RECD_COUNTER) {
-    m_token_type = RECD_INT;
-  }
-
   if (m_token_value_delta) {
     m_token_value_delta->data_type = m_token_type;
   }
@@ -228,8 +224,10 @@ StatExprToken::precedence()
  * or larger than max, then the error value is assigned. If no
  * error value is assigned, either min. or max. is assigned.
  */
-bool StatExprToken::statVarSet(RecData value)
+bool StatExprToken::statVarSet(RecDataT type, RecData value)
 {
+  RecData converted_value;
+
   if (StatError) {
     /* fix this after librecords is done
        mgmt_log(stderr,
@@ -240,14 +238,47 @@ bool StatExprToken::statVarSet(RecData value)
     return varSetData(m_token_type, m_token_name, err_value);
   }
 
-  if (RecDataCmp(m_token_type, value, m_token_value_min) < 0) {
+  /*
+   * do conversion if necessary.
+   */
+  if (m_token_type != type) {
+    switch (m_token_type) {
+    case RECD_INT:
+    case RECD_COUNTER:
+      if (type == RECD_NULL)
+        converted_value = value;
+      else if (type == RECD_INT || type == RECD_COUNTER || type == RECD_FX)
+        converted_value.rec_int = value.rec_int;
+      else if (type == RECD_FLOAT || type == RECD_CONST)
+        converted_value.rec_int = (RecInt)value.rec_float;
+      else
+        Fatal("invalid value type:%d\n", m_token_type);
+      break;
+    case RECD_FLOAT:
+      if (type == RECD_NULL)
+        converted_value = value;
+      else if (type == RECD_INT || type == RECD_COUNTER || type == RECD_FX)
+        converted_value.rec_float = (RecFloat)value.rec_int;
+      else if (type == RECD_FLOAT || type == RECD_CONST)
+        converted_value.rec_float = value.rec_float;
+      else
+        Fatal("invalid value type:%d\n", m_token_type);
+      break;
+    default:
+      Fatal("unsupported token type:%d\n", m_token_type);
+    }
+  } else {
+    converted_value = value;
+  }
+
+  if (RecDataCmp(m_token_type, converted_value, m_token_value_min) < 0) {
     value = m_token_value_min;
   }
-  else if (RecDataCmp(m_token_type, value, m_token_value_max) > 0) {
+  else if (RecDataCmp(m_token_type, converted_value, m_token_value_max) > 0) {
     value = m_token_value_max;
   }
 
-  return varSetData(m_token_type, m_token_name, value);
+  return varSetData(m_token_type, m_token_name, converted_value);
 }
 
 
@@ -632,7 +663,7 @@ StatObject::infix2postfix()
  *
  *
  */
-RecData StatObject::NodeStatEval(bool cluster)
+RecData StatObject::NodeStatEval(RecDataT *result_type, bool cluster)
 {
   StatExprList stack;
   StatExprToken *left = NULL;
@@ -653,8 +684,10 @@ RecData StatObject::NodeStatEval(bool cluster)
     }
 
     if (src->m_token_type == RECD_CONST) {
+      *result_type = RECD_CONST;
       tempValue = src->m_token_value;
     } else if (src->m_token_value_delta) {
+      *result_type = src->m_token_type;
       tempValue = src->m_token_value_delta->diff_value(src->m_token_name);
     } else if (!cluster) {
       if (!varDataFromName(src->m_token_type, src->m_token_name, &tempValue)) {
@@ -704,6 +737,7 @@ RecData StatObject::NodeStatEval(bool cluster)
       ink_debug_assert(false);
     }
 
+    *result_type = stack.top()->m_token_type;
     tempValue = stack.top()->m_token_value;
   }
 
@@ -718,7 +752,7 @@ RecData StatObject::NodeStatEval(bool cluster)
  *
  *
  */
-RecData StatObject::ClusterStatEval()
+RecData StatObject::ClusterStatEval(RecDataT *result_type)
 {
   RecData tempValue;
 
@@ -727,11 +761,12 @@ RecData StatObject::ClusterStatEval()
 
   // what is this?
   if ((m_node_dest == NULL) || (m_cluster_dest->m_sum_var == false)) {
-    return NodeStatEval(true);
+    return NodeStatEval(result_type, true);
   } else {
     if (!overviewGenerator->varClusterDataFromName(m_node_dest->m_token_type,
                                                    m_node_dest->m_token_name,
                                                    &tempValue)) {
+      *result_type = RECD_NULL;
       RecDataClear(RECD_NULL, &tempValue);
     }
     return (tempValue);
@@ -986,6 +1021,7 @@ StatObjectList::Eval()
 {
   RecData tempValue;
   RecData result;
+  RecDataT result_type;
   ink_hrtime threshold = 0;
   ink_hrtime delta = 0;
   short count = 0;
@@ -1006,13 +1042,13 @@ StatObjectList::Eval()
       object->m_current_time = ink_get_hrtime_internal();
 
       if (object->m_node_dest) {
-        result = object->NodeStatEval(false);
-        object->m_node_dest->statVarSet(result);
+        result = object->NodeStatEval(&result_type, false);
+        object->m_node_dest->statVarSet(result_type, result);
       }
 
       if (object->m_cluster_dest) {
-        result = object->ClusterStatEval();
-        object->m_cluster_dest->statVarSet(result);
+        result = object->ClusterStatEval(&result_type);
+        object->m_cluster_dest->statVarSet(result_type, result);
       }
 
       object->m_last_update = object->m_current_time;
@@ -1051,13 +1087,13 @@ StatObjectList::Eval()
           }
 
           if (object->m_node_dest) {
-            result = object->NodeStatEval(false);
-            object->m_node_dest->statVarSet(result);
+            result = object->NodeStatEval(&result_type, false);
+            object->m_node_dest->statVarSet(result_type, result);
           }
 
           if (object->m_cluster_dest) {
-            result = object->ClusterStatEval();
-            object->m_cluster_dest->statVarSet(result);
+            result = object->ClusterStatEval(&result_type);
+            object->m_cluster_dest->statVarSet(result_type, result);
           }
 
           object->m_last_update = object->m_current_time;
@@ -1083,13 +1119,13 @@ StatObjectList::Eval()
 
           if (delta > threshold) {
             if (object->m_node_dest) {
-              result = object->NodeStatEval(false);
-              object->m_node_dest->statVarSet(result);
+              result = object->NodeStatEval(&result_type, false);
+              object->m_node_dest->statVarSet(result_type, result);
             }
 
             if (object->m_cluster_dest) {
-              result = object->ClusterStatEval();
-              object->m_cluster_dest->statVarSet(result);
+              result = object->ClusterStatEval(&result_type);
+              object->m_cluster_dest->statVarSet(result_type, result);
             }
 
             object->m_last_update = object->m_current_time;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a4ad3e8d/mgmt/stats/StatType.h
----------------------------------------------------------------------
diff --git a/mgmt/stats/StatType.h b/mgmt/stats/StatType.h
index 3d56ee3..673e1e7 100644
--- a/mgmt/stats/StatType.h
+++ b/mgmt/stats/StatType.h
@@ -114,7 +114,7 @@ public:
   };
   void clean();
 
-  bool statVarSet(RecData);
+  bool statVarSet(RecDataT, RecData);
 };
 
 
@@ -189,8 +189,8 @@ public:
   void assignExpr(char *);
 
   StatExprToken *StatBinaryEval(StatExprToken *, char, StatExprToken *, bool cluster = false);
-  RecData NodeStatEval(bool cluster);
-  RecData ClusterStatEval();
+  RecData NodeStatEval(RecDataT *result_type, bool cluster);
+  RecData ClusterStatEval(RecDataT *result_type);
   void setTokenValue(StatExprToken *, bool cluster = false);
 
 private:


[41/50] git commit: Fix ubuntu vagrant image URL

Posted by zw...@apache.org.
Fix ubuntu vagrant image URL


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

Branch: refs/heads/3.3.x
Commit: 8fa72bf5c515ef5e7217ca6e0d6c5e4d40bf4d92
Parents: af74724
Author: James Peach <jp...@apache.org>
Authored: Wed Apr 10 10:47:11 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:44 2013 -0600

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8fa72bf5/Vagrantfile
----------------------------------------------------------------------
diff --git a/Vagrantfile b/Vagrantfile
index 87dd26e..064b3b4 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -42,7 +42,7 @@ Vagrant.configure("2") do |config|
   ['raring', 'quantal', 'precise'].each { |release|
     config.vm.define "#{release}64" do | config |
       config.vm.box = "#{release}64"
-      config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/%{release}/current/#{release}-server-cloudimg-amd64-vagrant-disk1.box"
+      config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/#{release}/current/#{release}-server-cloudimg-amd64-vagrant-disk1.box"
       config.vm.network :private_network, ip: $network["#{release}64"]
       config.vm.provision :puppet do |puppet|
         puppet.manifests_path = "contrib/manifests"

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8fa72bf5/contrib/manifests/debian.pp
----------------------------------------------------------------------
diff --git a/contrib/manifests/debian.pp b/contrib/manifests/debian.pp
index d495226..db5873e 100644
--- a/contrib/manifests/debian.pp
+++ b/contrib/manifests/debian.pp
@@ -16,7 +16,7 @@
 
 # Base ATS build dependencies.
 package {[
-    'gcc', 'g++', 'automake', 'autoconf', 'libtool',
+    'gcc', 'g++', 'automake', 'autoconf', 'libtool', 'pkg-config',
     'libssl-dev', 'tcl-dev', 'libexpat1-dev', 'libpcre3-dev',
     'libcap-dev', 'libcap2', 'bison', 'flex', 'make',
   ]:


[49/50] git commit: TS-1778: Remove vestigal extensions.config support

Posted by zw...@apache.org.
TS-1778: Remove vestigal extensions.config support


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

Branch: refs/heads/3.3.x
Commit: b7b685165efb116d4a23567ba1e637653aef7d12
Parents: 922c301
Author: James Peach <jp...@apache.org>
Authored: Fri Mar 29 14:09:24 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:45 2013 -0600

----------------------------------------------------------------------
 CHANGES                                            |    2 +
 .../perl/AdminClient/lib/Apache/TS/AdminClient.pm  |    1 -
 example/app-template/app-template.cc               |    6 +-
 mgmt/RecordsConfig.cc                              |    2 -
 proxy/Main.cc                                      |    6 +-
 proxy/Makefile.am                                  |    3 -
 proxy/Plugin.cc                                    |   64 +----
 proxy/Plugin.h                                     |    2 +-
 proxy/PluginDB.cc                                  |  205 ---------------
 proxy/PluginDB.h                                   |   65 -----
 10 files changed, 14 insertions(+), 342 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 59a196b..3444721 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1778] Remove vestigal extensions.config support
+
   *) [TS-1806] bogus buffer sizing in CfgContextUtils.cc
 
   *) [TS-1805] Fix stats ExpressionEval in stats xml.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm
----------------------------------------------------------------------
diff --git a/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm b/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm
index 82968db..8260fa2 100644
--- a/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm
+++ b/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm
@@ -618,7 +618,6 @@ The Apache Traffic Server Administration Manual will explain what these strings
  proxy.config.output.logfile
  proxy.config.ping.npacks_to_trans
  proxy.config.ping.timeout_sec
- proxy.config.plugin.extensions_dir
  proxy.config.plugin.plugin_dir
  proxy.config.plugin.plugin_mgmt_dir
  proxy.config.prefetch.child_port

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/example/app-template/app-template.cc
----------------------------------------------------------------------
diff --git a/example/app-template/app-template.cc b/example/app-template/app-template.cc
index adc2ef3..737e20a 100644
--- a/example/app-template/app-template.cc
+++ b/example/app-template/app-template.cc
@@ -233,12 +233,8 @@ int main(int argc, char * argv[])
   // initialize logging (after event and net processor)
   //Log::init(system_remote_management_flag ? 0 : Log::NO_REMOTE_MANAGEMENT);
 
-#if !defined(TS_NO_API)
-  //plugin_init(system_config_directory, true); // extensions.config
-#endif
-
 #ifndef TS_NO_API
-  //plugin_init(system_config_directory, false); // plugin.config
+  //plugin_init(system_config_directory); // plugin.config
 #else
   //api_init();  // still need to initialize some of the data structure other module needs.
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 75464bf..55b0cb8 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -1384,8 +1384,6 @@ RecordElement RecordsConfig[] = {
   ,
   {RECT_CONFIG, "proxy.config.plugin.plugin_mgmt_dir", RECD_STRING, TS_BUILD_SYSCONFDIR "/plugins_mgmt", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,
-  {RECT_CONFIG, "proxy.config.plugin.extensions_dir", RECD_STRING, TS_BUILD_RUNTIMEDIR, RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
-  ,
 
   //##############################################################################
   //#

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index 9cff6f3..c15529c 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -1650,10 +1650,6 @@ main(int argc, char **argv)
     Log::init(remote_management_flag ? 0 : Log::NO_REMOTE_MANAGEMENT);
 #endif
 
-#if !defined(TS_NO_API)
-    plugin_init(system_config_directory, true); // extensions.config
-#endif
-
     //acc.init();
     //if (auto_clear_authdb_flag)
      // acc.clear_cache();
@@ -1717,7 +1713,7 @@ main(int argc, char **argv)
     }
 
 #ifndef TS_NO_API
-    plugin_init(system_config_directory, false);        // plugin.config
+    plugin_init(system_config_directory);        // plugin.config
 #else
     api_init();                 // we still need to initialize some of the data structure other module needs.
     // i.e. http_global_hooks

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/proxy/Makefile.am
----------------------------------------------------------------------
diff --git a/proxy/Makefile.am b/proxy/Makefile.am
index ff2529d..288261d 100644
--- a/proxy/Makefile.am
+++ b/proxy/Makefile.am
@@ -106,8 +106,6 @@ traffic_server_SOURCES = \
   ParentSelection.h \
   Plugin.cc \
   Plugin.h \
-  PluginDB.cc \
-  PluginDB.h \
   PluginVC.cc \
   PluginVC.h \
   Prefetch.cc \
@@ -233,7 +231,6 @@ traffic_sac_SOURCES = \
   Prefetch.cc \
   Update.cc \
   Plugin.cc \
-  PluginDB.cc \
   InkAPI.cc \
   FetchSM.cc \
   InkIOCoreAPI.cc \

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/proxy/Plugin.cc
----------------------------------------------------------------------
diff --git a/proxy/Plugin.cc b/proxy/Plugin.cc
index e40925b..419017b 100644
--- a/proxy/Plugin.cc
+++ b/proxy/Plugin.cc
@@ -35,7 +35,6 @@
 #include "InkAPIInternal.h"
 #include "Main.h"
 #include "Plugin.h"
-#include "PluginDB.h"
 
 // HPUX:
 //   LD_SHAREDCMD=ld -b
@@ -48,12 +47,8 @@
 
 
 static const char *plugin_dir = ".";
-static const char *extensions_dir = ".";
-static PluginDB *plugin_db = NULL;
 
 typedef void (*init_func_t) (int argc, char *argv[]);
-typedef void (*init_func_w_handle_t) (void *handle, int argc, char *argv[]);
-typedef int (*lic_req_func_t) (void);
 
 // Plugin registration vars
 //
@@ -75,11 +70,9 @@ PluginRegInfo::PluginRegInfo()
 { }
 
 static void *
-dll_open(char *fn, bool global)
+dll_open(const char *path)
 {
-  int global_flags = global ? RTLD_GLOBAL : 0;
-
-  return (void *) dlopen(fn, RTLD_NOW | global_flags);
+  return (void *) dlopen(path, RTLD_NOW);
 }
 
 static void *
@@ -101,21 +94,18 @@ dll_close(void *dlp)
   dlclose(dlp);
 }
 
-
 static void
-plugin_load(int argc, char *argv[], bool internal)
+plugin_load(int argc, char *argv[])
 {
   char path[PATH_NAME_MAX + 1];
   void *handle;
   init_func_t init;
-  lic_req_func_t lic_req;
   PluginRegInfo *plugin_reg_temp;
-  const char *pdir = internal ? extensions_dir : plugin_dir;
 
   if (argc < 1) {
     return;
   }
-  ink_filepath_make(path, sizeof(path), pdir, argv[0]);
+  ink_filepath_make(path, sizeof(path), plugin_dir, argv[0]);
 
   Note("loading plugin '%s'", path);
 
@@ -128,33 +118,18 @@ plugin_load(int argc, char *argv[], bool internal)
     plugin_reg_temp = (plugin_reg_temp->link).next;
   }
 
-  handle = dll_open(path, (internal ? true : false));
+  handle = dll_open(path);
   if (!handle) {
     Error("unable to load '%s': %s", path, dll_error(handle));
     abort();
   }
 
-  lic_req = (lic_req_func_t) dll_findsym(handle, "TSPluginLicenseRequired");
-  if (lic_req && lic_req() != 0) {
-    PluginDB::CheckLicenseResult result = plugin_db->CheckLicense(argv[0]);
-    if (result != PluginDB::license_ok) {
-      Error("unable to load '%s': %s", path, PluginDB::CheckLicenseResultStr[result]);
-      dll_close(handle);
-      abort();
-    }
-  }
   // Allocate a new registration structure for the
   //    plugin we're starting up
   ink_assert(plugin_reg_current == NULL);
   plugin_reg_current = new PluginRegInfo;
   plugin_reg_current->plugin_path = ats_strdup(path);
 
-  init_func_w_handle_t inith = (init_func_w_handle_t) dll_findsym(handle, "TSPluginInitwDLLHandle");
-  if (inith) {
-    inith(handle, argc, argv);
-    return;
-  }
-
   init = (init_func_t) dll_findsym(handle, "TSPluginInit");
   if (!init) {
     Error("unable to find TSPluginInit function '%s': %s", path, dll_error(handle));
@@ -268,7 +243,7 @@ plugins_exist(const char *config_dir)
 }
 
 void
-plugin_init(const char *config_dir, bool internal)
+plugin_init(const char *config_dir)
 {
   char path[PATH_NAME_MAX + 1];
   char line[1024], *p;
@@ -281,35 +256,14 @@ plugin_init(const char *config_dir, bool internal)
 
   if (INIT_ONCE) {
     api_init();
-    char *cfg = NULL;
-
     plugin_dir = TSPluginDirGet();
-
-    RecGetRecordString_Xmalloc("proxy.config.plugin.extensions_dir", (char**)&cfg);
-    if (cfg != NULL) {
-      extensions_dir = Layout::get()->relative(cfg);
-      ats_free(cfg);
-      cfg = NULL;
-    }
-    ink_filepath_make(path, sizeof(path), config_dir, "plugin.db");
-    plugin_db = new PluginDB(path);
     INIT_ONCE = false;
   }
 
-  ink_assert(plugin_db);
-
-  if (internal == false) {
-    ink_filepath_make(path, sizeof(path), config_dir, "plugin.config");
-  } else {
-    ink_filepath_make(path, sizeof(path), config_dir, "extensions.config");
-  }
-
+  ink_filepath_make(path, sizeof(path), config_dir, "plugin.config");
   fd = open(path, O_RDONLY);
   if (fd < 0) {
-    /* secret extensions dont complain */
-    if (internal == false) {
-      Warning("unable to open plugin config file '%s': %d, %s", path, errno, strerror(errno));
-    }
+    Warning("unable to open plugin config file '%s': %d, %s", path, errno, strerror(errno));
     return;
   }
 
@@ -362,7 +316,7 @@ plugin_init(const char *config_dir, bool internal)
       }
     }
 
-    plugin_load(argc, argv, internal);
+    plugin_load(argc, argv);
 
     for (i = 0; i < argc; i++)
       ats_free(vars[i]);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/proxy/Plugin.h
----------------------------------------------------------------------
diff --git a/proxy/Plugin.h b/proxy/Plugin.h
index d520313..4173a05 100644
--- a/proxy/Plugin.h
+++ b/proxy/Plugin.h
@@ -56,7 +56,7 @@ struct PluginRegInfo
 extern DLL<PluginRegInfo> plugin_reg_list;
 extern PluginRegInfo *plugin_reg_current;
 
-void plugin_init(const char *config_dir, bool internal_exts);
+void plugin_init(const char *config_dir);
 int plugins_exist(const char *config_dir);
 
 #endif /* __PLUGIN_H__ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/proxy/PluginDB.cc
----------------------------------------------------------------------
diff --git a/proxy/PluginDB.cc b/proxy/PluginDB.cc
deleted file mode 100644
index a2b42d2..0000000
--- a/proxy/PluginDB.cc
+++ /dev/null
@@ -1,205 +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.
- */
-
-#include "ink_config.h"
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include "ink_code.h"
-#include "Diags.h"
-#include "ParseRules.h"
-#include "PluginDB.h"
-
-/***************************************************************************
- *
- * An Inktomi Traffic Server plugin license key should look like:
- *
- *     XXXXXEEEEDDDDDD
- *
- * XXXXX is a 5 digit alphanumeric id used by plugin vendors to
- * assign to their customers.
- *
- * EEEE is the hex encoding of the expiration date. It's the number
- * of days from January 1, 1970. If a plugin has no expiration date,
- * 0000 can be used instead.
- *
- * DDDDDD is the INK_MD5 encoding of some combination of the following
- * strings: "Inktomi Traffic Server", "Plugin Name", "XXXXXEEEE".
- *
- *
- ***************************************************************************/
-
-const char *
-  PluginDB::CheckLicenseResultStr[] = {
-  "license missing",
-  "license expired",
-  "license invalid",
-  "license ok"
-};
-
-const unsigned int
-  PluginDB::license_custid_len = 5;
-const unsigned int
-  PluginDB::license_expire_len = 4;
-const unsigned int
-  PluginDB::license_digest_len = 6;
-const unsigned int
-  PluginDB::license_total_len = PluginDB::license_custid_len +
-  PluginDB::license_expire_len + PluginDB::license_digest_len;
-
-PluginDB::PluginDB(const char *plugin_db_file)
-{
-  info_table = ink_hash_table_create(InkHashTableKeyType_String);
-  ReadPluginDB(plugin_db_file);
-}
-
-PluginDB::~PluginDB(void)
-{
-  ink_hash_table_destroy_and_free_values(info_table);
-}
-
-void
-PluginDB::ReadPluginDB(const char *plugin_db_file)
-{
-  FILE *pdb = fopen(plugin_db_file, "r");
-  if (pdb == NULL) {
-    Warning("unable to open plugin.db file '%s': %d, %s", plugin_db_file, errno, strerror(errno));
-    return;
-  }
-
-  char line[1024];
-  char plugin_obj[256];
-  plugin_obj[0] = '\0';
-  PluginDB::PluginInfo * pinfo = new PluginDB::PluginInfo();
-
-  while (fgets(line, sizeof(line) - 1, pdb) != NULL) {
-    char *p = line;
-    while (*p && ParseRules::is_wslfcr(*p)) {
-      p++;
-    }
-    if ((*p == '\0') || (*p == '#')) {
-      continue;
-    }
-    // We have a non-comment and non-blank line
-
-    // Nullify the newline character
-    int len = strlen(p);
-    int i;
-    p[len - 1] = '\0';
-
-    if (p[0] == '[') {
-      if (plugin_obj[0] != '\0' && (pinfo->name[0] != '\0' || pinfo->license[0] != '\0')) {
-        ink_hash_table_insert(info_table, (InkHashTableKey) plugin_obj, (InkHashTableValue) pinfo);
-        plugin_obj[0] = '\0';
-        pinfo = new PluginDB::PluginInfo();
-      }
-      p++;
-      for (i = 0; p[i] != '\0' && p[i] != ']' && i < 255; i++) {
-        pinfo->name[i] = p[i];
-      }
-      pinfo->name[i] = '\0';
-
-    } else {
-      if (strstr(p, "Object=")) {
-        p = p + sizeof("Object=") - 1;
-        for (i = 0; p[i] != '\0' && i < 255; i++) {
-          plugin_obj[i] = p[i];
-        }
-        plugin_obj[i] = '\0';
-      } else if (strstr(p, "License=")) {
-        p = p + sizeof("License=") - 1;
-        for (i = 0; p[i] != '\0' && i < 255; i++) {
-          pinfo->license[i] = p[i];
-        }
-        pinfo->license[i] = '\0';
-      }
-    }
-  }
-
-  if (plugin_obj[0] != '\0' && (pinfo->name[0] != '\0' || pinfo->license[0] != '\0')) {
-    ink_hash_table_insert(info_table, (InkHashTableKey) plugin_obj, (InkHashTableValue) pinfo);
-  } else {
-    delete pinfo;
-  }
-  fclose(pdb);
-}
-
-PluginDB::CheckLicenseResult PluginDB::CheckLicense(const char *plugin_obj)
-{
-  char
-    buffer[1024],
-    buffer_md5[16],
-    buffer_md5_str[33];
-  char
-    expire_str[PluginDB::license_expire_len + 1];
-  unsigned long
-    expire_days;
-  INK_DIGEST_CTX
-    md5_context;
-  PluginDB::PluginInfo * pinfo;
-  char *
-    end_ptr = NULL;
-
-  InkHashTableEntry *
-    ht_entry = ink_hash_table_lookup_entry(info_table,
-                                           (InkHashTableKey) plugin_obj);
-  if (ht_entry != NULL) {
-    pinfo = (PluginDB::PluginInfo *) ink_hash_table_entry_value(info_table, ht_entry);
-  } else {
-    return PluginDB::license_missing;
-  }
-
-  if (strlen(pinfo->license) != PluginDB::license_total_len) {
-    return PluginDB::license_invalid;
-  }
-
-  snprintf(buffer, sizeof(buffer), "Inktomi Traffic Server %s ", pinfo->name);
-  strncat(buffer, pinfo->license, PluginDB::license_custid_len + PluginDB::license_expire_len);
-
-  ink_code_incr_md5_init(&md5_context);
-  ink_code_incr_md5_update(&md5_context, buffer, strlen(buffer));
-  ink_code_incr_md5_final(buffer_md5, &md5_context);
-  // coverity[uninit_use_in_call]
-  ink_code_md5_stringify(buffer_md5_str, sizeof(buffer_md5_str), buffer_md5);
-
-  if (strncmp(buffer_md5_str,
-              pinfo->license + PluginDB::license_custid_len
-              + PluginDB::license_expire_len, PluginDB::license_digest_len) != 0) {
-    return PluginDB::license_invalid;
-  }
-
-  strncpy(expire_str, pinfo->license + PluginDB::license_custid_len, PluginDB::license_expire_len);
-  expire_str[PluginDB::license_expire_len] = '\0';
-
-  expire_days = strtoul(expire_str, &end_ptr, 16);
-
-  if (expire_days != 0) {
-    time_t
-      time_now = time(NULL);
-    if ((unsigned long) time_now > expire_days * (60 * 60 * 24)) {
-      return PluginDB::license_expired;
-    }
-  }
-
-  return PluginDB::license_ok;
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b7b68516/proxy/PluginDB.h
----------------------------------------------------------------------
diff --git a/proxy/PluginDB.h b/proxy/PluginDB.h
deleted file mode 100644
index cf8f3ae..0000000
--- a/proxy/PluginDB.h
+++ /dev/null
@@ -1,65 +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.
- */
-
-#ifndef __PLUGIN_DB_H__
-#define __PLUGIN_DB_H__
-
-#include "ink_hash_table.h"
-
-class PluginDB
-{
-public:
-  typedef enum
-  {
-    license_missing = 0,
-    license_expired,
-    license_invalid,
-    license_ok
-  } CheckLicenseResult;
-
-    PluginDB(const char *plugin_db_file);
-   ~PluginDB(void);
-
-  CheckLicenseResult CheckLicense(const char *plugin_obj);
-
-  static const char *CheckLicenseResultStr[];
-
-private:
-
-  typedef struct
-  {
-    char name[256];
-    char license[256];
-  } PluginInfo;
-
-  static const unsigned int license_custid_len;
-  static const unsigned int license_expire_len;
-  static const unsigned int license_digest_len;
-  static const unsigned int license_total_len;
-
-  void ReadPluginDB(const char *plugin_db_file);
-
-  InkHashTable *info_table;
-};
-
-#endif /* __PLUGIN_DB_H__ */


[48/50] git commit: Add some new generated output files from the RAT checks.

Posted by zw...@apache.org.
Add some new generated output files from the RAT checks.


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

Branch: refs/heads/3.3.x
Commit: f591c23652314866fd9306d873fd6661e573e1cd
Parents: b5b1323
Author: Leif Hedstrom <zw...@apache.org>
Authored: Mon Apr 15 14:44:32 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:45 2013 -0600

----------------------------------------------------------------------
 ci/rat-excludes.txt |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f591c236/ci/rat-excludes.txt
----------------------------------------------------------------------
diff --git a/ci/rat-excludes.txt b/ci/rat-excludes.txt
index 6a7d24a..ebb4f0d 100644
--- a/ci/rat-excludes.txt
+++ b/ci/rat-excludes.txt
@@ -110,3 +110,9 @@ plugins/experimental/esi/parser_test
 plugins/experimental/esi/processor_test
 plugins/experimental/esi/utils_test
 plugins/experimental/esi/vars_test
+iocore/aio/diags.log
+iocore/aio/test_AIO
+iocore/aio/test_AIO.sample
+iocore/eventsystem/diags.log
+iocore/eventsystem/test_Buffer
+iocore/eventsystem/test_Event


[13/50] git commit: TS-1067 Replace G_inkPipeInfo with a member variable in UDPQueue

Posted by zw...@apache.org.
TS-1067 Replace G_inkPipeInfo with a member variable in UDPQueue


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

Branch: refs/heads/3.3.x
Commit: 9c2993a2ad5f6af721d4abb05969b664aec78134
Parents: 5a02561
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed Mar 27 10:13:09 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

----------------------------------------------------------------------
 iocore/net/I_UDPNet.h    |   10 +----
 iocore/net/P_UDPNet.h    |   74 ++++++++++++++++++++--------------------
 iocore/net/UnixUDPNet.cc |   16 ++++-----
 3 files changed, 46 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9c2993a2/iocore/net/I_UDPNet.h
----------------------------------------------------------------------
diff --git a/iocore/net/I_UDPNet.h b/iocore/net/I_UDPNet.h
index 847e2c1..159e93b 100644
--- a/iocore/net/I_UDPNet.h
+++ b/iocore/net/I_UDPNet.h
@@ -49,14 +49,8 @@ public:
 
   //this function was interanal intially.. this is required for public and
   //interface probably should change.
-  bool CreateUDPSocket(
-    int *resfd,
-    sockaddr const* remote_addr,
-    sockaddr* local_addr,
-    int* local_addr_len,
-    Action ** status,
-    int send_bufsize = 0, int recv_bufsize = 0
-  );
+  bool CreateUDPSocket(int *resfd, sockaddr const* remote_addr, sockaddr* local_addr, int* local_addr_len,
+                       Action ** status, int send_bufsize = 0, int recv_bufsize = 0);
 
   /**
      create UDPConnection

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9c2993a2/iocore/net/P_UDPNet.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_UDPNet.h b/iocore/net/P_UDPNet.h
index 9cba1b3..e695383 100644
--- a/iocore/net/P_UDPNet.h
+++ b/iocore/net/P_UDPNet.h
@@ -56,29 +56,7 @@ struct UDPNetProcessorInternal : public UDPNetProcessor
 
 extern UDPNetProcessorInternal udpNetInternal;
 
-class PacketQueue;
 
-class UDPQueue
-{
-public:
-
-  void service(UDPNetHandler *);
-
-  void SendPackets();
-  void SendUDPPacket(UDPPacketInternal * p, int32_t pktLen);
-
-  // Interface exported to the outside world
-  void send(UDPPacket * p);
-
-  InkAtomicList atomicQueue;
-  ink_hrtime last_report;
-  ink_hrtime last_service;
-  int packets;
-  int added;
-
-  UDPQueue();
-  ~UDPQueue();
-};
 
 // 20 ms slots; 2048 slots  => 40 sec. into the future
 #define SLOT_TIME_MSEC 20
@@ -87,16 +65,16 @@ public:
 
 class PacketQueue
 {
-public:
-  PacketQueue()
-    : nPackets(0), now_slot(0)
-  {
-    lastPullLongTermQ = 0;
-    init();
-  }
+ public:
+ PacketQueue()
+   : nPackets(0), now_slot(0)
+    {
+      lastPullLongTermQ = 0;
+      init();
+    }
 
   virtual ~ PacketQueue()
-  { }
+    { }
 
   int nPackets;
   ink_hrtime lastPullLongTermQ;
@@ -250,7 +228,7 @@ public:
     now_slot = s;
   }
 
-private:
+ private:
   void remove(UDPPacketInternal * e)
   {
     nPackets--;
@@ -259,7 +237,7 @@ private:
     bucket[e->in_heap].remove(e);
   }
 
-public:
+ public:
   UDPPacketInternal *dequeue_ready(ink_hrtime t)
   {
     (void) t;
@@ -289,11 +267,37 @@ public:
     return HRTIME_FOREVER;
   }
 
-private:
+ private:
   void kill_cancelled_events()
   { }
 };
 
+
+class UDPQueue
+{
+  PacketQueue pipeInfo;
+  ink_hrtime last_report;
+  ink_hrtime last_service;
+  int packets;
+  int added;
+
+
+public:
+  InkAtomicList atomicQueue;
+
+  void service(UDPNetHandler *);
+
+  void SendPackets();
+  void SendUDPPacket(UDPPacketInternal * p, int32_t pktLen);
+
+  // Interface exported to the outside world
+  void send(UDPPacket * p);
+
+  UDPQueue();
+  ~UDPQueue();
+};
+
+
 void initialize_thread_for_udp_net(EThread * thread);
 
 struct UDPNetHandler: public Continuation
@@ -334,8 +338,4 @@ get_UDPNetHandler(EThread * t)
   return (UDPNetHandler *)ETHREAD_GET_PTR(t, udpNetInternal.udpNetHandler_offset);
 }
 
-// All of this stuff is for UDP egress b/w management
-// ToDo: It'd be nice to eliminate this entirely.... But we have no working use of UDPNet afaik. /leif
-extern PacketQueue G_inkPipeInfo;
-
 #endif //__P_UDPNET_H_

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9c2993a2/iocore/net/UnixUDPNet.cc
----------------------------------------------------------------------
diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc
index 446e349..ca428cb 100644
--- a/iocore/net/UnixUDPNet.cc
+++ b/iocore/net/UnixUDPNet.cc
@@ -58,8 +58,6 @@ int32_t g_udp_numSendRetries;
 // Public functions
 // See header for documentation
 //
-PacketQueue G_inkPipeInfo;
-
 int G_bwGrapherFd;
 sockaddr_in6 G_bwGrapherLoc;
 
@@ -677,11 +675,11 @@ UDPQueue::service(UDPNetHandler * nh)
       p->conn->lastPktStartTime = pktSendStartTime;
       p->delivery_time = pktSendStartTime;
 
-      G_inkPipeInfo.addPacket(p, now);
+      pipeInfo.addPacket(p, now);
     }
   }
 
-  G_inkPipeInfo.advanceNow(now);
+  pipeInfo.advanceNow(now);
   SendPackets();
 
   timeSpent = ink_hrtime_to_msec(now - last_report);
@@ -715,8 +713,8 @@ sendPackets:
   send_threshold_time = now + SLOT_TIME;
   bytesThisPipe = (int32_t)bytesThisSlot;
 
-  while ((bytesThisPipe > 0) && (G_inkPipeInfo.firstPacket(send_threshold_time))) {
-    p = G_inkPipeInfo.getFirstPacket();
+  while ((bytesThisPipe > 0) && (pipeInfo.firstPacket(send_threshold_time))) {
+    p = pipeInfo.getFirstPacket();
     pktLen = p->getPktLength();
 
     if (p->conn->shouldDestroy())
@@ -740,14 +738,14 @@ sendPackets:
   if ((bytesThisSlot > 0) && sentOne) {
     // redistribute the slack...
     now = ink_get_hrtime_internal();
-    if (G_inkPipeInfo.firstPacket(now) == NULL) {
-      G_inkPipeInfo.advanceNow(now);
+    if (pipeInfo.firstPacket(now) == NULL) {
+      pipeInfo.advanceNow(now);
     }
     goto sendPackets;
   }
 
   if ((g_udp_periodicFreeCancelledPkts) && (now - lastCleanupTime > ink_hrtime_from_sec(g_udp_periodicFreeCancelledPkts))) {
-    G_inkPipeInfo.FreeCancelledPackets(g_udp_periodicCleanupSlots);
+    pipeInfo.FreeCancelledPackets(g_udp_periodicCleanupSlots);
     lastCleanupTime = now;
   }
 }


[26/50] git commit: TS-1067 Remove more stats counting that is not needed anymore

Posted by zw...@apache.org.
TS-1067 Remove more stats counting that is not needed anymore


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

Branch: refs/heads/3.3.x
Commit: d502874ee4ef4974da36388e954e6bfc90e128ef
Parents: 0d3872a
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Mar 26 14:38:37 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

----------------------------------------------------------------------
 iocore/net/P_UDPConnection.h |   23 +----------------------
 iocore/net/UnixUDPNet.cc     |   13 -------------
 2 files changed, 1 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d502874e/iocore/net/P_UDPConnection.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_UDPConnection.h b/iocore/net/P_UDPConnection.h
index aacea6d..7cc7c33 100644
--- a/iocore/net/P_UDPConnection.h
+++ b/iocore/net/P_UDPConnection.h
@@ -60,38 +60,17 @@ public:
   // the same as the lastSentPktStartTime.
   uint64_t lastSentPktStartTime;
   uint64_t lastPktStartTime;
-  int32_t pipe_class;
-  uint32_t nBytesDone;
-  uint32_t nBytesTodo;
-  // flow rate in Bytes per sec.
-  double flowRateBps;
-  double avgPktSize;
-  int64_t allocedbps;
-
-  //this class is abstract
 };
 
 TS_INLINE
 UDPConnectionInternal::UDPConnectionInternal()
-  : continuation(NULL)
-  , recvActive(0)
-  , refcount(0)
-  , fd(-1)
-  , binding_valid(0)
-  , tobedestroyed(0)
-  , nBytesDone(0)
-  , nBytesTodo(0)
+  : continuation(NULL), recvActive(0), refcount(0), fd(-1), binding_valid(0), tobedestroyed(0)
 {
   sendGenerationNum = 0;
   lastSentPktTSSeqNum = -1;
   lastSentPktStartTime = 0;
   lastPktStartTime = 0;
-  pipe_class = 0;
-  flowRateBps = 0.0;
-  avgPktSize = 0.0;
-  allocedbps = 0;
   memset(&binding, 0, sizeof binding);
-  //SET_HANDLER(&BaseUDPConnection::callbackHandler);
 }
 
 TS_INLINE

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d502874e/iocore/net/UnixUDPNet.cc
----------------------------------------------------------------------
diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc
index fc94acc..c1e839d 100644
--- a/iocore/net/UnixUDPNet.cc
+++ b/iocore/net/UnixUDPNet.cc
@@ -696,18 +696,9 @@ UDPQueue::service(UDPNetHandler * nh)
         minPktSpacing = 0.0;
         pktSendTime = p->delivery_time;
         p->pktSendStartTime = MAX(MAX(now, pktSendTime), p->delivery_time);
-        if (p->conn->flowRateBps > 25600.0)
-          Debug("udpnet-pkt", "Pkt size = %.1lf now = %" PRId64 ", send = %" PRId64 ", del = %" PRId64 ", Delay delta = %" PRId64 "; delta = %" PRId64 "",
-                p->conn->avgPktSize,
-                now, pktSendTime, p->delivery_time,
-                ink_hrtime_to_msec(p->pktSendStartTime - now),
-                ink_hrtime_to_msec(p->pktSendStartTime - p->conn->lastPktStartTime));
-
-        p->conn->avgPktSize = ((4.0 * p->conn->avgPktSize) / 5.0) + (pktSize / 5.0);
       }
       p->conn->lastPktStartTime = p->pktSendStartTime;
       p->delivery_time = p->pktSendStartTime;
-      p->conn->nBytesTodo += pktLen;
 
       g_udp_bytesPending += pktLen;
       G_inkPipeInfo.addPacket(p, now);
@@ -754,8 +745,6 @@ UDPQueue::SendPackets()
   while ((p = reliabilityPktQueue.dequeue()) != NULL) {
     pktLen = p->getPktLength();
     g_udp_bytesPending -= pktLen;
-
-    p->conn->nBytesTodo -= pktLen;
     p->conn->nBytesDone += pktLen;
 
     if (p->conn->shouldDestroy())
@@ -783,8 +772,6 @@ sendPackets:
     pktLen = p->getPktLength();
     g_udp_bytesPending -= pktLen;
 
-    p->conn->nBytesTodo -= pktLen;
-    p->conn->nBytesDone += pktLen;
     if (p->conn->shouldDestroy())
       goto next_pkt;
     if (p->conn->GetSendGenerationNumber() != p->reqGenerationNum)


[18/50] git commit: TS-1067 Remove unused config (and code) for bandwidth management

Posted by zw...@apache.org.
TS-1067 Remove unused config (and code) for bandwidth management


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

Branch: refs/heads/3.3.x
Commit: ba740e8298d153261476bff1895e3a976bf0a6d2
Parents: 3da95a1
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Apr 2 15:32:35 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ba740e82/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 04d63ad..70e5bff 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1067] Remove unused config (and code) for bandwidth management.
+
   *) [TS-1736] Fatal() terminates process without a backtrace
     Author: Yunkai Zhang <yu...@gmail.com>
 


[15/50] git commit: TS-1067 Remove a number of unused member variables

Posted by zw...@apache.org.
TS-1067 Remove a number of unused member variables


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

Branch: refs/heads/3.3.x
Commit: f7da6934b395fb5f0ef0b9ac1bd956392c61ae9a
Parents: d502874
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Mar 26 20:24:45 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

----------------------------------------------------------------------
 iocore/net/I_UDPPacket.h |    1 -
 iocore/net/P_UDPNet.h    |   48 +++++++++++++++++++---------------------
 iocore/net/P_UDPPacket.h |   23 +------------------
 iocore/net/UnixUDPNet.cc |   34 +++++-----------------------
 4 files changed, 30 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f7da6934/iocore/net/I_UDPPacket.h
----------------------------------------------------------------------
diff --git a/iocore/net/I_UDPPacket.h b/iocore/net/I_UDPPacket.h
index ec50b9e..09826dc 100644
--- a/iocore/net/I_UDPPacket.h
+++ b/iocore/net/I_UDPPacket.h
@@ -55,7 +55,6 @@ public:
   UDPConnection *getConnection();
   void setArrivalTime(ink_hrtime t);
   IOBufferBlock *getIOBlockChain();
-  void setReliabilityPkt();
   int64_t getPktLength();
   /**
      Add IOBufferBlock (chain) to end of packet.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f7da6934/iocore/net/P_UDPNet.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_UDPNet.h b/iocore/net/P_UDPNet.h
index bf0d67d..9c564f3 100644
--- a/iocore/net/P_UDPNet.h
+++ b/iocore/net/P_UDPNet.h
@@ -63,7 +63,7 @@ class UDPQueue
 public:
 
   void service(UDPNetHandler *);
-  // In the absence of bulk-io, we are down sending packet after packet
+
   void SendPackets();
   void SendUDPPacket(UDPPacketInternal * p, int32_t pktLen);
 
@@ -74,7 +74,6 @@ public:
   InkAtomicList atomicQueue;
   ink_hrtime last_report;
   ink_hrtime last_service;
-  ink_hrtime last_byteperiod;
   int packets;
   int added;
 
@@ -89,24 +88,20 @@ public:
 #define SLOT_TIME HRTIME_MSECONDS(SLOT_TIME_MSEC)
 #define N_SLOTS 2048
 
-extern uint64_t g_udp_bytesPending;
-
 class PacketQueue
 {
 public:
   PacketQueue()
-  :nPackets(0)
-  , now_slot(0)
+    : nPackets(0), now_slot(0)
   {
     lastPullLongTermQ = 0;
     init();
   }
 
   virtual ~ PacketQueue()
-  {
-  }
-  int nPackets;
+  { }
 
+  int nPackets;
   ink_hrtime lastPullLongTermQ;
   Queue<UDPPacketInternal> longTermQ;
   Queue<UDPPacketInternal> bucket[N_SLOTS];
@@ -126,12 +121,12 @@ public:
     }
   }
 
-  void addPacket(UDPPacketInternal * e, ink_hrtime now = 0) {
+  void addPacket(UDPPacketInternal * e, ink_hrtime now = 0)
+  {
     int before = 0;
     int slot;
 
     if (IsCancelledPacket(e)) {
-      g_udp_bytesPending -= e->getPktLength();
       e->free();
       return;
     }
@@ -168,7 +163,8 @@ public:
     e->in_the_priority_queue = 1;
     e->in_heap = slot;
     bucket[slot].enqueue(e);
-  };
+  }
+
   UDPPacketInternal *firstPacket(ink_hrtime t)
   {
     if (t > delivery_time[now_slot]) {
@@ -176,23 +172,25 @@ public:
     } else {
       return NULL;
     }
-  };
+  }
+
   UDPPacketInternal *getFirstPacket()
   {
     nPackets--;
     return dequeue_ready(0);
-  };
+  }
+
   int size()
   {
     ink_assert(nPackets >= 0);
     return nPackets;
-  };
+  }
 
   bool IsCancelledPacket(UDPPacketInternal * p)
   {
     // discard packets that'll never get sent...
     return ((p->conn->shouldDestroy()) || (p->conn->GetSendGenerationNumber() != p->reqGenerationNum));
-  };
+  }
 
   void FreeCancelledPackets(int numSlots)
   {
@@ -204,7 +202,6 @@ public:
       s = (now_slot + i) % N_SLOTS;
       while (NULL != (p = bucket[s].dequeue())) {
         if (IsCancelledPacket(p)) {
-          g_udp_bytesPending -= p->getPktLength();
           p->free();
           continue;
         }
@@ -215,7 +212,7 @@ public:
         bucket[s].enqueue(p);
       }
     }
-  };
+  }
 
   void advanceNow(ink_hrtime t)
   {
@@ -254,7 +251,8 @@ public:
       Debug("udpnet-service", "Advancing by (%d slots): behind by %" PRId64 " ms",
             s - now_slot, ink_hrtime_to_msec(t - delivery_time[now_slot]));
     now_slot = s;
-  };
+  }
+
 private:
   void remove(UDPPacketInternal * e)
   {
@@ -265,7 +263,8 @@ private:
   }
 
 public:
-  UDPPacketInternal * dequeue_ready(ink_hrtime t) {
+  UDPPacketInternal *dequeue_ready(ink_hrtime t)
+  {
     (void) t;
     UDPPacketInternal *e = bucket[now_slot].dequeue();
     if (e) {
@@ -295,8 +294,7 @@ public:
 
 private:
   void kill_cancelled_events()
-  {
-  }
+  { }
 };
 #endif
 
@@ -331,17 +329,17 @@ struct PollCont;
 static inline PollCont *
 get_UDPPollCont(EThread * t)
 {
-  return (PollCont *) ETHREAD_GET_PTR(t, udpNetInternal.pollCont_offset);
+  return (PollCont *)ETHREAD_GET_PTR(t, udpNetInternal.pollCont_offset);
 }
 
 static inline UDPNetHandler *
 get_UDPNetHandler(EThread * t)
 {
-  return (UDPNetHandler *)
-    ETHREAD_GET_PTR(t, udpNetInternal.udpNetHandler_offset);
+  return (UDPNetHandler *)ETHREAD_GET_PTR(t, udpNetInternal.udpNetHandler_offset);
 }
 
 // All of this stuff is for UDP egress b/w management
+// ToDo: It'd be nice to eliminate this entirely.... But we have no working use of UDPNet afaik. /leif
 extern PacketQueue G_inkPipeInfo;
 
 #endif //__P_UDPNET_H_

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f7da6934/iocore/net/P_UDPPacket.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_UDPPacket.h b/iocore/net/P_UDPPacket.h
index 0a0d1a8..a93f083 100644
--- a/iocore/net/P_UDPPacket.h
+++ b/iocore/net/P_UDPPacket.h
@@ -45,7 +45,6 @@ public:
   UDPPacketInternal();
   virtual ~ UDPPacketInternal();
 
-  void append_bytes(char *buf, int len);
   void append_block_internal(IOBufferBlock * block);
 
   virtual void free();
@@ -56,8 +55,6 @@ public:
   uint64_t pktSendFinishTime;
   uint64_t pktLength;
 
-  bool isReliabilityPkt;
-
   int reqGenerationNum;
   ink_hrtime delivery_time;   // when to deliver packet
   ink_hrtime arrival_time;    // when packet arrived
@@ -78,7 +75,7 @@ inkcoreapi extern ClassAllocator<UDPPacketInternal> udpPacketAllocator;
 
 TS_INLINE
 UDPPacketInternal::UDPPacketInternal()
-  : pktSendStartTime(0), pktSendFinishTime(0), pktLength(0), isReliabilityPkt(false),
+  : pktSendStartTime(0), pktSendFinishTime(0), pktLength(0),
     reqGenerationNum(0), delivery_time(0), arrival_time(0), cont(NULL) , conn(NULL)
 #if defined(PACKETQUEUE_IMPL_AS_PQLIST) || defined(PACKETQUEUE_IMPL_AS_RING)
   ,in_the_priority_queue(0), in_heap(0)
@@ -106,24 +103,6 @@ UDPPacketInternal::free()
 }
 
 TS_INLINE void
-UDPPacketInternal::append_bytes(char *buf, int len)
-{
-  IOBufferData *d = NULL;
-  if (buf) {
-    d = new_xmalloc_IOBufferData(buf, len);
-    append_block(new_IOBufferBlock(d, len));
-  }
-}
-
-TS_INLINE void
-UDPPacket::setReliabilityPkt()
-{
-  UDPPacketInternal *p = (UDPPacketInternal *) this;
-
-  p->isReliabilityPkt = true;
-}
-
-TS_INLINE void
 UDPPacket::append_block(IOBufferBlock * block)
 {
   UDPPacketInternal *p = (UDPPacketInternal *) this;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f7da6934/iocore/net/UnixUDPNet.cc
----------------------------------------------------------------------
diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc
index c1e839d..a20c93f 100644
--- a/iocore/net/UnixUDPNet.cc
+++ b/iocore/net/UnixUDPNet.cc
@@ -48,7 +48,6 @@ EventType ET_UDP;
 UDPNetProcessorInternal udpNetInternal;
 UDPNetProcessor &udpNet = udpNetInternal;
 
-uint64_t g_udp_bytesPending;
 int32_t g_udp_periodicCleanupSlots;
 int32_t g_udp_periodicFreeCancelledPkts;
 int32_t g_udp_numSendRetries;
@@ -630,7 +629,7 @@ Lerror:
 
 // send out all packets that need to be sent out as of time=now
 UDPQueue::UDPQueue()
-  : last_report(0), last_service(0), last_byteperiod(0), packets(0), added(0)
+  : last_report(0), last_service(0), packets(0), added(0)
 {
 }
 
@@ -682,10 +681,6 @@ UDPQueue::service(UDPNetHandler * nh)
       p = stk.pop();
       ink_assert(p->link.prev == NULL);
       ink_assert(p->link.next == NULL);
-      if (p->isReliabilityPkt) {
-        reliabilityPktQueue.enqueue(p);
-        continue;
-      }
       // insert into our queue.
       Debug("udp-send", "Adding %p", p);
       pktLen = p->getPktLength();
@@ -700,13 +695,11 @@ UDPQueue::service(UDPNetHandler * nh)
       p->conn->lastPktStartTime = p->pktSendStartTime;
       p->delivery_time = p->pktSendStartTime;
 
-      g_udp_bytesPending += pktLen;
       G_inkPipeInfo.addPacket(p, now);
     }
   }
 
   if ((now - lastPrintTime) > ink_hrtime_from_sec(30)) {
-    Debug("udp-pending-packets", "udp bytes pending: %" PRId64 "", g_udp_bytesPending);
     Debug("udp-sched-jitter", "avg. udp sched jitter: %f", (double) schedJitter / numTimesSched);
     schedJitter = 0;
     numTimesSched = 0;
@@ -731,8 +724,6 @@ UDPQueue::SendPackets()
   UDPPacketInternal *p;
   static ink_hrtime lastCleanupTime = ink_get_hrtime_internal();
   ink_hrtime now = ink_get_hrtime_internal();
-  // ink_hrtime send_threshold_time = now + HRTIME_MSECONDS(5);
-  // send packets for SLOT_TIME per attempt
   ink_hrtime send_threshold_time = now + SLOT_TIME;
   int32_t bytesThisSlot = INT_MAX, bytesUsed = 0;
   int32_t bytesThisPipe, sentOne;
@@ -744,9 +735,6 @@ UDPQueue::SendPackets()
 
   while ((p = reliabilityPktQueue.dequeue()) != NULL) {
     pktLen = p->getPktLength();
-    g_udp_bytesPending -= pktLen;
-    p->conn->nBytesDone += pktLen;
-
     if (p->conn->shouldDestroy())
       goto next_pkt_3;
     if (p->conn->GetSendGenerationNumber() != p->reqGenerationNum)
@@ -770,7 +758,6 @@ sendPackets:
   while ((bytesThisPipe > 0) && (G_inkPipeInfo.firstPacket(send_threshold_time))) {
     p = G_inkPipeInfo.getFirstPacket();
     pktLen = p->getPktLength();
-    g_udp_bytesPending -= pktLen;
 
     if (p->conn->shouldDestroy())
       goto next_pkt;
@@ -790,7 +777,7 @@ sendPackets:
 
   bytesThisSlot -= bytesUsed;
 
-  if ((bytesThisSlot > 0) && (sentOne)) {
+  if ((bytesThisSlot > 0) && sentOne) {
     // redistribute the slack...
     now = ink_get_hrtime_internal();
     if (G_inkPipeInfo.firstPacket(now) == NULL) {
@@ -799,15 +786,8 @@ sendPackets:
     goto sendPackets;
   }
 
-  if ((g_udp_periodicFreeCancelledPkts) &&
-      (now - lastCleanupTime > ink_hrtime_from_sec(g_udp_periodicFreeCancelledPkts))) {
-    uint64_t nbytes = g_udp_bytesPending;
-    ink_hrtime startTime = ink_get_hrtime_internal(), endTime;
-
+  if ((g_udp_periodicFreeCancelledPkts) && (now - lastCleanupTime > ink_hrtime_from_sec(g_udp_periodicFreeCancelledPkts))) {
     G_inkPipeInfo.FreeCancelledPackets(g_udp_periodicCleanupSlots);
-    endTime = ink_get_hrtime_internal();
-    Debug("udp-pending-packets", "Did cleanup of %d buckets: %" PRId64 " bytes in %" PRId64 " m.sec",
-          g_udp_periodicCleanupSlots, nbytes - g_udp_bytesPending, (int64_t)ink_hrtime_to_msec(endTime - startTime));
     lastCleanupTime = now;
   }
 }
@@ -821,11 +801,9 @@ UDPQueue::SendUDPPacket(UDPPacketInternal * p, int32_t pktLen)
   int real_len = 0;
   int n, count, iov_len = 0;
 
-  if (!p->isReliabilityPkt) {
-    p->conn->lastSentPktStartTime = p->delivery_time;
-  }
-
+  p->conn->lastSentPktStartTime = p->delivery_time;
   Debug("udp-send", "Sending %p", p);
+
 #if !defined(solaris)
   msg.msg_control = 0;
   msg.msg_controllen = 0;
@@ -852,7 +830,7 @@ UDPQueue::SendUDPPacket(UDPPacketInternal * p, int32_t pktLen)
       // send succeeded or some random error happened.
       break;
     if (errno == EAGAIN) {
-      count++;
+      ++count;
       if ((g_udp_numSendRetries > 0) && (count >= g_udp_numSendRetries)) {
         // tried too many times; give up
         Debug("udpnet", "Send failed: too many retries");


[29/50] git commit: TS-1067 Remove InkSinglePipeInfo and turn it into a single queue

Posted by zw...@apache.org.
TS-1067 Remove InkSinglePipeInfo and turn it into a single queue


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

Branch: refs/heads/3.3.x
Commit: 0d3872a6a3187064c5038c1f2af7c5003cf50d40
Parents: 0c57ad7
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Mar 26 11:07:14 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

----------------------------------------------------------------------
 iocore/net/P_UDPNet.h    |   33 +--------------------------------
 iocore/net/UnixUDPNet.cc |   39 +++++++++++----------------------------
 proxy/Main.cc            |    4 ----
 3 files changed, 12 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0d3872a6/iocore/net/P_UDPNet.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_UDPNet.h b/iocore/net/P_UDPNet.h
index 44917f2..bf0d67d 100644
--- a/iocore/net/P_UDPNet.h
+++ b/iocore/net/P_UDPNet.h
@@ -75,7 +75,6 @@ public:
   ink_hrtime last_report;
   ink_hrtime last_service;
   ink_hrtime last_byteperiod;
-  int bytesSent;
   int packets;
   int added;
 
@@ -343,36 +342,6 @@ get_UDPNetHandler(EThread * t)
 }
 
 // All of this stuff is for UDP egress b/w management
-struct InkSinglePipeInfo
-{
-  InkSinglePipeInfo()
-  {
-    wt = 0.0;
-    bwLimit = 0;
-    count = 0;
-    bytesSent = pktsSent = 0;
-    bwAlloc = 0;
-    bwUsed = 0.0;
-    queue = NEW(new PacketQueue());
-  };
-
-  ~InkSinglePipeInfo() {
-    delete queue;
-  }
-
-  double wt;
-  // all are in bps (bits per sec.) so that we can do ink_atomic_increment
-  int64_t bwLimit;
-  int64_t bwAlloc;
-  // this is in Mbps
-  double bwUsed;
-  IpAddr destIP;
-  uint32_t count;
-  uint64_t bytesSent;
-  uint64_t pktsSent;
-  PacketQueue *queue;
-};
-
-extern InkSinglePipeInfo G_inkPipeInfo;
+extern PacketQueue G_inkPipeInfo;
 
 #endif //__P_UDPNET_H_

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0d3872a6/iocore/net/UnixUDPNet.cc
----------------------------------------------------------------------
diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc
index e0e3cd7..fc94acc 100644
--- a/iocore/net/UnixUDPNet.cc
+++ b/iocore/net/UnixUDPNet.cc
@@ -59,7 +59,7 @@ int32_t g_udp_numSendRetries;
 // Public functions
 // See header for documentation
 //
-InkSinglePipeInfo G_inkPipeInfo;
+PacketQueue G_inkPipeInfo;
 
 int G_bwGrapherFd;
 sockaddr_in6 G_bwGrapherLoc;
@@ -630,7 +630,7 @@ Lerror:
 
 // send out all packets that need to be sent out as of time=now
 UDPQueue::UDPQueue()
-  : last_report(0), last_service(0), last_byteperiod(0), bytesSent(0), packets(0), added(0)
+  : last_report(0), last_service(0), last_byteperiod(0), packets(0), added(0)
 {
 }
 
@@ -710,7 +710,7 @@ UDPQueue::service(UDPNetHandler * nh)
       p->conn->nBytesTodo += pktLen;
 
       g_udp_bytesPending += pktLen;
-      G_inkPipeInfo.queue->addPacket(p, now);
+      G_inkPipeInfo.addPacket(p, now);
     }
   }
 
@@ -722,27 +722,11 @@ UDPQueue::service(UDPNetHandler * nh)
     lastPrintTime = now;
   }
 
-  G_inkPipeInfo.queue->advanceNow(now);
+  G_inkPipeInfo.advanceNow(now);
   SendPackets();
 
   timeSpent = ink_hrtime_to_msec(now - last_report);
   if (timeSpent > 10000) {
-    double bw, totalBw;
-
-    if (bytesSent > 0)
-      totalBw = (bytesSent * 8.0 * 1000.0) / (timeSpent * 1024.0 * 1024.0);
-    else
-      totalBw = 1.0;
-
-    // bw is in Mbps
-    bw = (G_inkPipeInfo.bytesSent * 8.0 * 1000.0) / (timeSpent * 1024.0 * 1024.0);
-
-    // use a weighted estimator of current usage
-    G_inkPipeInfo.bwUsed = (4.0 * G_inkPipeInfo.bwUsed / 5.0) + (bw / 5.0);
-    G_inkPipeInfo.bytesSent = 0;
-    G_inkPipeInfo.pktsSent = 0;
-
-    bytesSent = 0;
     last_report = now;
     added = 0;
     packets = 0;
@@ -792,10 +776,10 @@ UDPQueue::SendPackets()
 sendPackets:
   sentOne = false;
   send_threshold_time = now + SLOT_TIME;
-  bytesThisPipe = (int32_t) (bytesThisSlot * G_inkPipeInfo.wt);
+  bytesThisPipe = (int32_t)bytesThisSlot;
 
-  while ((bytesThisPipe > 0) && (G_inkPipeInfo.queue->firstPacket(send_threshold_time))) {
-    p = G_inkPipeInfo.queue->getFirstPacket();
+  while ((bytesThisPipe > 0) && (G_inkPipeInfo.firstPacket(send_threshold_time))) {
+    p = G_inkPipeInfo.getFirstPacket();
     pktLen = p->getPktLength();
     g_udp_bytesPending -= pktLen;
 
@@ -806,7 +790,6 @@ sendPackets:
     if (p->conn->GetSendGenerationNumber() != p->reqGenerationNum)
       goto next_pkt;
 
-    G_inkPipeInfo.bytesSent += pktLen;
     SendUDPPacket(p, pktLen);
     bytesUsed += pktLen;
     bytesThisPipe -= pktLen;
@@ -823,8 +806,8 @@ sendPackets:
   if ((bytesThisSlot > 0) && (sentOne)) {
     // redistribute the slack...
     now = ink_get_hrtime_internal();
-    if (G_inkPipeInfo.queue->firstPacket(now) == NULL) {
-      G_inkPipeInfo.queue->advanceNow(now);
+    if (G_inkPipeInfo.firstPacket(now) == NULL) {
+      G_inkPipeInfo.advanceNow(now);
     }
     goto sendPackets;
   }
@@ -834,7 +817,7 @@ sendPackets:
     uint64_t nbytes = g_udp_bytesPending;
     ink_hrtime startTime = ink_get_hrtime_internal(), endTime;
 
-    G_inkPipeInfo.queue->FreeCancelledPackets(g_udp_periodicCleanupSlots);
+    G_inkPipeInfo.FreeCancelledPackets(g_udp_periodicCleanupSlots);
     endTime = ink_get_hrtime_internal();
     Debug("udp-pending-packets", "Did cleanup of %d buckets: %" PRId64 " bytes in %" PRId64 " m.sec",
           g_udp_periodicCleanupSlots, nbytes - g_udp_bytesPending, (int64_t)ink_hrtime_to_msec(endTime - startTime));
@@ -864,7 +847,7 @@ UDPQueue::SendUDPPacket(UDPPacketInternal * p, int32_t pktLen)
   msg.msg_name = (caddr_t) & p->to;
   msg.msg_namelen = sizeof(p->to);
   iov_len = 0;
-  bytesSent += pktLen;
+
   for (b = p->chain; b != NULL; b = b->next) {
     iov[iov_len].iov_base = (caddr_t) b->start();
     iov[iov_len].iov_len = b->size();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0d3872a6/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index dfde9c8..addbeeb 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -1521,10 +1521,6 @@ main(int argc, char **argv)
   TS_ReadConfigInteger(history_info_enabled, "proxy.config.history_info_enabled");
   TS_ReadConfigInteger(res_track_memory, "proxy.config.res_track_memory");
 
-  // This was the default when we had no bandwidth_mgmt.filename to load
-  // but I don't know for sure if we still need this.
-  G_inkPipeInfo.wt = 1.0;
-
   init_http_header();
 
   // Sanity checks


[04/50] git commit: TS-1713: SRV support refine

Posted by zw...@apache.org.
TS-1713: SRV support refine

the currenty SRV supporting in the DNS is not complete, and here is
a full refine of the old codes, as a side affect we also bump the
HostDB database version to 3.0, and increase the disk spaces from
32MB to 200MB:
CONFIG proxy.config.hostdb.storage_size INT 200M

*******CAUTION******
YOU ARE WARNED THAT FAIL TO ADJUST THE hostdb.storage_size CAN NOT
START THE SERVER PROCESS PROPERLY!!


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

Branch: refs/heads/3.3.x
Commit: 9e57b8a5d168ccb0382e30769a7ebfe2eeb1d088
Parents: 27182c5
Author: weijin <ta...@taobao.com>
Authored: Tue Apr 2 10:52:54 2013 +0800
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:42 2013 -0600

----------------------------------------------------------------------
 iocore/dns/DNS.cc                      |   39 +++--
 iocore/dns/Makefile.am                 |    1 -
 iocore/dns/SRV.cc                      |  161 ------------------
 iocore/dns/SRV.h                       |  110 ++-----------
 iocore/hostdb/HostDB.cc                |  238 +++++++++++++++++----------
 iocore/hostdb/I_HostDBProcessor.h      |  123 +++++++--------
 iocore/hostdb/P_HostDBProcessor.h      |   80 +++++++++-
 proxy/config/records.config.default.in |    2 +-
 proxy/http/HttpSM.cc                   |  163 +++++++++++++------
 proxy/http/HttpTransact.cc             |  140 ++--------------
 proxy/http/HttpTransact.h              |   15 ++-
 11 files changed, 460 insertions(+), 612 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e57b8a5/iocore/dns/DNS.cc
----------------------------------------------------------------------
diff --git a/iocore/dns/DNS.cc b/iocore/dns/DNS.cc
index a6f686d..8c85481 100644
--- a/iocore/dns/DNS.cc
+++ b/iocore/dns/DNS.cc
@@ -794,7 +794,6 @@ DNSHandler::recv_dns(int event, Event *e)
         if (dnsc->num == name_server)
           received_one(name_server);
       }
-      hostent_cache = protect_hostent.to_ptr();
     }
   }
 }
@@ -1358,8 +1357,10 @@ dns_process(DNSHandler *handler, HostEnt *buf, int len)
     u_char *cp = ((u_char *) h) + HFIXEDSZ;
     u_char *eom = (u_char *) h + len;
     int n;
-    unsigned char *srv[50];
-    int num_srv = 0;
+    ink_debug_assert(buf->srv_hosts.srv_host_count == 0 && buf->srv_hosts.srv_hosts_length == 0);
+    buf->srv_hosts.srv_host_count = 0;
+    buf->srv_hosts.srv_hosts_length = 0;
+    int &num_srv = buf->srv_hosts.srv_host_count;
     int rname_len = -1;
 
     //
@@ -1518,31 +1519,37 @@ dns_process(DNSHandler *handler, HostEnt *buf, int len)
           buflen -= n;
         }
       } else if (type == T_SRV) {
+        if (num_srv >= HOST_DB_MAX_ROUND_ROBIN_INFO)
+          break;
         cp = here;              /* hack */
         int strlen = dn_skipname(cp, eom);
         cp += strlen;
-        srv[num_srv] = cp;
+        const unsigned char *srv_off = cp;
         cp += SRV_FIXEDSZ;
         cp += dn_skipname(cp, eom);
         here = cp;              /* hack */
-        char srvname[MAXDNAME];
-        int r = ink_ns_name_ntop(srv[num_srv] + SRV_SERVER, srvname, MAXDNAME);
+        SRV *srv = &buf->srv_hosts.hosts[num_srv];
+        int r = ink_ns_name_ntop(srv_off + SRV_SERVER, srv->host, MAXDNAME);
         if (r <= 0) {
           /* FIXME: is this really an error? or just a continue; */
           ++error;
           goto Lerror;
         }
         Debug("dns_srv", "Discovered SRV record [from NS lookup] with cost:%d weight:%d port:%d with host:%s",
-              ink_get16(srv[num_srv] + SRV_COST),
-              ink_get16(srv[num_srv] + SRV_WEIGHT), ink_get16(srv[num_srv] + SRV_PORT), srvname);
-
-        SRV *s = SRVAllocator.alloc();
-        s->setPort(ink_get16(srv[num_srv] + SRV_PORT));
-        s->setPriority(ink_get16(srv[num_srv] + SRV_COST));
-        s->setWeight(ink_get16(srv[num_srv] + SRV_WEIGHT));
-        s->setHost(srvname);
-
-        buf->srv_hosts.insert(s);
+            ink_get16(srv_off + SRV_COST),
+            ink_get16(srv_off + SRV_WEIGHT), ink_get16(srv_off + SRV_PORT), srv->host);
+
+        srv->port = ink_get16(srv_off + SRV_PORT);
+        srv->priority = ink_get16(srv_off + SRV_COST);
+        srv->weight = ink_get16(srv_off + SRV_WEIGHT);
+        srv->host_len = r;
+        srv->host[r-1] = '\0';
+        srv->key = makeHostHash(srv->host);
+
+        if (srv->host[0] != '\0')
+          buf->srv_hosts.srv_hosts_length += r;
+        else
+          continue;
         ++num_srv;
       } else if (is_addr_query(type)) {
         if (answer) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e57b8a5/iocore/dns/Makefile.am
----------------------------------------------------------------------
diff --git a/iocore/dns/Makefile.am b/iocore/dns/Makefile.am
index c203dfb..300af79 100644
--- a/iocore/dns/Makefile.am
+++ b/iocore/dns/Makefile.am
@@ -52,7 +52,6 @@ libinkdns_a_SOURCES = \
   P_SplitDNS.h \
   P_SplitDNSProcessor.h \
   SplitDNS.cc \
-  SRV.cc \
   SRV.h \
   Inline.cc
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e57b8a5/iocore/dns/SRV.cc
----------------------------------------------------------------------
diff --git a/iocore/dns/SRV.cc b/iocore/dns/SRV.cc
deleted file mode 100644
index 37dd480..0000000
--- a/iocore/dns/SRV.cc
+++ /dev/null
@@ -1,161 +0,0 @@
-/** @file
-
-  Support for SRV records
-
-  @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.
-
-  @section description
-        Support for SRV records
-
-        http://www.faqs.org/rfcs/rfc2782.html
-        http://www.nongnu.org/ruli/
-        http://libsrv.cvs.sourceforge.net/libsrv/libsrv/src/libsrv.c
- */
-
-
-#include "P_DNS.h"
-
-struct HostDBRoundRobin;
-
-ClassAllocator<SRV> SRVAllocator("SRVAllocator");
-
-/*
-To select a target to be contacted next, arrange all SRV RRs
-(that have not been ordered yet) in any order, except that all
-those with weight 0 are placed at the beginning of the list.
-
-Compute the sum of the weights of those RRs, and with each RR
-associate the running sum in the selected order. Then choose a
-uniform random number between 0 and the sum computed
-(inclusive), and select the RR whose running sum value is the
-first in the selected order which is greater than or equal to
-the random number selected. The target host specified in the
-selected SRV RR is the next one to be contacted by the client.
-Remove this SRV RR from the set of the unordered SRV RRs and
-apply the described algorithm to the unordered SRV RRs to select
-the next target host.  Continue the ordering process until there
-are no unordered SRV RRs.  This process is repeated for each
-Priority.
-*/
-
-static InkRand SRVRand(55378008);
-
-void
-SRVHosts::getWeightedHost(char *ret_val)
-{
-  int a_prev;
-  int k = 0;
-  int accum = 0;
-  unsigned int pri = 0;
-  SRV *i;
-  //InkRand x(time(NULL));
-  int tmp[1024];
-  int j = 0;
-  int v;
-  uint32_t xx;
-
-  if (hosts.empty() || getCount() == 0) {
-    goto err;
-  }
-
-  /* Step 1/2 Sort based on 'priority': handled by operator<
-   */
-
-  hosts.sort();
-
-  /*
-   * Step 2/2: Select SRV RRs by random weighted order
-   */
-
-  //get lowest priority (now sorted)
-  i = hosts.head;
-
-  if (!i) {
-    goto err;
-  }
-  //Get current priority
-  pri = i->getPriority();
-  //Accumulate weight sum for priority
-
-  while (i != NULL && pri == i->getPriority()) {
-    a_prev = accum;
-    accum += i->getWeight();
-    for (j = a_prev; j < accum; j++) {
-      tmp[j] = k;
-    }
-    i = i->link.next;
-    k++;
-  }
-
-  Debug("dns_srv", "accum=%d for priority=%d", accum, pri);
-
-  if (!accum) {
-    Debug("dns_srv", "Accumulator was 0. eek.");
-    goto err;
-  }
-  //Pick random number: 0..accum
-  xx = SRVRand.random() % accum;
-
-  Debug("dns_srv", "picked %d as a random number", xx);
-
-  i = hosts.head;
-  v = tmp[xx];
-  j = 0;
-  while (j < v) {
-    i = i->link.next;
-    j++;
-  }
-  Debug("dns_srv", "using SRV record of: pri: %d, wei: %d, port: %d, host: %s",
-        i->getPriority(), i->getWeight(), i->getPort(), i->getHost());
-
-  ink_strlcpy(ret_val, i->getHost(), MAXDNAME);
-  if (strcmp(ret_val, "") == 0 || strcmp(ret_val, ".") == 0) {
-    goto err;
-  }
-  return;
-err:
-  Debug("dns_srv", "there was a problem figuring out getWeightedHost() -- we are returning a blank SRV host");
-  ret_val[0] = '\0';
-  return;
-}
-
-SRVHosts::SRVHosts(HostDBInfo * info)
-{
-  hosts.clear();
-  srv_host_count = 0;
-  if (!info)
-    return;
-  HostDBRoundRobin *rr_data = info->rr();
-
-  if (!rr_data) {
-    return;
-  }
-
-  for (unsigned int i = 0; i < info->srv_count; i++) {
-    /* get the RR data */
-    SRV *s = SRVAllocator.alloc();
-    HostDBInfo nfo = rr_data->info[i];
-    s->setPort(nfo.srv_port);
-    s->setPriority(nfo.srv_priority);
-    s->setWeight(nfo.srv_weight);
-    s->setHost(&rr_data->rr_srv_hosts[i][0]);
-    insert(s);
-  }
-  return;
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e57b8a5/iocore/dns/SRV.h
----------------------------------------------------------------------
diff --git a/iocore/dns/SRV.h b/iocore/dns/SRV.h
index b0f5191..4393d7e 100644
--- a/iocore/dns/SRV.h
+++ b/iocore/dns/SRV.h
@@ -29,128 +29,46 @@
 
 struct HostDBInfo;
 
+#define HOST_DB_MAX_ROUND_ROBIN_INFO  16
 #define RAND_INV_RANGE(r) ((int) ((RAND_MAX + 1) / (r)))
 
-class SRV
+struct SRV
 {
-private:
   unsigned int weight;
   unsigned int port;
   unsigned int priority;
   unsigned int ttl;
+  unsigned int host_len;
+  unsigned int key;
   char host[MAXDNAME];
 
-public:
-  LINK(SRV, link);
-  SRV():weight(0), port(0), priority(0), ttl(0)
+  SRV():weight(0), port(0), priority(0), ttl(0), host_len(0), key(0)
   {
-    memset(host, 0, MAXDNAME);
+    host[0] = '\0';
   }
-
-  unsigned int getWeight()
-  {
-    return weight;
-  }
-  unsigned int getPriority() const
-  {
-    return priority;
-  }
-  unsigned int getPort()
-  {
-    return port;
-  }
-  unsigned int getTTL()
-  {
-    return ttl;
-  }
-  char *getHost()
-  {
-    return &host[0];
-  }
-
-  void setWeight(int w)
-  {
-    weight = w;
-  }
-  void setTTL(int t)
-  {
-    ttl = t;
-  }
-  void setPort(int p)
-  {
-    port = p;
-  }
-  void setPriority(int p)
-  {
-    priority = p;
-  }
-  void setHost(const char *h)
-  {
-    if (!h) {
-      Debug("dns_srv", "SRV::setHost() was passed a NULL host -- better check your code)");
-      host[0] = '\0';
-      return;
-    }
-    if (*h == '\0') {
-      Debug("dns_srv", "SRV::setHost() was passed a blank host -- better check what might have happened.");
-      host[0] = '\0';
-      return;
-    }
-    ink_strlcpy(host, h, sizeof(host));
-  }
-
 };
 
-TS_INLINE bool
-operator<(const SRV & left, const SRV & right)
+inline bool
+operator<(const SRV &left, const SRV &right)
 {
-  return (left.getPriority() < right.getPriority());    /* lower priorities first :) */
+  // lower priorities first, then the key
+  return (left.priority == right.priority) ? (left.key < right.key) : (left.priority < right.priority);
 }
 
-extern ClassAllocator<SRV> SRVAllocator;
 
-class SRVHosts
+struct SRVHosts
 {
-private:
-  SortableQueue<SRV> hosts;
   int srv_host_count;
+  int srv_hosts_length;
+  SRV hosts[HOST_DB_MAX_ROUND_ROBIN_INFO];
 
-public:
    ~SRVHosts()
   {
-    SRV *i;
-    while ((i = hosts.dequeue())) {
-      Debug("dns_srv", "freeing srv entry inside SRVHosts::~SRVHosts");
-      SRVAllocator.free(i);
-    }
   }
 
-  SRVHosts():srv_host_count(0)
+  SRVHosts():srv_host_count(0), srv_hosts_length(0)
   {
-    hosts.clear();
-  }
-
-  SortableQueue<SRV> *getHosts() {
-    return &hosts;
   }
-
-  void getWeightedHost(char *);
-
-  bool insert(SRV * rec)
-  {
-    hosts.enqueue(rec);
-    srv_host_count++;
-    return true;
-  }
-
-  int getCount()
-  {
-    return srv_host_count;
-  }
-
-  /* convert this HostDBInfo to an SRVHosts */
-  SRVHosts(HostDBInfo * info);
-
 };
 
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e57b8a5/iocore/hostdb/HostDB.cc
----------------------------------------------------------------------
diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc
index 1d9ef72..8ba573c 100644
--- a/iocore/hostdb/HostDB.cc
+++ b/iocore/hostdb/HostDB.cc
@@ -78,6 +78,15 @@ HostDBCache hostDB;
 static  Queue <HostDBContinuation > remoteHostDBQueue[MULTI_CACHE_PARTITIONS];
 #endif
 
+char *
+HostDBInfo::srvname(HostDBRoundRobin *rr)
+{
+  if (!is_srv || !data.srv.srv_offset)
+    return NULL;
+  ink_assert(this - rr->info >= 0 && this - rr->info < rr->n && data.srv.srv_offset < rr->length);
+  return (char *) rr + data.srv.srv_offset;
+}
+
 static inline int
 corrupt_debugging_callout(HostDBInfo * e, RebuildMC & r)
 {
@@ -562,24 +571,17 @@ make_md5(INK_MD5 & md5, const char *hostname, int len, int port, char const* pDN
 
 
 static bool
-reply_to_cont(Continuation * cont, HostDBInfo * ar)
+reply_to_cont(Continuation * cont, HostDBInfo * ar, bool is_srv = false)
 {
   const char *reason = "none";
   HostDBInfo *r = ar;
 
-  if (r == NULL) {
-    cont->handleEvent(EVENT_HOST_DB_LOOKUP, NULL);
+  if (r == NULL || r->is_srv != is_srv || r->failed()) {
+    cont->handleEvent(is_srv ? EVENT_SRV_LOOKUP : EVENT_HOST_DB_LOOKUP, NULL);
     return false;
   }
 
-  if (r->failed()) {
-    if (r->is_srv && r->srv_count) {
-      cont->handleEvent(EVENT_SRV_LOOKUP, NULL);
-      return false;
-    }
-    cont->handleEvent(EVENT_HOST_DB_LOOKUP, NULL);
-    return false;
-  } else {
+  {
     if (r->reverse_dns) {
       if (!r->hostname()) {
         reason = "missing hostname";
@@ -588,7 +590,8 @@ reply_to_cont(Continuation * cont, HostDBInfo * ar)
       }
       Debug("hostdb", "hostname = %s", r->hostname());
     }
-    if (r->round_robin) {
+
+    if (!r->is_srv && r->round_robin) {
       if (!r->rr()) {
         reason = "missing round-robin";
         ink_assert(!"missing round-robin");
@@ -597,26 +600,15 @@ reply_to_cont(Continuation * cont, HostDBInfo * ar)
       ip_text_buffer ipb;
       Debug("hostdb", "RR of %d with %d good, 1st IP = %s", r->rr()->n, r->rr()->good, ats_ip_ntop(r->ip(), ipb, sizeof ipb));
     }
-    if (r->is_srv && r->srv_count) {
-      cont->handleEvent(EVENT_SRV_LOOKUP, r);
-      if (!r->full)
-        goto Ldelete;
-      return true;
-    } else if (r->is_srv) {
-      /* failure case where this is an SRV lookup, but we got no records back  -- this is handled properly in process_srv_info */
-      cont->handleEvent(EVENT_SRV_LOOKUP, r);
-      return true;
-    }
-    cont->handleEvent(EVENT_HOST_DB_LOOKUP, r);
+
+    cont->handleEvent(is_srv ? EVENT_SRV_LOOKUP : EVENT_HOST_DB_LOOKUP, r);
+
     if (!r->full)
       goto Ldelete;
     return true;
   }
 Lerror:
-  if (r->is_srv && r->srv_count) {
-    cont->handleEvent(EVENT_SRV_LOOKUP, r);
-  }
-  cont->handleEvent(EVENT_HOST_DB_LOOKUP, NULL);
+  cont->handleEvent(is_srv ? EVENT_SRV_LOOKUP : EVENT_HOST_DB_LOOKUP, NULL);
 Ldelete:
   Warning("bogus entry deleted from HostDB: %s", reason);
   hostDB.delete_block(ar);
@@ -904,7 +896,7 @@ HostDBProcessor::getSRVbyname_imm(Continuation * cont, process_srv_info_pfn proc
 
   md5.host_name = hostname;
   md5.host_len = hostname ? (len ? len : strlen(hostname)) : 0;
-  md5.port = opt.port;
+  md5.port = 0;
   md5.db_mark = HOSTDB_MARK_SRV;
   md5.refresh();
 
@@ -1040,20 +1032,33 @@ HostDBProcessor::getbyname_imm(Continuation * cont, process_hostdb_info_pfn proc
 
 
 static void
-do_setby(HostDBInfo * r, HostDBApplicationInfo * app, const char *hostname, IpAddr const& ip)
+do_setby(HostDBInfo * r, HostDBApplicationInfo * app, const char *hostname, IpAddr const& ip, bool is_srv = false)
 {
   HostDBRoundRobin *rr = r->rr();
 
+  if (is_srv && (!r->is_srv || !rr))
+    return;
+
   if (rr) {
-    ink_assert(hostname);
-    for (int i = 0; i < rr->n; i++) {
-      if (rr->info[i].ip() == ip) {
-        Debug("hostdb", "immediate setby for %s", hostname ? hostname : "<addr>");
-        rr->info[i].app.allotment.application1 = app->allotment.application1;
-        rr->info[i].app.allotment.application2 = app->allotment.application2;
-        return;
+    if (is_srv) {
+      uint32_t key = makeHostHash(hostname);
+      for (int i = 0; i < rr->n; i++) {
+        if (key == rr->info[i].data.srv.key && !strcmp(hostname, rr->info[i].srvname(rr))) {
+          Debug("hostdb", "immediate setby for %s", hostname);
+          rr->info[i].app.allotment.application1 = app->allotment.application1;
+          rr->info[i].app.allotment.application2 = app->allotment.application2;
+          return;
+        }
+      }
+    } else
+      for (int i = 0; i < rr->n; i++) {
+        if (rr->info[i].ip() == ip) {
+          Debug("hostdb", "immediate setby for %s", hostname ? hostname : "<addr>");
+          rr->info[i].app.allotment.application1 = app->allotment.application1;
+          rr->info[i].app.allotment.application2 = app->allotment.application2;
+          return;
+        }
       }
-    }
   } else {
     if (r->reverse_dns || (!r->round_robin && ip == r->ip())) {
       Debug("hostdb", "immediate setby for %s", hostname ? hostname : "<addr>");
@@ -1100,7 +1105,30 @@ HostDBProcessor::setby(const char *hostname, int len, sockaddr const* ip, HostDB
   thread->schedule_in(c, MUTEX_RETRY_DELAY);
 }
 
+void
+HostDBProcessor::setby_srv(const char *hostname, int len, const char *target, HostDBApplicationInfo * app)
+{
+  if (!hostdb_enable || !hostname || !target)
+      return;
 
+  HostDBMD5 md5;
+  md5.host_name = hostname;
+  md5.host_len = len ? len : strlen(hostname);
+  md5.port = 0;
+  md5.db_mark = HOSTDB_MARK_SRV;
+  md5.refresh();
+
+  // Create a continuation to do a deaper probe in the background
+
+  HostDBContinuation *c = hostDBContAllocator.alloc();
+  c->init(md5);
+  strncpy(c->srv_target_name, target, MAXDNAME);
+  c->app.allotment.application1 = app->allotment.application1;
+  c->app.allotment.application2 = app->allotment.application2;
+  SET_CONTINUATION_HANDLER(c,
+      (HostDBContHandler) & HostDBContinuation::setbyEvent);
+  eventProcessor.schedule_imm(c);
+}
 int
 HostDBContinuation::setbyEvent(int event, Event * e)
 {
@@ -1109,7 +1137,7 @@ HostDBContinuation::setbyEvent(int event, Event * e)
   HostDBInfo *r = probe(mutex, md5, false);
 
   if (r)
-    do_setby(r, &app, md5.host_name, md5.ip);
+    do_setby(r, &app, md5.host_name, md5.ip, is_srv());
 
   hostdb_cont_free(this);
   return EVENT_DONE;
@@ -1254,7 +1282,9 @@ HostDBContinuation::lookup_done(IpAddr const& ip, char const* aname, bool around
     }
     i = insert(hostdb_ip_fail_timeout_interval);        // currently ... 0
     i->round_robin = false;
+    i->is_srv = is_srv();
     i->reverse_dns = !is_byname() && !is_srv();
+
     i->set_failed();
   } else {
     switch (hostdb_ttl_mode) {
@@ -1289,22 +1319,12 @@ HostDBContinuation::lookup_done(IpAddr const& ip, char const* aname, bool around
       }
       i->is_srv = false;
     } else if (is_srv()) {
-      ats_ip_set(i->ip(), ip);
-      i->reverse_dns = false;
-
-      if (srv) {                //failed case: srv == NULL
-        i->srv_count = srv->getCount();
-      } else {
-        i->srv_count = 0;
-      }
-
-      if (i->srv_count <= 0) {
-        i->round_robin = false;
-      } else {
-        i->round_robin = true;
-      }
+      ink_debug_assert(srv && srv->srv_host_count > 0 && srv->srv_host_count <= 16 && around_robin);
 
+      i->data.srv.srv_offset = srv->srv_host_count;
+      i->reverse_dns = false;
       i->is_srv = true;
+      i->round_robin = around_robin;
 
       if (md5.host_name != aname) {
         ink_strlcpy(md5_host_name_store, aname, sizeof(md5_host_name_store));
@@ -1420,7 +1440,7 @@ HostDBContinuation::dnsEvent(int event, HostEnt * e)
     pending_action = NULL;
 
     if (is_srv()) {
-      rr = !failed && (e->srv_hosts.getCount() > 0);
+      rr = !failed && (e->srv_hosts.srv_host_count > 0);
     } else if (!failed) {
       rr = 0 != e->ent.h_addr_list[1];
     } else {
@@ -1434,13 +1454,22 @@ HostDBContinuation::dnsEvent(int event, HostEnt * e)
     if (old_r)
       old_info = *old_r;
     HostDBRoundRobin *old_rr_data = old_r ? old_r->rr() : NULL;
-
+#ifdef DEBUG
+    if (old_rr_data) {
+      for (int i = 0; i < old_rr_data->n; ++i) {
+        if (old_r->md5_high != old_rr_data->info[i].md5_high ||
+            old_r->md5_low != old_rr_data->info[i].md5_low ||
+            old_r->md5_low_low != old_rr_data->info[i].md5_low_low)
+          ink_assert(0);
+      }
+    }
+#endif
     int n = 0, nn = 0;
     void* first = 0;
     uint8_t af = e ? e->ent.h_addrtype : AF_UNSPEC; // address family
     if (rr) {
       if (is_srv() && !failed) {
-        n = e->srv_hosts.getCount();
+        n = e->srv_hosts.srv_host_count;
       } else {
         void* ptr; // tmp for current entry.
         for (
@@ -1474,7 +1503,8 @@ HostDBContinuation::dnsEvent(int event, HostEnt * e)
       if (first) ip_addr_set(tip, af, first);
       r = lookup_done(tip, md5.host_name, rr, ttl_seconds, failed ? 0 : &e->srv_hosts);
     } else if (is_srv()) {
-      if (first) ip_addr_set(tip, af, first);
+      if (!failed)
+        tip._family = AF_INET; // force the tip valid, or else the srv will fail
       r = lookup_done(tip,  /* junk: FIXME: is the code in lookup_done() wrong to NEED this? */
                       md5.host_name,     /* hostname */
                       rr,       /* is round robin, doesnt matter for SRV since we recheck getCount() inside lookup_done() */
@@ -1486,41 +1516,79 @@ HostDBContinuation::dnsEvent(int event, HostEnt * e)
       r = lookup_done(md5.ip, e->ent.h_name, false, ttl_seconds, &e->srv_hosts);
     }
 
+    ink_debug_assert(!r || (r->app.allotment.application1 == 0 && r->app.allotment.application2 == 0));
+
     if (rr) {
-      int s = HostDBRoundRobin::size(n, is_srv());
+      int s = HostDBRoundRobin::size(n, e->srv_hosts.srv_hosts_length);
       HostDBRoundRobin *rr_data = (HostDBRoundRobin *) hostDB.alloc(&r->app.rr.offset, s);
       Debug("hostdb", "allocating %d bytes for %d RR at %p %d", s, n, rr_data, r->app.rr.offset);
       if (rr_data) {
+        rr_data->length = s;
         int i = 0, ii = 0;
         if (is_srv()) {
-          SortableQueue<SRV> *q = e->srv_hosts.getHosts();
-          if (q) {
-            for (i = 0; i < n; ++i) {
-              SRV *t = q->dequeue();
-              HostDBInfo& item = rr_data->info[i];
+          int skip = 0;
+          char *pos = (char *) rr_data + sizeof(HostDBRoundRobin) + n * sizeof(HostDBInfo);
+          SRV *q[HOST_DB_MAX_ROUND_ROBIN_INFO];
+          ink_debug_assert(n <= HOST_DB_MAX_ROUND_ROBIN_INFO);
+          // sort
+          for (i = 0; i < n; ++i) {
+            q[i] = &e->srv_hosts.hosts[i];
+          }
+          for (i = 0; i < n; ++i) {
+            for (ii = i + 1; ii < n; ++ii) {
+              if (*q[ii] < *q[i]) {
+                SRV *tmp = q[i];
+                q[i] = q[ii];
+                q[ii] = tmp;
+              }
+            }
+          }
 
-              ats_ip_invalidate(item.ip());
-              item.round_robin = 0;
-              item.reverse_dns = 0;
+          for (i = 0; i < n; ++i) {
+            SRV *t = q[i];
+            HostDBInfo& item = rr_data->info[i];
+            item.round_robin = 0;
+            item.reverse_dns = 0;
+            item.is_srv = 1;
+            item.data.srv.srv_weight = t->weight;
+            item.data.srv.srv_priority = t->priority;
+            item.data.srv.srv_port = t->port;
+            item.data.srv.key = t->key;
 
-              item.srv_weight = t->getWeight();
-              item.srv_priority = t->getPriority();
-              item.srv_port = t->getPort();
+            ink_debug_assert (skip + (int) t->host_len <= e->srv_hosts.srv_hosts_length);
 
-              ink_strlcpy(rr_data->rr_srv_hosts[i], t->getHost(), MAXDNAME);
-              rr_data->rr_srv_hosts[i][MAXDNAME - 1] = '\0';
-              item.is_srv = true;
+            memcpy(pos + skip, t->host, t->host_len);
+            item.data.srv.srv_offset = (pos - (char *) rr_data) + skip;
 
-              item.full = 1;
-              item.md5_high = r->md5_high;
-              item.md5_low = r->md5_low;
-              item.md5_low_low = r->md5_low_low;
-              SRVAllocator.free(t);
-              Debug("dns_srv", "inserted SRV RR record into HostDB with TTL: %d seconds", ttl_seconds);
+            skip += t->host_len;
+
+            item.md5_high = r->md5_high;
+            item.md5_low = r->md5_low;
+            item.md5_low_low = r->md5_low_low;
+            item.full = 1;
+
+            item.app.allotment.application1 = 0;
+            item.app.allotment.application2 = 0;
+            Debug("dns_srv", "inserted SRV RR record [%s] into HostDB with TTL: %d seconds", t->host, ttl_seconds);
+          }
+          rr_data->good = rr_data->n = n;
+          rr_data->current = 0;
+
+          // restore
+          if (old_rr_data) {
+            for (i = 0; i < rr_data->n; ++i) {
+              for (ii = 0; ii < old_rr_data->n; ++ii) {
+                if (rr_data->info[i].data.srv.key == old_rr_data->info[ii].data.srv.key) {
+                  char *new_host = rr_data->info[i].srvname(rr_data);
+                  char *old_host = old_rr_data->info[ii].srvname(old_rr_data);
+                  if (!strcmp(new_host, old_host))
+                    rr_data->info[i].app = old_rr_data->info[ii].app;
+                }
+              }
             }
           }
         } else {
-          for (; ii < nn; ++ii) {
+          for (ii = 0; ii < nn; ++ii) {
             if (is_addr_valid(af, e->ent.h_addr_list[ii])) {
               HostDBInfo& item = rr_data->info[i];
               ip_addr_set(item.ip(), af, e->ent.h_addr_list[ii]);
@@ -1528,6 +1596,7 @@ HostDBContinuation::dnsEvent(int event, HostEnt * e)
               item.full = 1;
               item.round_robin = 0;
               item.reverse_dns = 0;
+              item.is_srv = 0;
               item.md5_high = r->md5_high;
               item.md5_low = r->md5_low;
               item.md5_low_low = r->md5_low_low;
@@ -1538,16 +1607,16 @@ HostDBContinuation::dnsEvent(int event, HostEnt * e)
               ++i;
             }
           }
+          rr_data->good = rr_data->n = n;
+          rr_data->current = 0;
         }
-        rr_data->good = rr_data->n = n;
-        rr_data->current = 0;
       } else {
         ink_assert(!"out of room in hostdb data area");
         Warning("out of room in hostdb for round-robin DNS data");
         r->round_robin = 0;
       }
     }
-    if (!failed && !rr)
+    if (!failed && !rr && !is_srv())
       restore_info(r, old_r, old_info, old_rr_data);
     ink_assert(!r || !r->round_robin || !r->reverse_dns);
     ink_assert(failed || !r->round_robin || r->app.rr.offset);
@@ -1579,7 +1648,7 @@ HostDBContinuation::dnsEvent(int event, HostEnt * e)
         return EVENT_CONT;
       }
       if (!action.cancelled)
-        reply_to_cont(action.continuation, r);
+        reply_to_cont(action.continuation, r, is_srv());
     }
     // wake up everyone else who is waiting
     remove_trigger_pending_dns();
@@ -1738,7 +1807,7 @@ HostDBContinuation::do_put_response(ClusterMachine * m, HostDBInfo * r, Continua
 {
   // don't remote fill round-robin DNS entries
   // if configured not to cluster them
-  if (!c && r->round_robin && !hostdb_cluster_round_robin)
+  if (!hostdb_cluster || (!c && r->round_robin && !hostdb_cluster_round_robin))
     return;
 
   HostDB_put_message msg;
@@ -2181,8 +2250,7 @@ HostDBInfo::heap_size()
     HostDBRoundRobin *r = rr();
 
     if (r)
-      // this is a bit conservative, we might want to resurect them later
-      return HostDBRoundRobin::size(r->n, this->is_srv);
+      return r->length;
   }
   return 0;
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e57b8a5/iocore/hostdb/I_HostDBProcessor.h
----------------------------------------------------------------------
diff --git a/iocore/hostdb/I_HostDBProcessor.h b/iocore/hostdb/I_HostDBProcessor.h
index 65e1418..1408810 100644
--- a/iocore/hostdb/I_HostDBProcessor.h
+++ b/iocore/hostdb/I_HostDBProcessor.h
@@ -38,6 +38,7 @@
 
 #define HOST_DB_MAX_ROUND_ROBIN_INFO         16
 
+#define HOST_DB_SRV_PREFIX "_http._tcp."
 //
 // Data
 //
@@ -59,6 +60,26 @@ extern unsigned int hostdb_ip_fail_timeout_interval;
 extern unsigned int hostdb_serve_stale_but_revalidate;
 
 
+static inline unsigned int
+makeHostHash(const char *string)
+{
+  ink_debug_assert(string && *string);
+  if (!string || *string == 0)
+    return 0;
+
+  const uint32_t InitialFNV = 2166136261U;
+  const int32_t FNVMultiple = 16777619;
+
+  uint64_t hash = InitialFNV;
+  uint32_t *p = (uint32_t *) &hash;
+  while(*string)  {
+    p[0] = p[0] ^ (toupper(*string));
+    hash = (p[1] ^ p[0]) * FNVMultiple;
+    ++string;
+  }
+  return (p[1] ^ p[0]);
+}
+
 //
 // Types
 //
@@ -116,6 +137,15 @@ union HostDBApplicationInfo
 
 struct HostDBRoundRobin;
 
+struct SRVInfo
+{
+  unsigned int srv_offset:16;
+  unsigned int srv_weight:16;
+  unsigned int srv_priority:16;
+  unsigned int srv_port:16;
+  unsigned int key;
+};
+
 struct HostDBInfo
 {
   /** Internal IP address data.
@@ -125,36 +155,12 @@ struct HostDBInfo
   sockaddr const* ip() const { return &data.ip.sa; }
 
   char *hostname();
-  char *srvname();
+  char *srvname(HostDBRoundRobin *rr);
   HostDBRoundRobin *rr();
 
   /** Indicate that the HostDBInfo is BAD and should be deleted. */
   void bad() { full = 0; }
 
-  /** Check the HostDBInfo or selected RR entry of a HostDBInfo is ok. */
-  int ok(bool byname, HostDBInfo * rr = NULL) {
-    if (rr) {
-      if (!byname ||
-          rr->md5_high != md5_high ||
-          rr->md5_low != md5_low || rr->md5_low_low != md5_low_low || rr->reverse_dns || !rr->ip())
-        goto Lbad;
-    } else if (byname) {
-      if (reverse_dns)
-        goto Lbad;
-      if (!ats_is_ip(ip()))
-        goto Lbad;
-    } else {
-      if (!reverse_dns)
-        goto Lbad;
-      if (!hostname())
-        goto Lbad;
-    }
-    return 1;
-  Lbad:
-    bad();
-    return 0;
-  }
-
   /**
     Application specific data. NOTE: We need an integral number of these
     per block. This structure is 32 bytes. (at 200k hosts = 8 Meg). Which
@@ -221,8 +227,10 @@ struct HostDBInfo
     memcpy(&data, &that.data, sizeof data);
     ip_timestamp = that.ip_timestamp;
     ip_timeout_interval = that.ip_timeout_interval;
+    is_srv = that.is_srv;
     round_robin = that.round_robin;
     reverse_dns = that.reverse_dns;
+
     app.allotment.application1 = that.app.allotment.application1;
     app.allotment.application2 = that.app.allotment.application2;
   }
@@ -235,23 +243,19 @@ struct HostDBInfo
   union {
     IpEndpoint ip; ///< IP address / port data.
     int hostname_offset; ///< Some hostname thing.
+    SRVInfo srv;
   } data;
 
-  unsigned int srv_weight:16;
-  unsigned int srv_priority:16;
-  unsigned int srv_port:16;
-  unsigned int srv_count:15;
-  unsigned int is_srv:1;
-
   unsigned int ip_timestamp;
   // limited to 0x1FFFFF (24 days)
-  unsigned int ip_timeout_interval;
+  unsigned int ip_timeout_interval:31;
 
   unsigned int full:1;
   unsigned int backed:1;        // duplicated in lower level
   unsigned int deleted:1;
   unsigned int hits:3;
 
+  unsigned int is_srv:1; // steal a bit from ip_timeout_interval
   unsigned int round_robin:1;
   unsigned int reverse_dns:1;
 
@@ -261,11 +265,15 @@ struct HostDBInfo
   uint64_t md5_high;
 
   bool failed() {
-    return !((reverse_dns && data.hostname_offset) || ats_is_ip(ip()));
+    return !((is_srv && data.srv.srv_offset) || (reverse_dns && data.hostname_offset) || ats_is_ip(ip()));
   }
   void set_failed() {
-    reverse_dns = false;
-    ats_ip_invalidate(ip());
+    if (is_srv)
+      data.srv.srv_offset = 0;
+    else if (reverse_dns)
+      data.hostname_offset = 0;
+    else
+      ats_ip_invalidate(ip());
   }
 
   void set_deleted() { deleted = 1; }
@@ -279,11 +287,6 @@ struct HostDBInfo
     md5_high = 0;
     md5_low = 0;
     md5_low_low = 0;
-    is_srv = 0;
-    srv_weight = 0;
-    srv_priority = 0;
-    srv_port = 0;
-    srv_count = 0;
   }
 
   void set_full(uint64_t folded_md5, int buckets)
@@ -307,6 +310,7 @@ struct HostDBInfo
     hits = 0;
     round_robin = 0;
     reverse_dns = 0;
+    is_srv = 0;
   }
 
   uint64_t tag() {
@@ -319,17 +323,13 @@ struct HostDBInfo
   int *heap_offset_ptr();
 
 HostDBInfo()
-  : srv_weight(0)
-  , srv_priority(0)
-  , srv_port(0)
-  , srv_count(0)
-  , is_srv(0)
-  , ip_timestamp(0)
+  : ip_timestamp(0)
   , ip_timeout_interval(0)
   , full(0)
   , backed(0)
   , deleted(0)
   , hits(0)
+  , is_srv(0)
   , round_robin(0)
   , reverse_dns(0)
   , md5_low_low(0)
@@ -352,28 +352,14 @@ struct HostDBRoundRobin
   short good;
 
   unsigned short current;
+  unsigned short length;
   ink_time_t timed_rr_ctime;
 
-  HostDBInfo info[HOST_DB_MAX_ROUND_ROBIN_INFO];
-  char rr_srv_hosts[HOST_DB_MAX_ROUND_ROBIN_INFO][MAXDNAME];
+  HostDBInfo info[];
 
-  static int size(int nn, bool using_srv)
+  static int size(int nn, int srv_len = 0)
   {
-    if (using_srv) {
-      /*     sizeof this struct
-         minus
-         unused round-robin entries [info]
-         minus
-         unused srv host data [rr_srv_hosts]
-       */
-      return (int) ((sizeof(HostDBRoundRobin)) -
-                    (sizeof(HostDBInfo) * (HOST_DB_MAX_ROUND_ROBIN_INFO - nn)) -
-                    (sizeof(char) * MAXDNAME * (HOST_DB_MAX_ROUND_ROBIN_INFO - nn)));
-    } else {
-      return (int) (sizeof(HostDBRoundRobin) -
-                    sizeof(HostDBInfo) * (HOST_DB_MAX_ROUND_ROBIN_INFO - nn) -
-                    sizeof(char) * MAXDNAME * HOST_DB_MAX_ROUND_ROBIN_INFO);
-    }
+    return INK_ALIGN((int) (sizeof(HostDBRoundRobin) + nn * sizeof(HostDBInfo) + srv_len), 8);
   }
 
   /** Find the index of @a addr in member @a info.
@@ -381,15 +367,17 @@ struct HostDBRoundRobin
   */
   int index_of(sockaddr const* addr);
   HostDBInfo *find_ip(sockaddr const* addr);
+  // Find the srv target
+  HostDBInfo *find_target(const char *target);
   /** Select the next entry after @a addr.
       @note If @a addr isn't an address in the round robin nothing is updated.
       @return The selected entry or @c NULL if @a addr wasn't present.
    */
   HostDBInfo* select_next(sockaddr const* addr);
   HostDBInfo *select_best_http(sockaddr const* client_ip, ink_time_t now, int32_t fail_window);
-
+  HostDBInfo *select_best_srv(char *target, InkRand *rand, ink_time_t now, int32_t fail_window);
   HostDBRoundRobin()
-    : n(0), good(0), current(0), timed_rr_ctime(0)
+    : n(0), good(0), current(0), length(0), timed_rr_ctime(0)
   { }
 
 };
@@ -530,6 +518,9 @@ public:
     HostDBApplicationInfo * app ///< I don't know.
   );
 
+  void setby_srv(const char *hostname, int len, const char *target,
+      HostDBApplicationInfo * app);
+
 };
 
 void run_HostDBTest();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e57b8a5/iocore/hostdb/P_HostDBProcessor.h
----------------------------------------------------------------------
diff --git a/iocore/hostdb/P_HostDBProcessor.h b/iocore/hostdb/P_HostDBProcessor.h
index 3b934d0..387d6da 100644
--- a/iocore/hostdb/P_HostDBProcessor.h
+++ b/iocore/hostdb/P_HostDBProcessor.h
@@ -78,8 +78,8 @@ inline unsigned int HOSTDB_CLIENT_IP_HASH(
 #define CONFIGURATION_HISTORY_PROBE_DEPTH   1
 
 // Bump this any time hostdb format is changed
-#define HOST_DB_CACHE_MAJOR_VERSION         2
-#define HOST_DB_CACHE_MINOR_VERSION         2
+#define HOST_DB_CACHE_MAJOR_VERSION         3
+#define HOST_DB_CACHE_MINOR_VERSION         0
 // 2.2: IP family split 2.1 : IPv6
 
 #define DEFAULT_HOST_DB_FILENAME             "host.db"
@@ -175,7 +175,7 @@ struct HostDBCache: public MultiCache<HostDBInfo>
   }
 
   // This accounts for an average of 2 HostDBInfo per DNS cache (for round-robin etc.)
-  virtual size_t estimated_heap_bytes_per_entry() const { return sizeof(HostDBInfo) * 2; }
+  virtual size_t estimated_heap_bytes_per_entry() const { return sizeof(HostDBInfo) * 2 + 512; }
 
   Queue<HostDBContinuation, Continuation::Link_link> pending_dns[MULTI_CACHE_PARTITIONS];
   Queue<HostDBContinuation, Continuation::Link_link> &pending_dns_for_hash(INK_MD5 & md5);
@@ -219,6 +219,22 @@ HostDBRoundRobin::select_next(sockaddr const* ip) {
 }
 
 inline HostDBInfo *
+HostDBRoundRobin::find_target(const char *target) {
+  bool bad = (n <= 0 || n > HOST_DB_MAX_ROUND_ROBIN_INFO || good <= 0 || good > HOST_DB_MAX_ROUND_ROBIN_INFO);
+  if (bad) {
+    ink_assert(!"bad round robin size");
+    return NULL;
+  }
+
+  uint32_t key = makeHostHash(target);
+  for (int i = 0; i < good; i++) {
+    if (info[i].data.srv.key == key && !strcmp(target, info[i].srvname(this)))
+      return &info[i];
+  }
+  return NULL;
+}
+
+inline HostDBInfo *
 HostDBRoundRobin::select_best_http(sockaddr const* client_ip, ink_time_t now, int32_t fail_window)
 {
   bool bad = (n <= 0 || n > HOST_DB_MAX_ROUND_ROBIN_INFO || good <= 0 || good > HOST_DB_MAX_ROUND_ROBIN_INFO);
@@ -295,6 +311,63 @@ HostDBRoundRobin::select_best_http(sockaddr const* client_ip, ink_time_t now, in
   }
 }
 
+inline HostDBInfo *
+HostDBRoundRobin::select_best_srv(char *target, InkRand *rand, ink_time_t now, int32_t fail_window)
+{
+  bool bad = (n <= 0 || n > HOST_DB_MAX_ROUND_ROBIN_INFO || good <= 0 || good > HOST_DB_MAX_ROUND_ROBIN_INFO);
+
+  if (bad) {
+    ink_assert(!"bad round robin size");
+    return NULL;
+  }
+
+#ifdef DEBUG
+  for (int i = 1; i < good; ++i) {
+    ink_debug_assert(info[i].data.srv.srv_priority >= info[i-1].data.srv.srv_priority);
+  }
+#endif
+
+  int i = 0, len = 0;
+  uint32_t weight = 0, p = INT32_MAX;
+  HostDBInfo *result = NULL;
+  HostDBInfo *infos[HOST_DB_MAX_ROUND_ROBIN_INFO];
+
+  do {
+    if (info[i].app.http_data.last_failure != 0 &&
+        (uint32_t) (now - fail_window) < info[i].app.http_data.last_failure) {
+      continue;
+    }
+
+    if (info[i].app.http_data.last_failure)
+      info[i].app.http_data.last_failure = 0;
+
+    if (info[i].data.srv.srv_priority <= p) {
+      p = info[i].data.srv.srv_priority;
+      weight += info[i].data.srv.srv_weight;
+      infos[len++] = &info[i];
+    } else
+      break;
+  } while (++i < good);
+
+  if (len == 0) { // all failed
+    result = &info[current++ % good];
+  } else if (weight == 0) { // srv weight is 0
+    result = &info[current++ % len];
+  } else {
+    uint32_t xx = rand->random() % weight;
+    for (i = 0; i < len && xx >= infos[i]->data.srv.srv_weight; ++i)
+      xx -= infos[i]->data.srv.srv_weight;
+
+    result = infos[i];
+  }
+
+  if (result) {
+    strcpy(target, result->srvname(this));
+    return result;
+  }
+  return NULL;
+}
+
 //
 // Types
 //
@@ -351,6 +424,7 @@ struct HostDBContinuation: public Continuation
   //  char name[MAXDNAME];
   //  int namelen;
   char md5_host_name_store[MAXDNAME+1]; // used as backing store for @a md5
+  char srv_target_name[MAXDNAME];
   void *m_pDS;
   Action *pending_action;
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e57b8a5/proxy/config/records.config.default.in
----------------------------------------------------------------------
diff --git a/proxy/config/records.config.default.in b/proxy/config/records.config.default.in
index ea74ade..9e396f0 100644
--- a/proxy/config/records.config.default.in
+++ b/proxy/config/records.config.default.in
@@ -393,7 +393,7 @@ CONFIG proxy.config.dns.validate_query_name INT 0
    # note that in order to increase hostdb.size, hostdb.storage_size should
    # also be increase. These are best guesses, you will have to monitor this.
 CONFIG proxy.config.hostdb.size INT 120000
-CONFIG proxy.config.hostdb.storage_size INT 32M
+CONFIG proxy.config.hostdb.storage_size INT 200M
    # ttl modes:
    #   0 = obey
    #   1 = ignore

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e57b8a5/proxy/http/HttpSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 36f5608..3b0b151 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -418,6 +418,7 @@ HttpSM::init()
   t_state.cache_info.config.cache_vary_default_other = t_state.http_config_param->cache_vary_default_other;
 
   t_state.init();
+  t_state.srv_lookup = HttpConfig::m_master.srv_enabled;
   // Added to skip dns if the document is in cache. DNS will be forced if there is a ip based ACL in
   // cache control or parent.config or if the doc_in_cache_skip_dns is disabled or if http caching is disabled
   // TODO: This probably doesn't honor this as a per-transaction overridable config.
@@ -1975,51 +1976,34 @@ HttpSM::process_srv_info(HostDBInfo * r)
 {
   DebugSM("dns_srv", "beginning process_srv_info");
 
-  SRVHosts s(r);                /* handled by conversion constructor */
-  char new_host[MAXDNAME];
-
   /* we didnt get any SRV records, continue w normal lookup */
-  if (!r->srv_count) {
+  if (!r || !r->is_srv || !r->round_robin) {
+    t_state.dns_info.srv_hostname[0] = '\0';
+    t_state.dns_info.srv_lookup_success = false;
+    t_state.srv_lookup = false;
     DebugSM("dns_srv", "No SRV records were available, continuing to lookup %s", t_state.dns_info.lookup_name);
-    ink_strlcpy(new_host, t_state.dns_info.lookup_name, sizeof(new_host));
-    goto lookup;
-  }
-
-  s.getWeightedHost(&new_host[0]);
-
-  if (*new_host == '\0') {
-    DebugSM("dns_srv", "Weighted host returned was NULL or blank!, using %s as origin", t_state.dns_info.lookup_name);
-    ink_strlcpy(new_host, t_state.dns_info.lookup_name, sizeof(new_host));
-  } else {
-    DebugSM("dns_srv", "Weighted host now: %s", new_host);
-  }
-
-  DebugSM("dns_srv", "ending process_srv_info SRV stuff; moving on to lookup origin host");
-
-lookup:
-  DebugSM("http_seq", "[HttpSM::process_srv_info] Doing DNS Lookup based on SRV %s", new_host);
-
-  int server_port = t_state.current.server ? t_state.current.server->port : t_state.server_info.port;
-
-  HTTP_SM_SET_DEFAULT_HANDLER(&HttpSM::state_hostdb_lookup);
-
-  HostDBProcessor::Options opt;
-  if (t_state.api_txn_dns_timeout_value != -1) {
-    opt.timeout = t_state.api_txn_dns_timeout_value;
-    DebugSM("http_timeout", "beginning DNS lookup. allowing %d mseconds for DNS", t_state.api_txn_dns_timeout_value);
-  }
-  opt.flags = (t_state.cache_info.directives.does_client_permit_dns_storing) ? HostDBProcessor::HOSTDB_DO_NOT_FORCE_DNS : HostDBProcessor::HOSTDB_FORCE_DNS_RELOAD;
-  opt.port = server_port;
-  opt.host_res_style = ua_session->host_res_style;
-
-  Action *dns_lookup_action_handle = hostDBProcessor.getbyname_imm(this, (process_hostdb_info_pfn) & HttpSM::process_hostdb_info, &new_host[0], 0, opt);
-
-  if (dns_lookup_action_handle != ACTION_RESULT_DONE) {
-    ink_assert(!pending_action);
-    pending_action = dns_lookup_action_handle;
-    historical_action = pending_action;
   } else {
-    call_transact_and_set_next_state(NULL);
+    HostDBRoundRobin *rr = r->rr();
+    HostDBInfo *srv = NULL;
+    if (rr) {
+      srv = rr->select_best_srv(t_state.dns_info.srv_hostname, &mutex.m_ptr->thread_holding->generator,
+          ink_cluster_time(), (int) t_state.txn_conf->down_server_timeout);
+    }
+    if (!srv) {
+      t_state.dns_info.srv_lookup_success = false;
+      t_state.dns_info.srv_hostname[0] = '\0';
+      t_state.srv_lookup = false;
+      DebugSM("dns_srv", "SRV records empty for %s", t_state.dns_info.lookup_name);
+    } else {
+      ink_debug_assert(r->md5_high == srv->md5_high && r->md5_low == srv->md5_low &&
+          r->md5_low_low == srv->md5_low_low);
+      t_state.dns_info.srv_lookup_success = true;
+      t_state.dns_info.srv_port = srv->data.srv.srv_port;
+      t_state.dns_info.srv_app = srv->app;
+      //t_state.dns_info.single_srv = (rr->good == 1);
+      ink_debug_assert(srv->data.srv.key == makeHostHash(t_state.dns_info.srv_hostname));
+      DebugSM("dns_srv", "select SRV records %s", t_state.dns_info.srv_hostname);
+    }
   }
   return;
 }
@@ -2028,22 +2012,39 @@ void
 HttpSM::process_hostdb_info(HostDBInfo * r)
 {
   if (r && !r->failed()) {
-    HostDBInfo *rr = NULL;
+    ink_time_t now = ink_cluster_time();
+    HostDBInfo *ret = NULL;
     t_state.dns_info.lookup_success = true;
-
     if (r->round_robin) {
       // Since the time elapsed between current time and client_request_time
       // may be very large, we cannot use client_request_time to approximate
       // current time when calling select_best_http().
-      rr = r->rr()->select_best_http(&t_state.client_info.addr.sa, ink_cluster_time(), (int) t_state.txn_conf->down_server_timeout);
+      HostDBRoundRobin *rr = r->rr();
+      ret = rr->select_best_http(&t_state.client_info.addr.sa, now, (int) t_state.txn_conf->down_server_timeout);
       t_state.dns_info.round_robin = true;
+
+      // set the srv target`s last_failure
+      if (t_state.dns_info.srv_lookup_success) {
+        uint32_t last_failure = 0xFFFFFFFF;
+        for (int i = 0; i < rr->n && last_failure != 0; ++i) {
+          if (last_failure > rr->info[i].app.http_data.last_failure)
+            last_failure = rr->info[i].app.http_data.last_failure;
+        }
+
+        if (last_failure != 0 && (uint32_t) (now - t_state.txn_conf->down_server_timeout) < last_failure) {
+          HostDBApplicationInfo app;
+          app.allotment.application1 = 0;
+          app.allotment.application2 = 0;
+          app.http_data.last_failure = last_failure;
+          hostDBProcessor.setby_srv(t_state.dns_info.lookup_name, 0, t_state.dns_info.srv_hostname, &app);
+        }
+      }
     } else {
-      rr = r;
+      ret = r;
       t_state.dns_info.round_robin = false;
     }
-    if (rr) {
-//                  m_s.host_db_info = m_updated_host_db_info = *rr;
-      t_state.host_db_info = *rr;
+    if (ret) {
+      t_state.host_db_info = *ret;
       ink_release_assert(!t_state.host_db_info.reverse_dns);
       ink_release_assert(ats_is_ip(t_state.host_db_info.ip()));
     }
@@ -2088,6 +2089,35 @@ HttpSM::state_hostdb_lookup(int event, void *data)
     process_hostdb_info((HostDBInfo *) data);
     call_transact_and_set_next_state(NULL);
     break;
+    case EVENT_SRV_LOOKUP:
+    {
+      pending_action = NULL;
+      process_srv_info((HostDBInfo *) data);
+
+      char *host_name = t_state.dns_info.srv_lookup_success ? t_state.dns_info.srv_hostname : t_state.dns_info.lookup_name;
+      HostDBProcessor::Options opt;
+      opt.port = t_state.dns_info.srv_lookup_success ? t_state.dns_info.srv_port : t_state.server_info.port;
+      opt.flags = (t_state.cache_info.directives.does_client_permit_dns_storing)
+            ? HostDBProcessor::HOSTDB_DO_NOT_FORCE_DNS
+            : HostDBProcessor::HOSTDB_FORCE_DNS_RELOAD
+          ;
+      opt.timeout = (t_state.api_txn_dns_timeout_value != -1) ? t_state.api_txn_dns_timeout_value : 0;
+      opt.host_res_style = ua_session->host_res_style;
+
+      Action *dns_lookup_action_handle = hostDBProcessor.getbyname_imm(this,
+                                                                 (process_hostdb_info_pfn) & HttpSM::
+                                                                 process_hostdb_info,
+                                                                 host_name, 0,
+                                                                 opt);
+      if (dns_lookup_action_handle != ACTION_RESULT_DONE) {
+        ink_assert(!pending_action);
+        pending_action = dns_lookup_action_handle;
+        historical_action = pending_action;
+      } else {
+        call_transact_and_set_next_state(NULL);
+      }
+    }
+    break;
   case EVENT_HOST_DB_IP_REMOVED:
     ink_assert(!"Unexpected event from HostDB");
     break;
@@ -3767,16 +3797,15 @@ HttpSM::do_hostdb_lookup()
   ink_assert(pending_action == NULL);
 
   milestones.dns_lookup_begin = ink_get_hrtime();
-  bool use_srv_records = HttpConfig::m_master.srv_enabled;
+  bool use_srv_records = t_state.srv_lookup;
 
   if (use_srv_records) {
-    char* d = t_state.dns_info.srv_hostname;
+    char d[MAXDNAME];
 
     memcpy(d, "_http._tcp.", 11); // don't copy '\0'
     ink_strlcpy(d + 11, t_state.server_info.name, sizeof(d) - 11 ); // all in the name of performance!
 
     DebugSM("dns_srv", "Beginning lookup of SRV records for origin %s", d);
-    HTTP_SM_SET_DEFAULT_HANDLER(&HttpSM::state_srv_lookup);
 
     HostDBProcessor::Options opt;
     if (t_state.api_txn_dns_timeout_value != -1)
@@ -3788,6 +3817,28 @@ HttpSM::do_hostdb_lookup()
       ink_assert(!pending_action);
       pending_action = srv_lookup_action_handle;
       historical_action = pending_action;
+    } else {
+      char *host_name = t_state.dns_info.srv_lookup_success ? t_state.dns_info.srv_hostname : t_state.dns_info.lookup_name;
+      opt.port = t_state.dns_info.srv_lookup_success ? t_state.dns_info.srv_port : t_state.server_info.port;
+      opt.flags = (t_state.cache_info.directives.does_client_permit_dns_storing)
+            ? HostDBProcessor::HOSTDB_DO_NOT_FORCE_DNS
+            : HostDBProcessor::HOSTDB_FORCE_DNS_RELOAD
+          ;
+      opt.timeout = (t_state.api_txn_dns_timeout_value != -1) ? t_state.api_txn_dns_timeout_value : 0;
+      opt.host_res_style = ua_session->host_res_style;
+
+      Action *dns_lookup_action_handle = hostDBProcessor.getbyname_imm(this,
+                                                                 (process_hostdb_info_pfn) & HttpSM::
+                                                                 process_hostdb_info,
+                                                                 host_name, 0,
+                                                                 opt);
+      if (dns_lookup_action_handle != ACTION_RESULT_DONE) {
+        ink_assert(!pending_action);
+        pending_action = dns_lookup_action_handle;
+        historical_action = pending_action;
+      } else {
+        call_transact_and_set_next_state(NULL);
+      }
     }
     return;
   } else {                      /* we arent using SRV stuff... */
@@ -3891,6 +3942,14 @@ HttpSM::do_hostdb_update_if_necessary()
             sm_id,
             ats_ip_nptop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf)));
     }
+
+    if (t_state.dns_info.srv_lookup_success && t_state.dns_info.srv_app.http_data.last_failure != 0) {
+      t_state.dns_info.srv_app.http_data.last_failure = 0;
+      hostDBProcessor.setby_srv(t_state.dns_info.lookup_name, 0, t_state.dns_info.srv_hostname, &t_state.dns_info.srv_app);
+      DebugSM("http", "[%" PRId64 "] hostdb update marking SRV: %s as up",
+                  sm_id,
+                  t_state.dns_info.srv_hostname);
+    }
   }
 
   if (issue_update) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e57b8a5/proxy/http/HttpTransact.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index 931fe80..3e466f0 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -1204,6 +1204,17 @@ HttpTransact::HandleRequest(State* s)
     return;
   }
 
+  // if ip in url or cop test page, not do srv lookup.
+  if (s->srv_lookup) {
+    if (s->cop_test_page)
+      s->srv_lookup = false;
+    else {
+      IpEndpoint addr;
+      ats_ip_pton(s->server_info.name, &addr);
+      s->srv_lookup = !ats_is_ip(&addr);
+    }
+  }
+
   // if the request is a trace or options request, decrement the
   // max-forwards value. if the incoming max-forwards value was 0,
   // then we have to return a response to the client with the
@@ -3517,7 +3528,7 @@ HttpTransact::handle_response_from_server(State* s)
       // If this is a round robin DNS entry & we're tried configured
       //    number of times, we should try another node
 
-      bool use_srv_records = HttpConfig::m_master.srv_enabled;
+      //bool use_srv_records = HttpConfig::m_master.srv_enabled;
 
       if (DNSLookupInfo::OS_ADDR_TRY_CLIENT == s->dns_info.os_addr_style) {
         // attempt was based on client supplied server address. Try again
@@ -3531,10 +3542,7 @@ HttpTransact::handle_response_from_server(State* s)
         // families - that is locked in by the client source address.
         s->state_machine->ua_session->host_res_style = ats_host_res_match(&s->current.server->addr.sa);
         TRANSACT_RETURN(HttpTransact::DNS_LOOKUP, OSDNSLookup);
-      } else if (use_srv_records) {
-        delete_srv_entry(s, max_connect_retries);
-        return;
-      } else if (s->server_info.dns_round_robin &&
+      } else if ((s->dns_info.srv_lookup_success || s->server_info.dns_round_robin) &&
                  (s->txn_conf->connect_attempts_rr_retries > 0) &&
                  (s->current.attempts % s->txn_conf->connect_attempts_rr_retries == 0)) {
         delete_server_rr_entry(s, max_connect_retries);
@@ -3565,129 +3573,7 @@ HttpTransact::handle_response_from_server(State* s)
   return;
 }
 
-void
-HttpTransact::delete_srv_entry(State* s, int max_retries)
-{
-  /* we are using SRV lookups and this host failed -- lets remove it from the HostDB */
-  HostDBMD5 md5;
-  EThread *thread = this_ethread();
-  //ProxyMutex *mutex = thread->mutex;
-  md5.host_name = s->dns_info.srv_hostname;
-  if (!md5.host_name) {
-    TRANSACT_RETURN(OS_RR_MARK_DOWN, ReDNSRoundRobin);
-  }
-  md5.host_len = strlen(md5.host_name);
-  md5.db_mark = HOSTDB_MARK_SRV;
-  md5.refresh();
-
-  ProxyMutex *bucket_mutex = hostDB.lock_for_bucket((int) (fold_md5(md5.hash) % hostDB.buckets));
-
-  s->current.attempts++;
-
-  DebugTxn("http_trans", "[delete_srv_entry] attempts now: %d, max: %d", s->current.attempts, max_retries);
-  DebugTxn("dns_srv", "[delete_srv_entry] attempts now: %d, max: %d", s->current.attempts, max_retries);
 
-  MUTEX_TRY_LOCK(lock, bucket_mutex, thread);
-  if (lock) {
-//    IpEndpoint ip;
-    HostDBInfo *r = probe(bucket_mutex, md5, false);
-    if (r) {
-      if (r->is_srv) {
-        DebugTxn("dns_srv", "Marking SRV records for %s [Origin: %s] as bad", md5.host_name, s->dns_info.lookup_name);
-
-        uint64_t folded_md5 = fold_md5(md5.hash);
-
-        HostDBInfo *new_r = NULL;
-
-        DebugTxn("dns_srv", "[HttpTransact::delete_srv_entry] Adding relevent entries back into HostDB");
-
-        SRVHosts srv_hosts(r);  /* conversion constructor for SRVHosts() */
-        r->set_deleted();       //delete the original HostDB
-        hostDB.delete_block(r); //delete the original HostDB
-
-        new_r = hostDB.insert_block(folded_md5, NULL, 0);       //create new entry
-        new_r->md5_high = md5.hash[1];
-
-        SortableQueue<SRV> *q = srv_hosts.getHosts();        //get the Queue of SRV entries
-        SRV *srv_entry = NULL;
-
-        Queue<SRV> still_ok_hosts;
-
-        new_r->srv_count = 0;
-        while ((srv_entry = q->dequeue())) {    // ok to dequeue since this is the last time we are using this.
-          if (strcmp(srv_entry->getHost(), s->dns_info.lookup_name) != 0) {
-            still_ok_hosts.enqueue(srv_entry);
-            new_r->srv_count++;
-          } else {
-            SRVAllocator.free(srv_entry);
-          }
-        }
-
-        q = NULL;
-
-        /* no hosts DON'T match -- max out retries and return */
-        if (still_ok_hosts.empty()) {
-          DebugTxn("dns_srv", "No more SRV hosts to try that don't contain a host we just tried -- giving up");
-          s->current.attempts = max_retries;
-          TRANSACT_RETURN(OS_RR_MARK_DOWN, ReDNSRoundRobin);
-        }
-
-        /*
-           assert: at this point, we have (inside still_ok_hosts) those SRV records that were NOT pointing to the
-           same hostname as the one that just failed; lets reenqueue those into the HostDB and perform another "lookup"
-           which [hopefully] will find these records inside the HostDB and use them.
-         */
-
-        new_r->ip_timeout_interval = 45;        /* good for 45 seconds, then lets re-validate? */
-        new_r->ip_timestamp = hostdb_current_interval;
-        ats_ip_invalidate(new_r->ip());
-
-        /* these go into the RR area */
-        int n = new_r->srv_count;
-
-        if (n < 1) {
-          new_r->round_robin = 0;
-        } else {
-          new_r->round_robin = 1;
-          int sz = HostDBRoundRobin::size(n, true);
-          HostDBRoundRobin *rr_data = (HostDBRoundRobin *) hostDB.alloc(&new_r->app.rr.offset, sz);
-          DebugTxn("hostdb", "allocating %d bytes for %d RR at %p %d", sz, n, rr_data, new_r->app.rr.offset);
-          int i = 0;
-          while ((srv_entry = still_ok_hosts.dequeue())) {
-            DebugTxn("dns_srv", "Re-adding %s to HostDB [as a RR] after %s failed", srv_entry->getHost(), s->dns_info.lookup_name);
-            ats_ip_invalidate(rr_data->info[i].ip());
-            rr_data->info[i].round_robin = 0;
-            rr_data->info[i].reverse_dns = 0;
-
-            rr_data->info[i].srv_weight = srv_entry->getWeight();
-            rr_data->info[i].srv_priority = srv_entry->getPriority();
-            rr_data->info[i].srv_port = srv_entry->getPort();
-
-            ink_strlcpy(rr_data->rr_srv_hosts[i], srv_entry->getHost(), sizeof(rr_data->rr_srv_hosts[i]));
-            rr_data->info[i].is_srv = true;
-
-            rr_data->info[i].md5_high = new_r->md5_high;
-            rr_data->info[i].md5_low = new_r->md5_low;
-            rr_data->info[i].md5_low_low = new_r->md5_low_low;
-            rr_data->info[i].full = 1;
-            SRVAllocator.free(srv_entry);
-            i++;
-          }
-          rr_data->good = rr_data->n = n;
-          rr_data->current = 0;
-        }
-
-      } else {
-        DebugTxn("dns_srv", "Trying to delete a bad SRV for %s and something was wonky", md5.host_name);
-      }
-    } else {
-      DebugTxn("dns_srv", "No SRV data to remove. Ruh Roh Shaggy. Maxing out connection attempts...");
-      s->current.attempts = max_retries;
-    }
-  }
-
-  TRANSACT_RETURN(OS_RR_MARK_DOWN, ReDNSRoundRobin);
-}
 
 ///////////////////////////////////////////////////////////////////////////////
 // Name       : delete_server_rr_entry

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e57b8a5/proxy/http/HttpTransact.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransact.h b/proxy/http/HttpTransact.h
index 2c3a9bd..a92b1ab 100644
--- a/proxy/http/HttpTransact.h
+++ b/proxy/http/HttpTransact.h
@@ -770,12 +770,18 @@ public:
     char srv_hostname[MAXDNAME];
     LookingUp_t looking_up;
     bool round_robin;
+    bool srv_lookup_success;
+    short srv_port;
+    HostDBApplicationInfo srv_app;
 
     _DNSLookupInfo()
     : attempts(0), os_addr_style(OS_ADDR_TRY_DEFAULT),
-        lookup_success(false), lookup_name(NULL), looking_up(UNDEFINED_LOOKUP), round_robin(false)
+        lookup_success(false), lookup_name(NULL), looking_up(UNDEFINED_LOOKUP), round_robin(false),
+        srv_lookup_success(false), srv_port(0)
     {
-      memset(&srv_hostname, 0, sizeof(srv_hostname));
+      srv_hostname[0] = '\0';
+      srv_app.allotment.application1 = 0;
+      srv_app.allotment.application2 = 0;
     }
   } DNSLookupInfo;
 
@@ -913,7 +919,8 @@ public:
 
     // for negative caching
     bool negative_caching;
-
+    // for srv_lookup
+    bool srv_lookup;
     // for authenticated content caching
     CacheAuth_t www_auth_content;
 
@@ -1038,6 +1045,7 @@ public:
         first_stats(),
         current_stats(NULL),
         negative_caching(false),
+        srv_lookup(false),
         www_auth_content(CACHE_AUTH_NONE),
         client_connection_enabled(true),
         acl_filtering_performed(false),
@@ -1235,7 +1243,6 @@ public:
   static void handle_response_from_parent(State* s);
   static void handle_response_from_server(State* s);
   static void delete_server_rr_entry(State* s, int max_retries);
-  static void delete_srv_entry(State* s, int max_retries);
   static void retry_server_connection_not_open(State* s, ServerState_t conn_state, int max_retries);
   static void handle_server_connection_not_open(State* s);
   static void handle_forward_server_connection_open(State* s);


[44/50] git commit: Fix vagrant VM addressing

Posted by zw...@apache.org.
Fix vagrant VM addressing


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

Branch: refs/heads/3.3.x
Commit: bb75f4a50a7e2a4cba10ac3c0c7b92b10e732df3
Parents: c350809
Author: James Peach <jp...@apache.org>
Authored: Thu Apr 4 12:48:56 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:44 2013 -0600

----------------------------------------------------------------------
 Vagrantfile |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bb75f4a5/Vagrantfile
----------------------------------------------------------------------
diff --git a/Vagrantfile b/Vagrantfile
index babfca6..87dd26e 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -15,13 +15,14 @@
 #  limitations under the License.
 
 $network = {
-  "raring64"  => "192.168.100.1",
-  "quantal64" => "192.168.100.2",
-  "precise64" => "192.168.100.3",
-  "lucid64"   => "192.168.100.4",
-  "centos63"  => "192.168.100.5",
-  "freebsd"   => "192.168.100.6",
-  "omnios"    => "192.168.100.7",
+  # The VM host is 192.168.100.1
+  "raring64"  => "192.168.100.11",
+  "quantal64" => "192.168.100.12",
+  "precise64" => "192.168.100.13",
+  "lucid64"   => "192.168.100.14",
+  "centos63"  => "192.168.100.15",
+  "freebsd"   => "192.168.100.16",
+  "omnios"    => "192.168.100.17",
 }
 
 Vagrant.configure("2") do |config|


[08/50] git commit: add TS-1713

Posted by zw...@apache.org.
add TS-1713


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

Branch: refs/heads/3.3.x
Commit: 3c1e58a7a2688164784d6be99d8b8ec228007c3e
Parents: fa084a6
Author: Zhao Yongming <mi...@gmail.com>
Authored: Tue Apr 2 15:30:41 2013 +0800
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:42 2013 -0600

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3c1e58a7/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index a31e7c8..8a5218a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1713] SRV support refine. Now the srv option is able to enable, with
+   no crash. Be care, the hostdb.storage_size or ostdb.size need check.
+
   *) [TS-1632] In addition to the changes from TS-1674, also add
    some safety measures assuring that the stats sums don't go
    negative. Author: Yakov Kopel.


[20/50] git commit: TS-1067 Reduce to one UDP pipe, and remove BulkIOSend()

Posted by zw...@apache.org.
TS-1067 Reduce to one UDP pipe, and remove BulkIOSend()


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

Branch: refs/heads/3.3.x
Commit: 0f2d659c1aa4970d033e4b13d5a08e208d154284
Parents: 7217e78
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Mar 26 09:48:36 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

----------------------------------------------------------------------
 iocore/net/P_LibBulkIO.h |    2 -
 iocore/net/P_UDPNet.h    |    6 --
 iocore/net/UnixUDPNet.cc |  154 +++++++++++------------------------------
 proxy/Main.cc            |    2 -
 4 files changed, 40 insertions(+), 124 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0f2d659c/iocore/net/P_LibBulkIO.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_LibBulkIO.h b/iocore/net/P_LibBulkIO.h
index 0d80671..0fe541f 100644
--- a/iocore/net/P_LibBulkIO.h
+++ b/iocore/net/P_LibBulkIO.h
@@ -166,8 +166,6 @@ int BulkIOSplitPkt(struct InkBulkIOState *bioCookie,
 int BulkIOAppendToReqBlock(struct InkBulkIOState *bioCookie,
                            struct InkBulkIOAggregator *bioAggregator, Ptr<IOBufferBlock> pkt);
 
-int BulkIOSend(struct InkBulkIOState *bioCookie, uint32_t blkId);
-
 void BulkIORequestComplete(struct InkBulkIOState *bioCookie, struct InkBulkIOAggregator *bioAggregator);
 
 void BulkIOFlush(struct InkBulkIOState *bioCookie, struct InkBulkIOAggregator *bioAggregator);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0f2d659c/iocore/net/P_UDPNet.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_UDPNet.h b/iocore/net/P_UDPNet.h
index 31a2492..239ab34 100644
--- a/iocore/net/P_UDPNet.h
+++ b/iocore/net/P_UDPNet.h
@@ -63,9 +63,6 @@ class UDPQueue
 public:
 
   void service(UDPNetHandler *);
-  // these are internal APIs
-  // BulkIOSend uses the BulkIO kernel module for bulk data transfer
-  void BulkIOSend();
   // In the absence of bulk-io, we are down sending packet after packet
   void SendPackets();
   void SendUDPPacket(UDPPacketInternal * p, int32_t pktLen);
@@ -378,9 +375,6 @@ struct InkSinglePipeInfo
 
 struct InkPipeInfo
 {
-  int numPipes;
-  double interfaceMbps;
-  double reliabilityMbps;
   InkSinglePipeInfo *perPipeInfo;
 };
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0f2d659c/iocore/net/UnixUDPNet.cc
----------------------------------------------------------------------
diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc
index ccf1fde..029d8cc 100644
--- a/iocore/net/UnixUDPNet.cc
+++ b/iocore/net/UnixUDPNet.cc
@@ -54,7 +54,6 @@ int32_t g_udp_periodicFreeCancelledPkts;
 int32_t g_udp_numSendRetries;
 
 #include "P_LibBulkIO.h"
-void *G_bulkIOState = NULL;
 
 //
 // Public functions
@@ -90,7 +89,6 @@ initialize_thread_for_udp_net(EThread * thread)
 
   thread->schedule_every(get_UDPPollCont(thread), -9);
   thread->schedule_imm(get_UDPNetHandler(thread));
-  Debug("bulk-io", "%s bulk-io for sends", G_bulkIOState ? "Using" : "Not using");
 }
 
 int
@@ -658,8 +656,8 @@ UDPQueue::service(UDPNetHandler * nh)
   double minPktSpacing;
   uint32_t pktSize;
   int64_t pktLen;
-  int i;
   bool addToGuaranteedQ;
+
   (void) nh;
   static ink_hrtime lastPrintTime = ink_get_hrtime_internal();
   static ink_hrtime lastSchedTime = ink_get_hrtime_internal();
@@ -741,46 +739,25 @@ UDPQueue::service(UDPNetHandler * nh)
     lastPrintTime = now;
   }
 
-  for (i = 0; i < G_inkPipeInfo.numPipes + 1; i++)
-    G_inkPipeInfo.perPipeInfo[i].queue->advanceNow(now);
-
-  if (G_bulkIOState) {
-    BulkIOSend();
-  } else {
-    SendPackets();
-  }
+  G_inkPipeInfo.perPipeInfo[0].queue->advanceNow(now);
+  SendPackets();
 
   timeSpent = ink_hrtime_to_msec(now - last_report);
   if (timeSpent > 10000) {
-    // if (bytesSent > 0)
-    // timespent is in milli-seconds
-    char temp[2048], *p1;
     double bw, totalBw;
 
-    temp[0] = '\0';
-    p1 = temp;
-
     if (bytesSent > 0)
       totalBw = (bytesSent * 8.0 * 1000.0) / (timeSpent * 1024.0 * 1024.0);
     else
       totalBw = 1.0;
 
-    for (i = 0; i < G_inkPipeInfo.numPipes + 1; i++) {
-      // bw is in Mbps
-      bw = (G_inkPipeInfo.perPipeInfo[i].bytesSent * 8.0 * 1000.0) / (timeSpent * 1024.0 * 1024.0);
-      snprintf(p1, sizeof(temp), "\t class[%d] = %f Mbps, alloc = %f Mbps, (conf'ed = %f, got = %f) \n",
-               i, bw, (G_inkPipeInfo.perPipeInfo[i].bwAlloc / (1024.0 * 1024.0)),
-               G_inkPipeInfo.perPipeInfo[i].wt, bw / totalBw);
-      p1 += strlen(p1);
-
-      // use a weighted estimator of current usage
-      G_inkPipeInfo.perPipeInfo[i].bwUsed = (4.0 * G_inkPipeInfo.perPipeInfo[i].bwUsed / 5.0) + (bw / 5.0);
-      G_inkPipeInfo.perPipeInfo[i].bytesSent = 0;
-      G_inkPipeInfo.perPipeInfo[i].pktsSent = 0;
-    }
-    if (temp[0])
-      Debug("udpnet-bw", "B/w: %f Mbps; breakdown: \n%s", totalBw, temp);
+    // bw is in Mbps
+    bw = (G_inkPipeInfo.perPipeInfo[0].bytesSent * 8.0 * 1000.0) / (timeSpent * 1024.0 * 1024.0);
 
+    // use a weighted estimator of current usage
+    G_inkPipeInfo.perPipeInfo[0].bwUsed = (4.0 * G_inkPipeInfo.perPipeInfo[0].bwUsed / 5.0) + (bw / 5.0);
+    G_inkPipeInfo.perPipeInfo[0].bytesSent = 0;
+    G_inkPipeInfo.perPipeInfo[0].pktsSent = 0;
 
     bytesSent = 0;
     last_report = now;
@@ -799,23 +776,14 @@ UDPQueue::SendPackets()
   // ink_hrtime send_threshold_time = now + HRTIME_MSECONDS(5);
   // send packets for SLOT_TIME per attempt
   ink_hrtime send_threshold_time = now + SLOT_TIME;
-  int32_t bytesThisSlot = INT_MAX, bytesUsed = 0, reliabilityBytes = 0;
-  int32_t bytesThisPipe, sentOne, i;
+  int32_t bytesThisSlot = INT_MAX, bytesUsed = 0;
+  int32_t bytesThisPipe, sentOne;
   int64_t pktLen;
   ink_hrtime timeDelta = 0;
 
   if (now > last_service)
     timeDelta = ink_hrtime_to_msec(now - last_service);
 
-  if (G_inkPipeInfo.numPipes > 0) {
-    bytesThisSlot = (int32_t) (((G_inkPipeInfo.reliabilityMbps * 1024.0 * 1024.0) / (8.0 * 1000.0)) * timeDelta);
-    if (bytesThisSlot == 0) {
-      // use at most 10% for reliability
-      bytesThisSlot = (int32_t) (((G_inkPipeInfo.interfaceMbps * 1024.0 * 1024.0) / (8.0 * 1000.0)) * timeDelta * 0.1);
-      reliabilityBytes = bytesThisSlot;
-    }
-  }
-
   while ((p = reliabilityPktQueue.dequeue()) != NULL) {
     pktLen = p->getPktLength();
     g_udp_bytesPending -= pktLen;
@@ -836,41 +804,35 @@ UDPQueue::SendPackets()
     p->free();
   }
 
-
-  if (G_inkPipeInfo.numPipes > 0)
-    bytesThisSlot = (int32_t) (((G_inkPipeInfo.interfaceMbps * 1024.0 * 1024.0) /
-                              (8.0 * 1000.0)) * timeDelta - reliabilityBytes);
-  else
-    bytesThisSlot = INT_MAX;
+  bytesThisSlot = INT_MAX;
 
 sendPackets:
   sentOne = false;
   send_threshold_time = now + SLOT_TIME;
-  for (i = 0; i < G_inkPipeInfo.numPipes + 1; i++) {
-    bytesThisPipe = (int32_t) (bytesThisSlot * G_inkPipeInfo.perPipeInfo[i].wt);
-    while ((bytesThisPipe > 0) && (G_inkPipeInfo.perPipeInfo[i].queue->firstPacket(send_threshold_time))) {
-      p = G_inkPipeInfo.perPipeInfo[i].queue->getFirstPacket();
-      pktLen = p->getPktLength();
-      g_udp_bytesPending -= pktLen;
-
-      p->conn->nBytesTodo -= pktLen;
-      p->conn->nBytesDone += pktLen;
-      if (p->conn->shouldDestroy())
-        goto next_pkt;
-      if (p->conn->GetSendGenerationNumber() != p->reqGenerationNum)
-        goto next_pkt;
-
-      G_inkPipeInfo.perPipeInfo[i].bytesSent += pktLen;
-      SendUDPPacket(p, pktLen);
-      bytesUsed += pktLen;
-      bytesThisPipe -= pktLen;
-    next_pkt:
-      sentOne = true;
-      p->free();
-
-      if (bytesThisPipe < 0)
-        break;
-    }
+  bytesThisPipe = (int32_t) (bytesThisSlot * G_inkPipeInfo.perPipeInfo[0].wt);
+
+  while ((bytesThisPipe > 0) && (G_inkPipeInfo.perPipeInfo[0].queue->firstPacket(send_threshold_time))) {
+    p = G_inkPipeInfo.perPipeInfo[0].queue->getFirstPacket();
+    pktLen = p->getPktLength();
+    g_udp_bytesPending -= pktLen;
+
+    p->conn->nBytesTodo -= pktLen;
+    p->conn->nBytesDone += pktLen;
+    if (p->conn->shouldDestroy())
+      goto next_pkt;
+    if (p->conn->GetSendGenerationNumber() != p->reqGenerationNum)
+      goto next_pkt;
+
+    G_inkPipeInfo.perPipeInfo[0].bytesSent += pktLen;
+    SendUDPPacket(p, pktLen);
+    bytesUsed += pktLen;
+    bytesThisPipe -= pktLen;
+  next_pkt:
+    sentOne = true;
+    p->free();
+
+    if (bytesThisPipe < 0)
+      break;
   }
 
   bytesThisSlot -= bytesUsed;
@@ -878,10 +840,8 @@ sendPackets:
   if ((bytesThisSlot > 0) && (sentOne)) {
     // redistribute the slack...
     now = ink_get_hrtime_internal();
-    for (i = 0; i < G_inkPipeInfo.numPipes + 1; i++) {
-      if (G_inkPipeInfo.perPipeInfo[i].queue->firstPacket(now) == NULL) {
-        G_inkPipeInfo.perPipeInfo[i].queue->advanceNow(now);
-      }
+    if (G_inkPipeInfo.perPipeInfo[0].queue->firstPacket(now) == NULL) {
+      G_inkPipeInfo.perPipeInfo[0].queue->advanceNow(now);
     }
     goto sendPackets;
   }
@@ -890,9 +850,8 @@ sendPackets:
       (now - lastCleanupTime > ink_hrtime_from_sec(g_udp_periodicFreeCancelledPkts))) {
     uint64_t nbytes = g_udp_bytesPending;
     ink_hrtime startTime = ink_get_hrtime_internal(), endTime;
-    for (i = 0; i < G_inkPipeInfo.numPipes + 1; i++) {
-      G_inkPipeInfo.perPipeInfo[i].queue->FreeCancelledPackets(g_udp_periodicCleanupSlots);
-    }
+
+    G_inkPipeInfo.perPipeInfo[0].queue->FreeCancelledPackets(g_udp_periodicCleanupSlots);
     endTime = ink_get_hrtime_internal();
     Debug("udp-pending-packets", "Did cleanup of %d buckets: %" PRId64 " bytes in %" PRId64 " m.sec",
           g_udp_periodicCleanupSlots, nbytes - g_udp_bytesPending, (int64_t)ink_hrtime_to_msec(endTime - startTime));
@@ -950,37 +909,6 @@ UDPQueue::SendUDPPacket(UDPPacketInternal * p, int32_t pktLen)
   }
 }
 
-#ifndef BULK_IO_SEND_IS_BROKEN
-void
-UDPQueue::BulkIOSend()
-{
-  ink_assert(!"Don't call here...");
-}
-#else
-void
-UDPQueue::BulkIOSend()
-{
-  bool sentOne = false;
-  UDPPacketInternal *p;
-  ink_hrtime now = ink_get_hrtime_internal();
-  ink_hrtime send_threshold_time = now + SLOT_TIME;
-
-  for (int i = 0; i < G_inkPipeInfo.numPipes + 1; i++) {
-    while (p = G_inkPipeInfo.perPipeInfo[i].queue->firstPacket(send_threshold_time)) {
-      p = G_inkPipeInfo.perPipeInfo[i].queue->getFirstPacket();
-      sentOne = true;
-      Debug("bulk-io-pkt", "Adding a packet...");
-      BulkIOAddPkt(G_bulkIOState, &G_bulkIOAggregator, p, p->conn->getPortNum());
-      bytesSent += p->getPktLength();
-      // Now the packet is "sent"; get rid of it
-      p->free();
-    }
-  }
-  if (sentOne) {
-    BulkIOFlush(G_bulkIOState, &G_bulkIOAggregator);
-  }
-}
-#endif
 
 void
 UDPQueue::send(UDPPacket * p)
@@ -1054,8 +982,6 @@ UDPNetHandler::mainNetEvent(int event, Event * e)
       ink_assert(uc->refcount >= 1);
       next = uc->polling_link.next;
       if (uc->shouldDestroy()) {
-        if (G_inkPipeInfo.numPipes > 0)
-          G_inkPipeInfo.perPipeInfo[uc->pipe_class].count--;
         //changed by YTS Team, yamsat
         //udp_polling->remove(uc,uc->polling_link);
         uc->Release();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0f2d659c/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index 5337748..a22098e 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -1525,8 +1525,6 @@ main(int argc, char **argv)
   // but I don't know for sure if we still need this.
   G_inkPipeInfo.perPipeInfo = NEW(new InkSinglePipeInfo[1]);
   G_inkPipeInfo.perPipeInfo[0].wt = 1.0;
-  G_inkPipeInfo.numPipes = 0;
-  G_inkPipeInfo.interfaceMbps = 0.0;
 
   init_http_header();
 


[45/50] git commit: streamline vagrant network assignments

Posted by zw...@apache.org.
streamline vagrant network assignments

Add a IP adress assignment map to make adding VMs easy. Use the
official Ubuntu cloud images where there is one available.


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

Branch: refs/heads/3.3.x
Commit: 4423f0b8f1addb9ae75fde629f2c32214e939693
Parents: 37ad2c3
Author: James Peach <jp...@apache.org>
Authored: Thu Apr 4 11:10:48 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:44 2013 -0600

----------------------------------------------------------------------
 Vagrantfile |   48 ++++++++++++++++++++++++++++++++----------------
 1 files changed, 32 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4423f0b8/Vagrantfile
----------------------------------------------------------------------
diff --git a/Vagrantfile b/Vagrantfile
index 85998e6..f98f415 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -14,6 +14,16 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 
+$network = {
+  raring64: "192.168.100.1",
+  quantal4: "192.168.100.2",
+  precise64:"192.168.100.3",
+  lucid64:  "192.168.100.4",
+  centos63: "192.168.100.5",
+  freebsd:  "192.168.100.6",
+  omnios:   "192.168.100.7",
+}
+
 Vagrant.configure("2") do |config|
 
   # Default all VMs to 1GB.
@@ -25,37 +35,43 @@ Vagrant.configure("2") do |config|
   # because it's faster and vboxfs doesn't support links.
   config.vm.synced_folder ".", "/opt/src/trafficserver.git", :nfs => true
 
+  # Ubuntu 13.04 (Raring Ringtail)
+  # Ubuntu 12.10 (Quantal Quetzal)
   # 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 :private_network, ip: "192.168.100.3"
-    config.vm.provision :puppet do |puppet|
-      puppet.manifests_path = "contrib/manifests"
-      puppet.manifest_file = "debian.pp"
+  ['raring', 'quantal', 'precise'].each { |release|
+    config.vm.define "#{release}64" do | config |
+      config.vm.box = "#{release}64"
+      config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/%{release}/current/#{release}-server-cloudimg-amd64-vagrant-disk1.box"
+      config.vm.network :private_network, ip: $network["#{release}64"]
+      config.vm.provision :puppet do |puppet|
+        puppet.manifests_path = "contrib/manifests"
+        puppet.manifest_file = "debian.pp"
+      end
     end
-  end
+  }
 
   # Ubuntu 10.04 LTS (Lucid Lynx)
   config.vm.define :lucid64 do | config |
     config.vm.box = "lucid64"
-    config.vm.network :hostonly, "192.168.100.2"
+    config.vm.network :private_network, ip: $network["lucid64"]
     config.vm.box_url = "http://files.vagrantup.com/lucid64.box"
   end
 
   config.vm.define :freebsd do | config |
     config.vm.box = "freebsd"
-    config.vm.share_folder "src", "/opt/src", "src", :nfs => false
+    config.vm.synced_folder ".", "/opt/src/trafficserver.git", :nfs => false
     # Force the FreeBSD VM to use a network driver that actually works.
-    config.vm.customize ["modifyvm", :id, "--nictype1", "82543GC"]
-    config.vm.customize ["modifyvm", :id, "--nictype2", "82543GC"]
-    config.vm.network :hostonly, "192.168.100.6"
+    config.vm.provider :virtualbox do |v|
+      v.customize ["modifyvm", :id, "--nictype1", "82543GC"]
+      v.customize ["modifyvm", :id, "--nictype2", "82543GC"]
+    end
+    config.vm.network :private_network, ip: $network["freebsd"]
     config.vm.box_url = "https://github.com/downloads/xironix/freebsd-vagrant/freebsd_amd64_zfs.box"
   end
 
   config.vm.define :centos63 do |config|
     config.vm.box = "centos63"
-    config.vm.network :private_network, ip: "192.168.100.8"
+    config.vm.network :private_network, ip: $network["centos63"]
     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"
@@ -67,10 +83,10 @@ Vagrant.configure("2") do |config|
   config.vm.define :omnios do | config |
     config.vm.box = "omnios"
     config.vm.guest = :solaris
-    config.vm.network :private_network, ip: "192.168.100.9"
+    config.vm.network :private_network, ip: $network["omnios"]
     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"
+    config.vm.provision :shell, :path => "contrib/manifests/omnios.sh"
   end
 
 end


[24/50] git commit: TS-1787 Eliminate old ink_time code (was probably only used by the now obsolete Web UI). This fixes compiling with gcc 4.8 as well.

Posted by zw...@apache.org.
TS-1787 Eliminate old ink_time code (was probably only used by the
now obsolete Web UI). This fixes compiling with gcc 4.8 as well.


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

Branch: refs/heads/3.3.x
Commit: 7f4bd7b9bce58cc811800c736115cf8f5b127cce
Parents: 662cd1a
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Apr 2 16:55:58 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7f4bd7b9/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 70e5bff..b8321b1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1787] Eliminate old ink_time code (was probably only used by the
+   now obsolete Web UI). This fixes compiling with gcc 4.8 as well.
+
   *) [TS-1067] Remove unused config (and code) for bandwidth management.
 
   *) [TS-1736] Fatal() terminates process without a backtrace


[07/50] git commit: Add .dirstamp and CRUFT.txt to RAT exclusion list

Posted by zw...@apache.org.
Add .dirstamp and CRUFT.txt to RAT exclusion list


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

Branch: refs/heads/3.3.x
Commit: 8e94fa7e161da1c0bbdafa65f0205db5fc38082c
Parents: 20c6a45
Author: Uri Shachar <us...@apache.org>
Authored: Tue Apr 2 15:34:30 2013 +0300
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:42 2013 -0600

----------------------------------------------------------------------
 ci/rat-excludes.txt |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8e94fa7e/ci/rat-excludes.txt
----------------------------------------------------------------------
diff --git a/ci/rat-excludes.txt b/ci/rat-excludes.txt
index 4155095..6a7d24a 100644
--- a/ci/rat-excludes.txt
+++ b/ci/rat-excludes.txt
@@ -9,6 +9,7 @@ proxy/config/
 **/*.la
 **/*.lai
 **/*.lo
+**/.dirstamp
 **/Makefile
 **/TODO
 .vimrc
@@ -18,6 +19,7 @@ proxy/config/
 .indent.pro
 aclocal.m4
 CHANGES
+CRUFT.txt
 autom4te.cache/
 build/
 LAYOUT


[39/50] git commit: Clean up --enable-reclaimable-freelist help string

Posted by zw...@apache.org.
Clean up --enable-reclaimable-freelist help string


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

Branch: refs/heads/3.3.x
Commit: 8487fe9943a386a95f0ebfa7824eb746d8c3358a
Parents: ca7cb51
Author: James Peach <jp...@apache.org>
Authored: Wed Apr 3 09:53:07 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:44 2013 -0600

----------------------------------------------------------------------
 configure.ac |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8487fe99/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 72e60b0..7a6145a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -384,10 +384,9 @@ AC_SUBST(use_freelist)
 #
 if test "x${enable_freelist}" = "xyes"; then
   AC_MSG_CHECKING([whether to enable reclaimable freelist])
-  AC_ARG_ENABLE([reclaimable_freelist],
+  AC_ARG_ENABLE([reclaimable-freelist],
 		[AS_HELP_STRING([--enable-reclaimable-freelist],
-				[turn on reclaimable freelist, this option is effective
-				 only when freelist is enable])],
+				[enable reclaimable freelist support (effective only when freelist is enabled)])],
 		[],
 		[enable_recalimable_freelist="yes"])
   AC_MSG_RESULT([$enable_reclaimable_freelist])


[16/50] git commit: TS-1067 Remove the UDPWorkContinuation code

Posted by zw...@apache.org.
TS-1067 Remove the UDPWorkContinuation code


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

Branch: refs/heads/3.3.x
Commit: dc7c12f1411fdce80ab3384c9e92366b5af4265d
Parents: 959235e
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Mar 26 08:39:06 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

----------------------------------------------------------------------
 iocore/net/I_UDPConnection.h |    9 +-
 iocore/net/I_UDPNet.h        |    8 --
 iocore/net/P_UDPNet.h        |   34 -------
 iocore/net/UnixUDPNet.cc     |  199 -------------------------------------
 4 files changed, 4 insertions(+), 246 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dc7c12f1/iocore/net/I_UDPConnection.h
----------------------------------------------------------------------
diff --git a/iocore/net/I_UDPConnection.h b/iocore/net/I_UDPConnection.h
index ab55181..045f376 100644
--- a/iocore/net/I_UDPConnection.h
+++ b/iocore/net/I_UDPConnection.h
@@ -97,12 +97,11 @@ public:
   /**
      Put socket on net queue for read/write polling.
 
-     Not required for UDPConnections created with
-     UDPNetProcessor::UDPBind
+     Not required for UDPConnections created with UDPNetProcessor::UDPBind
 
-     Required for UDPNetProcessor::UDPCreatePortPairs  and
-     UDPNetProcessor::CreateUDPSocket.  They  don't do bindToThread()
-     automatically so that the sockets can be passed to other Continuations.
+     Required for  and UDPNetProcessor::CreateUDPSocket.  They  don't do
+     bindToThread() automatically so that the sockets can be passed to
+     other Continuations.
   */
   void bindToThread(Continuation * c);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dc7c12f1/iocore/net/I_UDPNet.h
----------------------------------------------------------------------
diff --git a/iocore/net/I_UDPNet.h b/iocore/net/I_UDPNet.h
index d9dc38b..5497fbd 100644
--- a/iocore/net/I_UDPNet.h
+++ b/iocore/net/I_UDPNet.h
@@ -84,14 +84,6 @@ public:
   // The mess again: the complier won't let me stick UDPConnection here.
   void UDPClassifyConnection(Continuation * udpConn, IpAddr const& addr);
 
-  // create pairs of UDPConnections in which the first connection is
-  // on a even-#'ed port and the second connection is on the next
-  // odd-#'ed port.  Create "nPairs" of such connections.
-  Action *UDPCreatePortPairs(Continuation *, int nPairs,
-    sockaddr const* local_addr,
-    sockaddr const* remote_addr,
-    int send_bufsize = 0, int recv_bufsize = 0);
-
   // Regarding sendto_re, sendmsg_re, recvfrom_re:
   // * You may be called back on 'c' with completion or error status.
   // * 'token' is an opaque which can be used by caller to match up the I/O

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dc7c12f1/iocore/net/P_UDPNet.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_UDPNet.h b/iocore/net/P_UDPNet.h
index 8a3cfb8..31a2492 100644
--- a/iocore/net/P_UDPNet.h
+++ b/iocore/net/P_UDPNet.h
@@ -386,38 +386,4 @@ struct InkPipeInfo
 
 extern InkPipeInfo G_inkPipeInfo;
 
-class UDPWorkContinuation:public Continuation
-{
-public:
-  UDPWorkContinuation():cont(NULL), numPairs(0), 
-    sendbufsize(0), recvbufsize(0), udpConns(NULL), resultCode(NET_EVENT_DATAGRAM_OPEN)
-  {
-    memset(&local_ip, 0, sizeof(local_ip));
-    memset(&remote_ip, 0, sizeof(remote_ip));
-  };
-  ~UDPWorkContinuation() {
-  };
-  void init(Continuation * c, int num_pairs,
-    sockaddr const* local_ip,
-    sockaddr const* remote_ip,
-    int s_bufsize, int r_bufsize);
-  int StateCreatePortPairs(int event, void *data);
-  int StateDoCallback(int event, void *data);
-
-  Action action;
-
-private:
-  Continuation * cont;
-  int numPairs;
-  IpEndpoint local_ip; ///< replaces myIP.
-  IpEndpoint remote_ip; ///< replaces destIP.
-  int sendbufsize, recvbufsize;
-  UnixUDPConnection **udpConns;
-  int resultCode;
-};
-
-typedef int (UDPWorkContinuation::*UDPWorkContinuation_Handler) (int, void *);
-
-inkcoreapi extern ClassAllocator<UDPWorkContinuation> udpWorkContinuationAllocator;
-
 #endif //__P_UDPNET_H_

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dc7c12f1/iocore/net/UnixUDPNet.cc
----------------------------------------------------------------------
diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc
index 73dc0f6..79dd8da 100644
--- a/iocore/net/UnixUDPNet.cc
+++ b/iocore/net/UnixUDPNet.cc
@@ -35,9 +35,6 @@
 typedef int (UDPNetHandler::*UDPNetContHandler) (int, void *);
 
 inkcoreapi ClassAllocator<UDPPacketInternal> udpPacketAllocator("udpPacketAllocator");
-
-inkcoreapi ClassAllocator<UDPWorkContinuation> udpWorkContinuationAllocator("udpWorkContinuationAllocator");
-
 EventType ET_UDP;
 
 #if defined(linux) && !defined(DEBUG)
@@ -514,23 +511,6 @@ UDPNetProcessor::sendto_re(Continuation * cont,
   }
 }
 
-Action *
-UDPNetProcessor::UDPCreatePortPairs(
-  Continuation * cont,
-  int nPairs,
-  sockaddr const* local_addr,
-  sockaddr const* remote_addr,
-  int send_bufsize, int recv_bufsize
-) {
-
-  UDPWorkContinuation *worker = udpWorkContinuationAllocator.alloc();
-  // UDPWorkContinuation *worker = NEW(new UDPWorkContinuation);
-
-  worker->init(cont, nPairs, local_addr, remote_addr, send_bufsize, recv_bufsize);
-  eventProcessor.schedule_imm(worker, ET_UDP);
-  return &(worker->action);
-}
-
 
 bool
 UDPNetProcessor::CreateUDPSocket(
@@ -1135,182 +1115,3 @@ UDPNetHandler::mainNetEvent(int event, Event * e)
 
   return EVENT_CONT;
 }
-
-/////////////////////////////////////////////////////////////////////
-//
-// A helper continuation that creates a pair of UDP ports in a non-blocking
-// way.  This continuation runs on the UDP thread; a run lasts for at most 500ms.
-//
-/////////////////////////////////////////////////////////////////////
-
-void
-UDPWorkContinuation::init(Continuation * c, int num_pairs,
-  sockaddr const* local_addr,
-  sockaddr const* remote_addr,
-  int s_bufsize, int r_bufsize
-) {
-  mutex = c->mutex;
-  cont = c;
-  action = c;
-  numPairs = num_pairs;
-  ats_ip_copy(&local_ip, local_addr);
-  ats_ip_copy(&remote_ip, remote_addr);
-  sendbufsize = s_bufsize;
-  recvbufsize = r_bufsize;
-  udpConns = NULL;
-  SET_HANDLER((UDPWorkContinuation_Handler) & UDPWorkContinuation::StateCreatePortPairs);
-}
-
-int
-UDPWorkContinuation::StateCreatePortPairs(int event, void *data)
-{
-  NOWARN_UNUSED(event);
-  NOWARN_UNUSED(data);
-//  int res = 0;
-  int numUdpPorts = 2 * numPairs;
-  int fd1 = -1, fd2 = -1;
-  IpEndpoint target;
-  IpEndpoint myaddr1, myaddr2;
-  int portNum, i;
-//  int myaddr_len = sizeof(myaddr1);
-  static int lastAllocPort = 10000;
-  ink_hrtime startTime, endTime;
-  Action *status;
-  //epoll changes
-
-  PollCont *pc = NULL;
-  //epoll changes ends here
-  ink_debug_assert(mutex->thread_holding == this_ethread());
-
-  if (action.cancelled) {
-    action = NULL;
-    mutex = NULL;
-    udpWorkContinuationAllocator.free(this);
-    return EVENT_CONT;
-  }
-
-  startTime = ink_get_hrtime_internal();
-  ats_ip_copy(&target, &remote_ip);
-
-  udpConns = NEW(new UnixUDPConnection *[numUdpPorts]);
-  for (i = 0; i < numUdpPorts; i++)
-    udpConns[i] = NULL;
-  ink_atomic_swap(&portNum, lastAllocPort);
-  portNum %= 50000;
-  if (portNum == 0)
-    portNum = 10000;
-
-  i = 0;
-  while (i < numUdpPorts) {
-
-    int myaddr1_len = sizeof(myaddr1);
-    int myaddr2_len = sizeof(myaddr2);
-    ats_ip_port_cast(&target) = htons(portNum);
-    if (udpNet.CreateUDPSocket(&fd1, 
-        &target.sa, 
-        &myaddr1.sa,
-        &myaddr1_len,
-        &status, sendbufsize, recvbufsize)) {
-      ats_ip_port_cast(&target) = htons(portNum + 1);
-      if (udpNet.CreateUDPSocket(&fd2, 
-        &target.sa, 
-        &myaddr2.sa,
-        &myaddr2_len,
-        &status, sendbufsize, recvbufsize)) {
-        udpConns[i] = NEW(new UnixUDPConnection(fd1));        // new_UnixUDPConnection(fd1);
-        udpConns[i]->setBinding(&myaddr1.sa);
-        i++;
-        udpConns[i] = NEW(new UnixUDPConnection(fd2));        // new_UnixUDPConnection(fd2);
-        udpConns[i]->setBinding(&myaddr2.sa);
-        i++;
-        // remember the last alloc'ed port
-        ink_atomic_swap(&lastAllocPort, portNum + 2);
-      } else {
-        if (fd1 != NO_FD)
-          socketManager.close(fd1);
-        if (status == ACTION_IO_ERROR)
-          goto Lerror;
-      }
-      Debug("udpnet", "Created port pair with ports = %d, %d", portNum, portNum + 1);
-    } else if (status == ACTION_IO_ERROR)
-      goto Lerror;
-    // pick the next port pair value
-    portNum += 2;
-    // wrap around at 50K
-    portNum %= 50000;
-    if (portNum == 0)
-      portNum = 10000;
-    endTime = ink_get_hrtime_internal();
-    // if we spend more than 500 ms. bail!
-    if (ink_hrtime_to_msec(endTime - startTime) > 500) {
-      status = ACTION_IO_ERROR;
-      goto Lerror;
-    }
-
-  }
-
-  for (i = 0; i < numUdpPorts; i++) {
-    udpNet.UDPClassifyConnection(udpConns[i], IpAddr(target));
-    Debug("udpnet-pipe", "Adding (port = %d) to Pipe class: %d",
-          udpConns[i]->getPortNum(), udpConns[i]->pipe_class);
-  }
-
-  // assert should *never* fire; we check for this at the begin of the func.
-  ink_assert(!action.cancelled);
-
-  // Bind to threads only on a success.  Currently, after you have
-  // bound to have a thread, the only way to remove a UDPConnection is
-  // to call destroy(); the thread to which the UDPConnection will
-  // remove the connection from a linked list and call delete.
-
-  for (i = 0; i < numUdpPorts; i++) {
-    udpConns[i]->bindToThread(cont);
-    pc = get_UDPPollCont(udpConns[i]->ethread);
-    udpConns[i]->ep.start(pc->pollDescriptor, udpConns[i], EVENTIO_READ);
-  }
-
-  resultCode = NET_EVENT_DATAGRAM_OPEN;
-  goto out;
-
-Lerror:
-  resultCode = NET_EVENT_DATAGRAM_ERROR;
-  for (i = 0; i < numUdpPorts; i++)
-    delete udpConns[i];
-  delete[] udpConns;
-  udpConns = NULL;
-
-out:
-  SET_HANDLER((UDPWorkContinuation_Handler) & UDPWorkContinuation::StateDoCallback);
-  return StateDoCallback(0, NULL);
-}
-
-int
-UDPWorkContinuation::StateDoCallback(int event, void *data)
-{
-  NOWARN_UNUSED(event);
-  NOWARN_UNUSED(data);
-  MUTEX_TRY_LOCK(lock, action.mutex, this_ethread());
-  if (!lock) {
-    this_ethread()->schedule_in(this, MUTEX_RETRY_DELAY);
-    return EVENT_CONT;
-  }
-  if (!action.cancelled) {
-    action.continuation->handleEvent(resultCode, udpConns);
-  } else {
-    // else action.cancelled
-    if (resultCode == NET_EVENT_DATAGRAM_OPEN) {
-      for (int i = 0; i < numPairs * 2; i++)
-        // don't call delete on individual connections; the udp thread will do
-        // that when it cleans up an fd.
-        udpConns[i]->destroy();
-      delete[]udpConns;       // I think this is OK to delete the array, what we shouldn't do is loop over
-      udpConns = NULL;        // the conns and and do delete udpConns[i].
-    }
-  }
-
-  action = NULL;
-  mutex = NULL;
-  udpWorkContinuationAllocator.free(this);
-
-  return EVENT_CONT;
-}


[32/50] git commit: Teach vagrant that omnios is solaris

Posted by zw...@apache.org.
Teach vagrant that omnios is solaris


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

Branch: refs/heads/3.3.x
Commit: fa3ae7e7cb0844625381aa99c8b8b7b1329fc92d
Parents: ca07fdf
Author: James Peach <jp...@apache.org>
Authored: Tue Apr 2 18:40:16 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:44 2013 -0600

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa3ae7e7/Vagrantfile
----------------------------------------------------------------------
diff --git a/Vagrantfile b/Vagrantfile
index 8c7c755..85998e6 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -66,6 +66,7 @@ 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.guest = :solaris
     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"


[38/50] git commit: TS-1067 Fix the code around the proxy.config.udp.theads option

Posted by zw...@apache.org.
TS-1067 Fix the code around the proxy.config.udp.theads option


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

Branch: refs/heads/3.3.x
Commit: ca7cb51e06ca01dd431aea901adccb8c0db23398
Parents: ba09198
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed Apr 3 10:14:11 2013 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:44 2013 -0600

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ca7cb51e/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index 05c3bc4..9cff6f3 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -1639,7 +1639,7 @@ main(int argc, char **argv)
 
     // UDP net-threads are turned off by default.
     if (!num_of_udp_threads)
-      TS_ReadConfigInteger(num_of_udp_threads, "proxy.config.ssl.number.threads");
+      TS_ReadConfigInteger(num_of_udp_threads, "proxy.config.udp.threads");
     if (num_of_udp_threads)
       udpNet.start(num_of_udp_threads);
 


[42/50] git commit: filename_to_string doesn't need to strdup

Posted by zw...@apache.org.
filename_to_string doesn't need to strdup


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

Branch: refs/heads/3.3.x
Commit: 922c3011fc76d25cfba739796d1c2e235575b251
Parents: 8fa72bf
Author: James Peach <jp...@apache.org>
Authored: Fri Mar 29 13:53:08 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:44 2013 -0600

----------------------------------------------------------------------
 mgmt/api/CfgContextUtils.cc |   64 +++++++++----------------------------
 mgmt/api/CfgContextUtils.h  |    2 +-
 mgmt/api/CoreAPI.cc         |    7 +---
 mgmt/api/include/mgmtapi.h  |    2 +-
 4 files changed, 20 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/922c3011/mgmt/api/CfgContextUtils.cc
----------------------------------------------------------------------
diff --git a/mgmt/api/CfgContextUtils.cc b/mgmt/api/CfgContextUtils.cc
index 32cb139..7e458e7 100644
--- a/mgmt/api/CfgContextUtils.cc
+++ b/mgmt/api/CfgContextUtils.cc
@@ -1413,57 +1413,25 @@ round_robin_type_to_string(TSRrT rr)
  *----------------------------------------------------------------------------
  * TSFileNameT ==> string
  */
-char *
+const char *
 filename_to_string(TSFileNameT file)
 {
   switch (file) {
-  case TS_FNAME_CACHE_OBJ:
-    return ats_strdup("cache.config");
-
-  case TS_FNAME_CONGESTION:
-    return ats_strdup("congestion.config");
-
-  case TS_FNAME_HOSTING:
-    return ats_strdup("hosting.config");
-
-  case TS_FNAME_ICP_PEER:
-    return ats_strdup("icp.config");
-
-  case TS_FNAME_IP_ALLOW:
-    return ats_strdup("ip_allow.config");
-
-
-  case TS_FNAME_LOGS_XML:
-    return ats_strdup("logs_xml.config");
-
-  case TS_FNAME_PARENT_PROXY:
-    return ats_strdup("parent.config");
-
-  case TS_FNAME_VOLUME:
-    return ats_strdup("volume.config");
-
-  case TS_FNAME_PLUGIN:
-    return ats_strdup("plugin.config");
-
-  case TS_FNAME_REMAP:
-    return ats_strdup("remap.config");
-
-  case TS_FNAME_SOCKS:
-    return ats_strdup("socks.config");
-
-  case TS_FNAME_SPLIT_DNS:
-    return ats_strdup("splitdns.config");
-
-  case TS_FNAME_STORAGE:
-    return ats_strdup("storage.config");
-
-  case TS_FNAME_UPDATE_URL:
-    return ats_strdup("update.config");
-
-  case TS_FNAME_VADDRS:
-    return ats_strdup("vaddrs.config");
-
-
+  case TS_FNAME_CACHE_OBJ:    return "cache.config";
+  case TS_FNAME_CONGESTION:   return "congestion.config";
+  case TS_FNAME_HOSTING:      return "hosting.config";
+  case TS_FNAME_ICP_PEER:     return "icp.config";
+  case TS_FNAME_IP_ALLOW:     return "ip_allow.config";
+  case TS_FNAME_LOGS_XML:     return "logs_xml.config";
+  case TS_FNAME_PARENT_PROXY: return "parent.config";
+  case TS_FNAME_VOLUME:       return "volume.config";
+  case TS_FNAME_PLUGIN:       return "plugin.config";
+  case TS_FNAME_REMAP:        return "remap.config";
+  case TS_FNAME_SOCKS:        return "socks.config";
+  case TS_FNAME_SPLIT_DNS:    return "splitdns.config";
+  case TS_FNAME_STORAGE:      return "storage.config";
+  case TS_FNAME_UPDATE_URL:   return "update.config";
+  case TS_FNAME_VADDRS:       return "vaddrs.config";
   default:                     /* no such config file */
     return NULL;
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/922c3011/mgmt/api/CfgContextUtils.h
----------------------------------------------------------------------
diff --git a/mgmt/api/CfgContextUtils.h b/mgmt/api/CfgContextUtils.h
index 8e91f9b..b6fc86d 100644
--- a/mgmt/api/CfgContextUtils.h
+++ b/mgmt/api/CfgContextUtils.h
@@ -119,7 +119,7 @@ TSRrT string_to_round_robin_type(const char *rr);
 char *round_robin_type_to_string(TSRrT rr);
 
 /* TSFileNameT <==> string */
-char *filename_to_string(TSFileNameT file);
+const char *filename_to_string(TSFileNameT file);
 
 TSCongestionSchemeT string_to_congest_scheme_type(const char *scheme);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/922c3011/mgmt/api/CoreAPI.cc
----------------------------------------------------------------------
diff --git a/mgmt/api/CoreAPI.cc b/mgmt/api/CoreAPI.cc
index c5a1a21..f1aeae3 100644
--- a/mgmt/api/CoreAPI.cc
+++ b/mgmt/api/CoreAPI.cc
@@ -534,7 +534,7 @@ MgmtRecordSetString(const char *rec_name, const char *string_val, TSActionNeedT
 TSError
 ReadFile(TSFileNameT file, char **text, int *size, int *version)
 {
-  char *fname;
+  const char *fname;
   Rollback *file_rb;
   int ret, old_file_len;
   textBuffer *old_file_content;
@@ -551,10 +551,8 @@ ReadFile(TSFileNameT file, char **text, int *size, int *version)
   ret = configFiles->getRollbackObj(fname, &file_rb);
   if (ret != TRUE) {
     Debug("FileOp", "[get_lines_from_file] Can't get Rollback for file: %s\n", fname);
-    ats_free(fname);
     return TS_ERR_READ_FILE;
   }
-  ats_free(fname);
   ver = file_rb->getCurrentVersion();
   file_rb->getVersion(ver, &old_file_content);
   *version = ver;
@@ -586,7 +584,7 @@ ReadFile(TSFileNameT file, char **text, int *size, int *version)
 TSError
 WriteFile(TSFileNameT file, char *text, int size, int version)
 {
-  char *fname;
+  const char *fname;
   Rollback *file_rb;
   textBuffer *file_content;
   int ret;
@@ -603,7 +601,6 @@ WriteFile(TSFileNameT file, char *text, int size, int version)
     mgmt_log(stderr, "[CfgFileIO::WriteFile] ERROR getting rollback object\n");
     //goto generate_error_msg;
   }
-  ats_free(fname);
 
   // if version < 0 then, just use next version in sequence;
   // otherwise check if trying to commit an old version

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/922c3011/mgmt/api/include/mgmtapi.h
----------------------------------------------------------------------
diff --git a/mgmt/api/include/mgmtapi.h b/mgmt/api/include/mgmtapi.h
index 0e9c45e..9e38380 100644
--- a/mgmt/api/include/mgmtapi.h
+++ b/mgmt/api/include/mgmtapi.h
@@ -368,7 +368,7 @@ extern "C"
     TS_FNAME_IP_ALLOW,         /* ip_allow.config */
     TS_FNAME_LOGS_XML,         /* logs_xml.config */
     TS_FNAME_PARENT_PROXY,     /* parent.config */
-    TS_FNAME_VOLUME,        /* volume.config */
+    TS_FNAME_VOLUME,           /* volume.config */
     TS_FNAME_PLUGIN,           /* plugin.config */
     TS_FNAME_REMAP,            /* remap.config */
     TS_FNAME_SOCKS,            /* socks.config */


[06/50] git commit: TS-1736: Fatal() terminates process without a backtrace

Posted by zw...@apache.org.
TS-1736: Fatal() terminates process without a backtrace

The root casue is that cleanup_func() was called before logging
backtrace in Diags::error(), however cleanup_func() would terminate
process by calling exit() directly.


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

Branch: refs/heads/3.3.x
Commit: dbe42413cbda864f31552d1f2544f8d489e1f2f5
Parents: 7f7c388
Author: Yunkai Zhang <yu...@gmail.com>
Authored: Tue Apr 2 11:56:30 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:42 2013 -0600

----------------------------------------------------------------------
 CHANGES                    |    5 ++++-
 mgmt/LocalManager.cc       |    6 ++----
 mgmt/LocalManager.h        |    2 +-
 mgmt/Main.cc               |    3 ++-
 mgmt/api/CoreAPI.cc        |    2 +-
 mgmt/cluster/ClusterCom.cc |    4 ++--
 mgmt/utils/MgmtUtils.cc    |    2 +-
 7 files changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dbe42413/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 9883ad7..04d63ad 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,9 +2,12 @@
   Changes with Apache Traffic Server 3.3.2
 
 
+  *) [TS-1736] Fatal() terminates process without a backtrace
+    Author: Yunkai Zhang <yu...@gmail.com>
+
   *) [TS-1791] remove m_mutex acquire&release to avoid deadlock in
    ~LogBufferList(). Author: Gang Li <qu...@taobao.com>.
-   
+
   *) [TS-1713] SRV support refine. Now the srv option is able to enable, with
    no crash. Be care, the hostdb.storage_size or ostdb.size need check.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dbe42413/mgmt/LocalManager.cc
----------------------------------------------------------------------
diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc
index 20a711d..aaddf18 100644
--- a/mgmt/LocalManager.cc
+++ b/mgmt/LocalManager.cc
@@ -62,7 +62,7 @@ LocalManager::mgmtCleanup()
 
 
 void
-LocalManager::mgmtShutdown(int status, bool mainThread)
+LocalManager::mgmtShutdown(bool mainThread)
 {
   if (mainThread) {
     mgmt_log("[LocalManager::mgmtShutdown] Executing shutdown request.\n");
@@ -70,7 +70,7 @@ LocalManager::mgmtShutdown(int status, bool mainThread)
     // WCCP TBD: Send a shutdown message to routers.
 
     if (processRunning()) {
-      waitpid(watched_process_pid, &status, 0);
+      waitpid(watched_process_pid, NULL, 0);
 #if defined(linux)
       /* Avert race condition, wait for the thread to complete,
          before getting one more restart process */
@@ -78,9 +78,7 @@ LocalManager::mgmtShutdown(int status, bool mainThread)
       mgmt_sleep_msec(1);
 #endif
     }
-
     mgmtCleanup();
-    _exit(status);
   } else {
     mgmt_shutdown_outstanding = true;
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dbe42413/mgmt/LocalManager.h
----------------------------------------------------------------------
diff --git a/mgmt/LocalManager.h b/mgmt/LocalManager.h
index 92e7d65..8df0640 100644
--- a/mgmt/LocalManager.h
+++ b/mgmt/LocalManager.h
@@ -87,7 +87,7 @@ public:
   void closeProxyPorts();
 
   void mgmtCleanup();
-  void mgmtShutdown(int status, bool mainThread = false);
+  void mgmtShutdown(bool mainThread = false);
   void processShutdown(bool mainThread = false);
   void processRestart();
   void processBounce();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dbe42413/mgmt/Main.cc
----------------------------------------------------------------------
diff --git a/mgmt/Main.cc b/mgmt/Main.cc
index 2463689..3760366 100644
--- a/mgmt/Main.cc
+++ b/mgmt/Main.cc
@@ -798,7 +798,8 @@ main(int argc, char **argv)
     }
 
     if (lmgmt->mgmt_shutdown_outstanding == true) {
-      lmgmt->mgmtShutdown(0, true);
+      lmgmt->mgmtShutdown(true);
+      _exit(0);
     }
 
     if (lmgmt->run_proxy && !lmgmt->processRunning()) { /* Make sure we still have a proxy up */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dbe42413/mgmt/api/CoreAPI.cc
----------------------------------------------------------------------
diff --git a/mgmt/api/CoreAPI.cc b/mgmt/api/CoreAPI.cc
index 43c5f30..c5a1a21 100644
--- a/mgmt/api/CoreAPI.cc
+++ b/mgmt/api/CoreAPI.cc
@@ -256,7 +256,7 @@ Restart(bool cluster)
     // this will kill TM completely;traffic_cop will restart TM/TS
     lmgmt->ccom->sendClusterMessage(CLUSTER_MSG_SHUTDOWN_MANAGER);
   } else {                      // just bounce local proxy
-    lmgmt->mgmtShutdown(0);
+    lmgmt->mgmtShutdown();
   }
 
   return TS_ERR_OKAY;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dbe42413/mgmt/cluster/ClusterCom.cc
----------------------------------------------------------------------
diff --git a/mgmt/cluster/ClusterCom.cc b/mgmt/cluster/ClusterCom.cc
index 4a40c24..6f15a91 100644
--- a/mgmt/cluster/ClusterCom.cc
+++ b/mgmt/cluster/ClusterCom.cc
@@ -273,7 +273,7 @@ drainIncomingChannel(void *arg)
             delete buff;
         } else if (strstr(message, "cmd: shutdown_manager")) {
           mgmt_log("[ClusterCom::drainIncomingChannel] Received manager shutdown request\n");
-          lmgmt->mgmtShutdown(0);
+          lmgmt->mgmtShutdown();
         } else if (strstr(message, "cmd: shutdown_process")) {
           mgmt_log("[ClusterCom::drainIncomingChannel] Received process shutdown request\n");
           lmgmt->processShutdown();
@@ -1789,7 +1789,7 @@ ClusterCom::sendClusterMessage(int msg_type, const char *args)
 
   switch (msg_type) {
   case CLUSTER_MSG_SHUTDOWN_MANAGER:
-    lmgmt->mgmtShutdown(0);
+    lmgmt->mgmtShutdown();
     break;
   case CLUSTER_MSG_SHUTDOWN_PROCESS:
     lmgmt->processShutdown();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dbe42413/mgmt/utils/MgmtUtils.cc
----------------------------------------------------------------------
diff --git a/mgmt/utils/MgmtUtils.cc b/mgmt/utils/MgmtUtils.cc
index 6a5c40e..29d4401 100644
--- a/mgmt/utils/MgmtUtils.cc
+++ b/mgmt/utils/MgmtUtils.cc
@@ -473,7 +473,7 @@ mgmt_cleanup()
 {
 #if defined(LOCAL_MANAGER)
   if (lmgmt != NULL) {
-    lmgmt->mgmtShutdown(1, true);
+    lmgmt->mgmtShutdown(true);
   }
 #endif
 }


[43/50] git commit: TS-1797 improve ClusterMachine::pop_ClusterHandler() when ts starting

Posted by zw...@apache.org.
TS-1797 improve ClusterMachine::pop_ClusterHandler() when ts starting


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

Branch: refs/heads/3.3.x
Commit: ca07fdf95af3c9675aed1a587939bc385d2f8560
Parents: 900cc39
Author: Chen Bin <ku...@taobao.com>
Authored: Wed Apr 3 11:17:22 2013 +0800
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:44 2013 -0600

----------------------------------------------------------------------
 iocore/cluster/ClusterMachine.cc |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ca07fdf9/iocore/cluster/ClusterMachine.cc
----------------------------------------------------------------------
diff --git a/iocore/cluster/ClusterMachine.cc b/iocore/cluster/ClusterMachine.cc
index e4ac7df..a60839f 100644
--- a/iocore/cluster/ClusterMachine.cc
+++ b/iocore/cluster/ClusterMachine.cc
@@ -152,10 +152,17 @@ clusterHandlers(0)
 
 ClusterHandler *ClusterMachine::pop_ClusterHandler(int no_rr)
 {
+  int find = 0;
   int64_t now = rr_count;
   if (no_rr == 0) {
     ink_atomic_increment(&rr_count, 1);
   }
+
+  /* will happen when ts start (cluster connection is not established) */
+  while (!clusterHandlers[now % this->num_connections] && (find < this->num_connections)) {
+    now++;
+    find++;
+  }
   return this->clusterHandlers[now % this->num_connections];
 }
 


[09/50] git commit: TS-1751 when ts have high cpu usage, cluster thread isn't balance

Posted by zw...@apache.org.
TS-1751  when ts have high cpu usage, cluster thread isn't balance


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

Branch: refs/heads/3.3.x
Commit: fa084a6e4d531c83afa1adbdc61940084f86d9fd
Parents: b4f366a
Author: Chen Bin <ku...@taobao.com>
Authored: Tue Apr 2 13:29:21 2013 +0800
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:42 2013 -0600

----------------------------------------------------------------------
 iocore/cluster/ClusterHandlerBase.cc |   70 ++++++++++++++++++++++++----
 iocore/cluster/P_ClusterHandler.h    |    3 +
 2 files changed, 63 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa084a6e/iocore/cluster/ClusterHandlerBase.cc
----------------------------------------------------------------------
diff --git a/iocore/cluster/ClusterHandlerBase.cc b/iocore/cluster/ClusterHandlerBase.cc
index ee8070c..1a4e2ef 100644
--- a/iocore/cluster/ClusterHandlerBase.cc
+++ b/iocore/cluster/ClusterHandlerBase.cc
@@ -984,7 +984,6 @@ ClusterHandler::startClusterEvent(int event, Event * e)
       {
         int proto_major = -1;
         int proto_minor = -1;
-        int failed = 0;
 
         clusteringVersion.AdjustByteOrder();
         /////////////////////////////////////////////////////////////////////////
@@ -1026,6 +1025,64 @@ ClusterHandler::startClusterEvent(int event, Event * e)
         if (!connector)
           id = clusteringVersion._id & 0xffff;
 
+        machine->msg_proto_major = proto_major;
+        machine->msg_proto_minor = proto_minor;
+
+        thread = eventProcessor.eventthread[ET_CLUSTER][id % eventProcessor.n_threads_for_type[ET_CLUSTER]];
+        if (net_vc->thread == thread) {
+          cluster_connect_state = CLCON_CONN_BIND_OK;
+          break;
+        } else { 
+          cluster_connect_state = ClusterHandler::CLCON_CONN_BIND_CLEAR;
+          thread->schedule_in(this, CLUSTER_PERIOD);
+          return EVENT_DONE;
+        }
+      }
+
+    case ClusterHandler::CLCON_CONN_BIND_CLEAR:
+      {
+        //
+        UnixNetVConnection *vc = (UnixNetVConnection *)net_vc; 
+        MUTEX_TRY_LOCK(lock, vc->nh->mutex, e->ethread);
+        MUTEX_TRY_LOCK(lock1, vc->mutex, e->ethread);
+        if (lock && lock1) {
+          vc->ep.stop();
+          vc->nh->open_list.remove(vc);
+          vc->nh = NULL;
+          vc->thread = NULL;
+          cluster_connect_state = ClusterHandler::CLCON_CONN_BIND;
+        } else {
+          thread->schedule_in(this, CLUSTER_PERIOD);
+          return EVENT_DONE;
+        }
+      }
+
+    case ClusterHandler::CLCON_CONN_BIND:
+      {
+        // 
+        NetHandler *nh = get_NetHandler(e->ethread);
+        UnixNetVConnection *vc = (UnixNetVConnection *)net_vc; 
+        MUTEX_TRY_LOCK(lock, nh->mutex, e->ethread);
+        MUTEX_TRY_LOCK(lock1, vc->mutex, e->ethread);
+        if (lock && lock1) {
+          vc->nh = nh;
+          vc->nh->open_list.enqueue(vc);
+          vc->thread = e->ethread;
+          PollDescriptor *pd = get_PollDescriptor(e->ethread);
+          if (vc->ep.start(pd, vc, EVENTIO_READ|EVENTIO_WRITE) < 0) {
+            cluster_connect_state = ClusterHandler::CLCON_DELETE_CONNECT;
+            break;                // goto next state
+          }
+        } else {
+          thread->schedule_in(this, CLUSTER_PERIOD);
+          return EVENT_DONE;
+        }
+      }
+
+    case ClusterHandler::CLCON_CONN_BIND_OK:
+      {
+        int failed = 0;
+
         // include this node into the cluster configuration
         MUTEX_TAKE_LOCK(the_cluster_config_mutex, this_ethread());
         MachineList *cc = the_cluster_config();
@@ -1068,8 +1125,6 @@ failed:
         }
 
         this->needByteSwap = !clusteringVersion.NativeByteOrder();
-        machine->msg_proto_major = proto_major;
-        machine->msg_proto_minor = proto_minor;
 #ifdef NON_MODULAR
         machine_online_APIcallout(ip);
 #endif
@@ -1083,7 +1138,7 @@ failed:
         Note("machine up %hhu.%hhu.%hhu.%hhu:%d, protocol version=%d.%d",
              DOT_SEPARATED(ip), id, clusteringVersion._major, clusteringVersion._minor);
 #endif
-        thread = e->ethread;
+
         read_vcs = NEW((new Queue<ClusterVConnectionBase, ClusterVConnectionBase::Link_read_link>[CLUSTER_BUCKETS]));
         write_vcs = NEW((new Queue<ClusterVConnectionBase, ClusterVConnectionBase::Link_write_link>[CLUSTER_BUCKETS]));
         SET_HANDLER((ClusterContHandler) & ClusterHandler::beginClusterEvent);
@@ -1092,12 +1147,7 @@ failed:
         read.do_iodone_event = true;
         write.do_iodone_event = true;
 
-#ifdef CLUSTER_IMMEDIATE_NETIO
-        e->schedule_every(-CLUSTER_PERIOD);     // Negative event
-#else
-        e->schedule_every(-CLUSTER_PERIOD);
-#endif
-        cluster_periodic_event = e;
+        cluster_periodic_event = thread->schedule_every(this, -CLUSTER_PERIOD);
 
         // Startup the periodic events to process entries in
         //  external_incoming_control.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa084a6e/iocore/cluster/P_ClusterHandler.h
----------------------------------------------------------------------
diff --git a/iocore/cluster/P_ClusterHandler.h b/iocore/cluster/P_ClusterHandler.h
index 979de00..ec0fb22 100644
--- a/iocore/cluster/P_ClusterHandler.h
+++ b/iocore/cluster/P_ClusterHandler.h
@@ -465,6 +465,9 @@ struct ClusterHandler:public ClusterHandlerBase
     CLCON_READ_MSG,
     CLCON_READ_MSG_COMPLETE,
     CLCON_VALIDATE_MSG,
+    CLCON_CONN_BIND_CLEAR,
+    CLCON_CONN_BIND,
+    CLCON_CONN_BIND_OK,
     CLCON_ABORT_CONNECT,
     CLCON_DELETE_CONNECT
   } clcon_state_t;


[35/50] git commit: Drop in libloader code.

Posted by zw...@apache.org.
Drop in libloader code.

Necessary build and docs to follow.


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

Branch: refs/heads/3.3.x
Commit: b18645b324db59753844c502c6440e14d8aa0b3e
Parents: bb75f4a
Author: niq <ni...@apache.org>
Authored: Sat Apr 6 00:32:59 2013 +0100
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:44 2013 -0600

----------------------------------------------------------------------
 plugins/libloader/libloader.c |   85 ++++++++++++++++++++++++++++++++++++
 1 files changed, 85 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b18645b3/plugins/libloader/libloader.c
----------------------------------------------------------------------
diff --git a/plugins/libloader/libloader.c b/plugins/libloader/libloader.c
new file mode 100644
index 0000000..ef84c2f
--- /dev/null
+++ b/plugins/libloader/libloader.c
@@ -0,0 +1,85 @@
+/*****************************************************************************
+ * Copyright (C) 2011-13 Qualys, Inc
+ * Copyright (C) 2013 The Apache Software Foundation
+ *
+ * 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.
+ * QUALYS 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.
+ ****************************************************************************/
+
+/* libloader: load libraries, making all symbols exported
+ * universally visible.  Equivalent to LoadFile in HTTPD.
+ *
+ * Written for ironbee plugin, whose module architecture
+ * is not compatible with trafficserver's plugins.
+ * May be useful for other plugins with non-trivial
+ * library dependencies.
+ */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ts/ts.h>
+
+typedef struct {
+    void *handle;
+    void *next;
+} link_handle;
+
+static link_handle *libs = NULL;
+
+static void unloadlibs(void)
+{
+    link_handle *p = libs;
+    while (p != NULL) {
+        link_handle *next = p->next;
+        dlclose(p->handle);
+        TSfree(p);
+        p = next;
+    }
+    libs = NULL;
+}
+
+void TSPluginInit(int argc, const char *argv[])
+{
+    int i;
+    TSPluginRegistrationInfo info;
+
+    info.plugin_name = (char *)"libloader";
+    info.vendor_name = (char *)"Apache Software Foundation";
+    info.support_email = (char *)"users@trafficserver.apache.org";
+
+    if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS) {
+        TSError("[libloader] Plugin registration failed.\n");
+        return;
+    }
+
+    atexit(unloadlibs);
+
+    for (i = 1; i < argc; ++i) {
+        const char *lib = argv[i];
+        void *handle = dlopen(lib, RTLD_GLOBAL|RTLD_NOW);
+        if (handle) {
+            link_handle *l = TSmalloc(sizeof(link_handle));
+            l->handle = handle;
+            l->next = libs;
+            libs = l;
+            TSDebug("libloader", " loaded %s\n", lib);
+        }
+        else {
+            TSError("[libloader] failed to load %s: %s\n", lib, dlerror());
+        }
+    }
+    return;
+}


[25/50] git commit: TS-1783 Remove the remnants of wpad.dat

Posted by zw...@apache.org.
TS-1783 Remove the remnants of wpad.dat


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

Branch: refs/heads/3.3.x
Commit: cf1550dfd64834ad1ebeb425008d40eb95601a2a
Parents: 7f4bd7b
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed Mar 27 12:29:58 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:43 2013 -0600

----------------------------------------------------------------------
 .../perl/AdminClient/lib/Apache/TS/AdminClient.pm  |    1 -
 mgmt/AddConfigFilesHere.cc                         |    1 -
 mgmt/Main.cc                                       |    3 ---
 mgmt/RecordsConfig.cc                              |    2 --
 mgmt/web2/WebHttp.cc                               |    1 -
 5 files changed, 0 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cf1550df/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm
----------------------------------------------------------------------
diff --git a/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm b/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm
index 1374cf4..82968db 100644
--- a/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm
+++ b/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm
@@ -270,7 +270,6 @@ The Apache Traffic Server Administration Manual will explain what these strings
  proxy.config.admin.autoconf.pac_filename
  proxy.config.admin.autoconf_port
  proxy.config.admin.autoconf.doc_root
- proxy.config.admin.autoconf.wpad_filename
  proxy.config.admin.cli_path
  proxy.config.admin.number_config_bak
  proxy.config.admin.user_id

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cf1550df/mgmt/AddConfigFilesHere.cc
----------------------------------------------------------------------
diff --git a/mgmt/AddConfigFilesHere.cc b/mgmt/AddConfigFilesHere.cc
index 95db5c9..a1e60ae 100644
--- a/mgmt/AddConfigFilesHere.cc
+++ b/mgmt/AddConfigFilesHere.cc
@@ -71,7 +71,6 @@ initializeRegistry()
   configFiles->addFile("storage.config", false);
   configFiles->addFile("socks.config", false);
   configFiles->addFile("proxy.pac", false);
-  configFiles->addFile("wpad.dat", false);
   configFiles->addFile("records.config", false);
   configFiles->addFile("vaddrs.config", false);
   configFiles->addFile("cache.config", false);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cf1550df/mgmt/Main.cc
----------------------------------------------------------------------
diff --git a/mgmt/Main.cc b/mgmt/Main.cc
index 3760366..06f3e6a 100644
--- a/mgmt/Main.cc
+++ b/mgmt/Main.cc
@@ -1056,9 +1056,6 @@ fileUpdated(char *fname)
   } else if (strcmp(fname, "proxy.pac") == 0) {
     mgmt_log(stderr, "[fileUpdated] proxy.pac file has been modified\n");
 
-  } else if (strcmp(fname, "wpad.dat") == 0) {
-    mgmt_log(stderr, "[fileUpdated] wpad.dat file has been modified\n");
-
   } else if (strcmp(fname, "icp.config") == 0) {
     lmgmt->signalFileChange("proxy.config.icp.icp_configuration");
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cf1550df/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index bf9e56a..75464bf 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -259,8 +259,6 @@ RecordElement RecordsConfig[] = {
   ,
   {RECT_CONFIG, "proxy.config.admin.autoconf.pac_filename", RECD_STRING, "proxy.pac", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,
-  {RECT_CONFIG, "proxy.config.admin.autoconf.wpad_filename", RECD_STRING, "wpad.dat", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
-  ,
   {RECT_CONFIG, "proxy.config.admin.admin_user", RECD_STRING, "admin", RECU_DYNAMIC, RR_REQUIRED, RECC_STR, ".+", RECA_NO_ACCESS}
   ,
   {RECT_CONFIG, "proxy.config.admin.number_config_bak", RECD_INT, "3", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cf1550df/mgmt/web2/WebHttp.cc
----------------------------------------------------------------------
diff --git a/mgmt/web2/WebHttp.cc b/mgmt/web2/WebHttp.cc
index 5b331ab..14c0804 100644
--- a/mgmt/web2/WebHttp.cc
+++ b/mgmt/web2/WebHttp.cc
@@ -480,7 +480,6 @@ WebHttpInit()
   // initialize allow files
   g_autoconf_allow_ht = ink_hash_table_create(InkHashTableKeyType_String);
   ink_hash_table_insert(g_autoconf_allow_ht, "/proxy.pac", NULL);
-  ink_hash_table_insert(g_autoconf_allow_ht, "/wpad.dat", NULL);
   ink_hash_table_insert(g_autoconf_allow_ht, "/public_key.der", NULL);
   ink_hash_table_insert(g_autoconf_allow_ht, "/synthetic.txt", NULL);
 


[47/50] git commit: TS-1760: clean up and fix --enable-linux-native-aio

Posted by zw...@apache.org.
TS-1760: clean up and fix --enable-linux-native-aio

Tidy the --enable-linux-native-aio to conform with autoconf
conventions. Use the correct TS_USE_LINUX_NATIVE_AIO macro to enable
Linux AIO support.


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

Branch: refs/heads/3.3.x
Commit: 37ad2c34504fefdbf3cc2ca484e994da0ec95b96
Parents: f85dc19
Author: James Peach <jp...@apache.org>
Authored: Wed Apr 3 09:59:42 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 15 14:45:44 2013 -0600

----------------------------------------------------------------------
 configure.ac       |   29 ++++++++++++++++-------------
 iocore/aio/I_AIO.h |    3 ++-
 2 files changed, 18 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/37ad2c34/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index dbf1679..f237ebe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -397,25 +397,28 @@ TS_ARG_ENABLE_VAR([use], [reclaimable_freelist])
 AC_SUBST(use_reclaimable_freelist)
 
 #
-# If the OS is linux, we can use '--use_linux_native_aio' option to
+# If the OS is linux, we can use the '--enable-linux-native-aio' option to
 # replace the aio thread mode. Effective only on the linux system.
 #
 
-if test "x${host_os_def}" = "xlinux"; then
-  AC_MSG_CHECKING([whether to use native aio or not])
-  AC_ARG_ENABLE([linux_native_aio],
-    [AS_HELP_STRING([--enable-linux-native-aio],
-      [turn on linux native aio, only effective on linux system])],
-    [],
-    [enable_linux_native_aio="yes"])
-  AC_MSG_RESULT([$enable_linux_native_aio])
-else
-  enable_linux_native_aio="no"
-fi
+AC_MSG_CHECKING([whether to enable Linux native AIO])
+AC_ARG_ENABLE([linux-native-aio],
+  [AS_HELP_STRING([--enable-linux-native-aio], [enable native Linux AIO support @<:@default=no@:>@])],
+  [enable_linux_native_aio="${enableval}"],
+  [enable_linux_native_aio=no]
+)
+
+case $host_os in
+  linux*);;
+  *) AS_IF([test "x$enable_linux_native_aio" = "xyes"], [
+      AC_MSG_ERROR([Linux native AIO can only be enabled on Linux systems])
+    ])
+esac
+
+AC_MSG_RESULT([$enable_linux_native_aio])
 TS_ARG_ENABLE_VAR([use], [linux_native_aio])
 AC_SUBST(use_linux_native_aio)
 
-
 # Configure how many stats to allocate for plugins. Default is 512.
 #
 AC_ARG_WITH([max-api-stats],

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/37ad2c34/iocore/aio/I_AIO.h
----------------------------------------------------------------------
diff --git a/iocore/aio/I_AIO.h b/iocore/aio/I_AIO.h
index ccdc078..ef49d93 100644
--- a/iocore/aio/I_AIO.h
+++ b/iocore/aio/I_AIO.h
@@ -47,7 +47,8 @@
 #define AIO_MODE_SYNC            1
 #define AIO_MODE_THREAD          2
 #define AIO_MODE_NATIVE          3
-#if use_linux_native_aio
+
+#if TS_USE_LINUX_NATIVE_AIO
 #define AIO_MODE                 AIO_MODE_NATIVE
 #else
 #define AIO_MODE                 AIO_MODE_THREAD