You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2010/03/27 22:54:16 UTC

svn commit: r928291 - in /incubator/trafficserver/traffic/trunk: iocore/cache/ proxy/hdrs/

Author: jplevyak
Date: Sat Mar 27 21:54:16 2010
New Revision: 928291

URL: http://svn.apache.org/viewvc?rev=928291&view=rev
Log:
TS-281: fix compilation errors, also fix several other instances of long instead of intptr_t
        also increment cache disk magic to get a auto-clear because of format changes in
        URL.h, and comment the layout of the various HdrHeap bits including URL.h
        Lastly, fix a minor problem with Cache::scan when using per-host partitions for
        reverse proxy.

Modified:
    incubator/trafficserver/traffic/trunk/iocore/cache/CachePart.cc
    incubator/trafficserver/traffic/trunk/iocore/cache/I_Cache.h
    incubator/trafficserver/traffic/trunk/iocore/cache/P_CacheDisk.h
    incubator/trafficserver/traffic/trunk/proxy/hdrs/HTTP.h
    incubator/trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.cc
    incubator/trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.h
    incubator/trafficserver/traffic/trunk/proxy/hdrs/MIME.cc
    incubator/trafficserver/traffic/trunk/proxy/hdrs/MIME.h
    incubator/trafficserver/traffic/trunk/proxy/hdrs/URL.cc
    incubator/trafficserver/traffic/trunk/proxy/hdrs/URL.h

Modified: incubator/trafficserver/traffic/trunk/iocore/cache/CachePart.cc
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/iocore/cache/CachePart.cc?rev=928291&r1=928290&r2=928291&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/iocore/cache/CachePart.cc (original)
+++ incubator/trafficserver/traffic/trunk/iocore/cache/CachePart.cc Sat Mar 27 21:54:16 2010
@@ -25,7 +25,7 @@
 
 #include "P_Cache.h"
 
-#define SCAN_BUF_SIZE      (512 * 1024)
+#define SCAN_BUF_SIZE      RECOVERY_SIZE
 #define SCAN_WRITER_LOCK_MAX_RETRY 5
 
 Action *
@@ -44,7 +44,7 @@ Cache::scan(Continuation * cont, char *h
   c->host_len = host_len;
   c->base_stat = cache_scan_active_stat;
   c->buf = new_IOBufferData(BUFFER_SIZE_FOR_XMALLOC(SCAN_BUF_SIZE), MEMALIGNED);
-  c->scan_msec_delay = (512000 / KB_per_second);
+  c->scan_msec_delay = (SCAN_BUF_SIZE / KB_per_second);
   c->offset = 0;
   SET_CONTINUATION_HANDLER(c, &CacheVC::scanPart);
   eventProcessor.schedule_in(c, HRTIME_MSECONDS(c->scan_msec_delay));
@@ -176,6 +176,7 @@ CacheVC::scanObject(int event, Event * e
         continue;
       if (!hostinfo_copied) {
         memccpy(hname, vector.get(i)->request_get()->url_get()->host_get(&hlen), 0, 500);
+        hname[hlen] = 0;
         Debug("cache_scan", "hostname = '%s', hostlen = %d", hname, hlen);
         hostinfo_copied = 1;
       }
@@ -257,6 +258,8 @@ Lread:
   io.aiocb.aio_fildes = part->fd;
   if ((ink_off_t)(io.aiocb.aio_offset + io.aiocb.aio_nbytes) > (ink_off_t)(part->skip + part->len))
     io.aiocb.aio_nbytes = part->skip + part->len - io.aiocb.aio_offset;
+  else
+    io.aiocb.aio_nbytes = SCAN_BUF_SIZE;
   offset = 0;
   ink_assert(ink_aio_read(&io) >= 0);
   return EVENT_CONT;

Modified: incubator/trafficserver/traffic/trunk/iocore/cache/I_Cache.h
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/iocore/cache/I_Cache.h?rev=928291&r1=928290&r2=928291&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/iocore/cache/I_Cache.h (original)
+++ incubator/trafficserver/traffic/trunk/iocore/cache/I_Cache.h Sat Mar 27 21:54:16 2010
@@ -42,6 +42,8 @@
 #define CACHE_WRITE_OPT_SYNC            (CACHE_WRITE_OPT_CLOSE_COMPLETE | 0x0004)
 #define CACHE_WRITE_OPT_OVERWRITE_SYNC  (CACHE_WRITE_OPT_SYNC | CACHE_WRITE_OPT_OVERWRITE)
 
+#define SCAN_KB_PER_SECOND      8192 // 1TB/8MB = 131072 = 36 HOURS to scan a TB
+
 class CacheLookupHttpConfig;
 class CacheVC;
 #ifdef HTTP_CACHE
@@ -88,7 +90,7 @@ struct CacheProcessor:public Processor
                             CacheFragType frag_type = CACHE_FRAG_TYPE_NONE, 
                             bool rm_user_agents = true, bool rm_link = false,
                             char *hostname = 0, int host_len = 0);
-  Action *scan(Continuation *cont, char *hostname = 0, int host_len = 0, int KB_per_second = 2500);
+  Action *scan(Continuation *cont, char *hostname = 0, int host_len = 0, int KB_per_second = SCAN_KB_PER_SECOND);
 #ifdef HTTP_CACHE
   Action *lookup(Continuation *cont, URL *url, bool local_only = false,
                  CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP);

Modified: incubator/trafficserver/traffic/trunk/iocore/cache/P_CacheDisk.h
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/iocore/cache/P_CacheDisk.h?rev=928291&r1=928290&r2=928291&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/iocore/cache/P_CacheDisk.h (original)
+++ incubator/trafficserver/traffic/trunk/iocore/cache/P_CacheDisk.h Sat Mar 27 21:54:16 2010
@@ -40,7 +40,7 @@ extern int cache_config_max_disk_errors;
 #define ROUND_DOWN_TO_STORE_BLOCK(_x)   (((_x) >> STORE_BLOCK_SHIFT) << STORE_BLOCK_SHIFT)
 
 #define STORE_BLOCKS_PER_PART  (PART_BLOCK_SIZE / STORE_BLOCK_SIZE)
-#define DISK_HEADER_MAGIC               0xABCD1235
+#define DISK_HEADER_MAGIC               0xABCD1236
 
 /* each disk part block has a corresponding Part object */
 struct CacheDisk;

Modified: incubator/trafficserver/traffic/trunk/proxy/hdrs/HTTP.h
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/proxy/hdrs/HTTP.h?rev=928291&r1=928290&r2=928291&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/proxy/hdrs/HTTP.h (original)
+++ incubator/trafficserver/traffic/trunk/proxy/hdrs/HTTP.h Sat Mar 27 21:54:16 2010
@@ -258,9 +258,10 @@ enum HTTPType
 
 struct HTTPHdrImpl:public HdrHeapObjImpl
 {
+  // HdrHeapObjImpl is 4 bytes
   HTTPType m_polarity;          // request or response or unknown
   ink32 m_version;              // cooked version number
-
+  // 12 bytes means 4 bytes padding here on 64-bit architectures
   union
   {
     struct

Modified: incubator/trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.cc
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.cc?rev=928291&r1=928290&r2=928291&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.cc (original)
+++ incubator/trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.cc Sat Mar 27 21:54:16 2010
@@ -625,8 +625,7 @@ int
 HdrHeap::marshal(char *buf, int len)
 {
 
-// FIX: replaced unsigned long with portable paddr_t
-  ink_assert((((unsigned long) buf) & HDR_PTR_ALIGNMENT_MASK) == 0);
+  ink_assert((((uintptr_t) buf) & HDR_PTR_ALIGNMENT_MASK) == 0);
 
   HdrHeap *marshal_hdr = (HdrHeap *) buf;
   char *b = buf + HDR_HEAP_HDR_SIZE;
@@ -746,7 +745,6 @@ HdrHeap::marshal(char *buf, int len)
       str_xlation[str_heaps].end = m_ronly_heap[i].m_heap_start + m_ronly_heap[i].m_heap_len;
       str_xlation[str_heaps].offset = str_xlation[str_heaps].start - (b - buf);
       ink_assert(str_xlation[str_heaps].start <= str_xlation[str_heaps].end);
-      // INKqa10130: ink_assert(((long) str_xlation[str_heaps].offset) >= 0); 
 
       str_heaps++;
       b += m_ronly_heap[i].m_heap_len;
@@ -844,11 +842,11 @@ HdrHeap::check_marshalled(inku32 buf_len
     return false;
   }
 
-  if (this->m_size != (unsigned long) this->m_ronly_heap[0].m_heap_start) {
+  if (this->m_size != (uintptr_t) this->m_ronly_heap[0].m_heap_start) {
     return false;
   }
 
-  if ((unsigned long) (this->m_size + m_ronly_heap[0].m_heap_start) > buf_length) {
+  if ((uintptr_t) (this->m_size + m_ronly_heap[0].m_heap_start) > buf_length) {
     return false;
   }
 

Modified: incubator/trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.h
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.h?rev=928291&r1=928290&r2=928291&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.h (original)
+++ incubator/trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.h Sat Mar 27 21:54:16 2010
@@ -87,8 +87,7 @@ extern void obj_describe(HdrHeapObjImpl 
 inline int
 obj_is_aligned(HdrHeapObjImpl * obj)
 {
-// FIX: replace unsigned long with portable paddr_t
-  return (((((unsigned long) obj) & HDR_PTR_ALIGNMENT_MASK) == 0) && ((obj->m_length & HDR_PTR_ALIGNMENT_MASK) == 0));
+  return (((((uintptr_t) obj) & HDR_PTR_ALIGNMENT_MASK) == 0) && ((obj->m_length & HDR_PTR_ALIGNMENT_MASK) == 0));
 }
 
 inline void
@@ -290,7 +289,7 @@ if (ptr) { \
    for (int i = 0; i < nentries; i++) { \
       if (ptr >= table[i].start && \
 	  ptr <= table[i].end) { \
-          ptr =  (((char*)ptr) - (unsigned long) table[i].offset); \
+          ptr =  (((char*)ptr) - (uintptr_t) table[i].offset); \
           found = 1; \
           break; \
       } \
@@ -307,7 +306,7 @@ if (ptr) { \
    int found = 0; \
       if (ptr >= table[0].start && \
 	  ptr <= table[0].end) { \
-          ptr =  (((char*)ptr) - (unsigned long) table[0].offset); \
+          ptr =  (((char*)ptr) - (uintptr_t) table[0].offset); \
           found = 1; \
       } \
    ink_assert(found); \
@@ -324,7 +323,7 @@ if (ptr) { \
    for (int i = 0; i < nentries; i++) { \
       if ((char*) ptr >= table[i].start && \
 	  (char*) ptr <= table[i].end) { \
-          ptr = (type *) (((char*)ptr) - (unsigned long) table[i].offset); \
+          ptr = (type *) (((char*)ptr) - (uintptr_t) table[i].offset); \
           found = 1; \
           break; \
       } \
@@ -340,7 +339,7 @@ if (ptr) { \
    int found = 0; \
       if ((char*) ptr >= table[0].start && \
 	  (char*) ptr <= table[0].end) { \
-          ptr = (type *) (((char*)ptr) - (unsigned long) table[0].offset); \
+          ptr = (type *) (((char*)ptr) - (uintptr_t) table[0].offset); \
           found = 1; \
       } \
    ink_assert(found); \

Modified: incubator/trafficserver/traffic/trunk/proxy/hdrs/MIME.cc
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/proxy/hdrs/MIME.cc?rev=928291&r1=928290&r2=928291&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/proxy/hdrs/MIME.cc (original)
+++ incubator/trafficserver/traffic/trunk/proxy/hdrs/MIME.cc Sat Mar 27 21:54:16 2010
@@ -4097,7 +4097,7 @@ MIMEHdrImpl::marshal(MarshalXlate * ptr_
 }
 
 void
-MIMEHdrImpl::unmarshal(long offset)
+MIMEHdrImpl::unmarshal(intptr_t offset)
 {
   HDR_UNMARSHAL_PTR(m_fblock_list_tail, MIMEFieldBlockImpl, offset);
   m_first_fblock.unmarshal(offset);

Modified: incubator/trafficserver/traffic/trunk/proxy/hdrs/MIME.h
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/proxy/hdrs/MIME.h?rev=928291&r1=928290&r2=928291&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/proxy/hdrs/MIME.h (original)
+++ incubator/trafficserver/traffic/trunk/proxy/hdrs/MIME.h Sat Mar 27 21:54:16 2010
@@ -154,15 +154,16 @@ struct MIMEField
 
 struct MIMEFieldBlockImpl:public HdrHeapObjImpl
 {
-  MIMEFieldBlockImpl *m_next;
+  // HdrHeapObjImpl is 4 bytes
   inku32 m_freetop;
+  MIMEFieldBlockImpl *m_next;
   MIMEField m_field_slots[MIME_FIELD_BLOCK_SLOTS];
   // mime_hdr_copy_onto assumes that m_field_slots is last --
   // don't add any new fields afterit.
 
   // Marshaling Functions
   int marshal(MarshalXlate * ptr_xlate, int num_ptr, MarshalXlate * str_xlate, int num_str);
-  void unmarshal(long offset);
+  void unmarshal(intptr_t offset);
   void move_strings(HdrStrHeap * new_heap);
 
   // Sanity Check Functions
@@ -221,6 +222,7 @@ struct MIMECooked
 
 struct MIMEHdrImpl:public HdrHeapObjImpl
 {
+  // HdrHeapObjImpl is 4 bytes, so this will result in 4 bytes padding
   inku64 m_presence_bits;
   inku32 m_slot_accelerators[4];
 

Modified: incubator/trafficserver/traffic/trunk/proxy/hdrs/URL.cc
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/proxy/hdrs/URL.cc?rev=928291&r1=928290&r2=928291&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/proxy/hdrs/URL.cc (original)
+++ incubator/trafficserver/traffic/trunk/proxy/hdrs/URL.cc Sat Mar 27 21:54:16 2010
@@ -553,7 +553,7 @@ url_type_set(URLImpl * url, unsigned int
 void
 url_called_set(URLImpl * url)
 {
-  url->clean = !url->m_ptr_printed_string;
+  url->m_clean = !url->m_ptr_printed_string;
 }
 
 void
@@ -562,7 +562,7 @@ url_clear_string_ref(URLImpl * url)
   if (url->m_ptr_printed_string) {
     url->m_len_printed_string = 0;
     url->m_ptr_printed_string = NULL;
-    url->clean = true;
+    url->m_clean = true;
   }
   return;
 }
@@ -573,7 +573,7 @@ url_string_get_ref(HdrHeap * heap, URLIm
   if (!url)
     return NULL;
 
-  if (url->m_ptr_printed_string && url->clean) {
+  if (url->m_ptr_printed_string && url->m_clean) {
     if (length)
       *length = url->m_len_printed_string;
     return (char *) url->m_ptr_printed_string;
@@ -591,7 +591,7 @@ url_string_get_ref(HdrHeap * heap, URLIm
     if (length) {
       *length = len;
     }
-    url->clean = true;          //reset since we have url_print()'ed again
+    url->m_clean = true;          //reset since we have url_print()'ed again
     url->m_len_printed_string = len;
     url->m_ptr_printed_string = buf;
     return buf;
@@ -617,7 +617,7 @@ url_string_get(URLImpl * url, Arena * ar
     buf2 = heap->allocate_str(len + 1);
     memcpy(buf2, buf, len);
     buf2[len] = '\0';
-    url->clean = true;          //reset since we have url_print()'ed again
+    url->m_clean = true;          //reset since we have url_print()'ed again
     url->m_len_printed_string = len;
     url->m_ptr_printed_string = buf2;
   }

Modified: incubator/trafficserver/traffic/trunk/proxy/hdrs/URL.h
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/proxy/hdrs/URL.h?rev=928291&r1=928290&r2=928291&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/proxy/hdrs/URL.h (original)
+++ incubator/trafficserver/traffic/trunk/proxy/hdrs/URL.h Sat Mar 27 21:54:16 2010
@@ -46,6 +46,7 @@ enum URLType
 
 struct URLImpl:public HdrHeapObjImpl
 {
+  // HdrHeapObjImpl is 4 bytes
   inku16 m_len_scheme;
   inku16 m_len_user;
   inku16 m_len_password;
@@ -56,6 +57,7 @@ struct URLImpl:public HdrHeapObjImpl
   inku16 m_len_query;
   inku16 m_len_fragment;
   inku16 m_len_printed_string;
+  // 4 + 20 byte = 24, 8 bytes aligned
 
   const char *m_ptr_scheme;
   const char *m_ptr_user;
@@ -66,19 +68,20 @@ struct URLImpl:public HdrHeapObjImpl
   const char *m_ptr_params;
   const char *m_ptr_query;
   const char *m_ptr_fragment;
-  const char *m_ptr_printed_string;     //ebalsa: added for [Bug 2058039]
-  bool clean;                   //ebalsa: added for [Bug 2058039]
+  const char *m_ptr_printed_string;
+  // pointer aligned (4 or 8)
 
   // Tokenized values
   ink16 m_scheme_wks_idx;
   inku16 m_port;
   inku8 m_url_type;             // e.g. FTP or HTTP
   inku8 m_type_code;            // RFC 1738 limits type code to 1 char
+  // 6 bytes
 
-  // adding this member might cause issues with (un)marshalling
-  // and/or memory alignment; this should be checked first if there
-  // are issues with URLImpl objects
   inku16 m_capacity_host;
+  // 8 bytes
+  inku32 m_clean:1;
+  // 8 bytes + 1 bit, will result in padding
 
   // Marshaling Functions
   int marshal(MarshalXlate * str_xlate, int num_xlate);