~ubuntu-branches/ubuntu/wily/trafficserver/wily

« back to all changes in this revision

Viewing changes to iocore/cache/CacheDisk.cc

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2012-12-17 22:28:16 UTC
  • mfrom: (5.1.8 raring-proposed)
  • Revision ID: package-import@ubuntu.com-20121217222816-7xwjsx5k76zkb63d
Tags: 3.2.0-1ubuntu1
* Revert FreeBSD strerror_r() fixes that give errors with glibc 2.16.
* Apply patch from Konstantinos Margaritis to define barriers on ARM.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
int
28
28
CacheDisk::open(char *s, off_t blocks, off_t askip, int ahw_sector_size, int fildes, bool clear)
29
29
{
30
 
  path = xstrdup(s);
 
30
  path = ats_strdup(s);
31
31
  hw_sector_size = ahw_sector_size;
32
32
  fd = fildes;
33
33
  skip = askip;
49
49
    start = skip + header_len;
50
50
  }
51
51
 
52
 
  disk_vols = (DiskVol **) xmalloc((l / MIN_VOL_SIZE + 1) * sizeof(DiskVol **));
 
52
  disk_vols = (DiskVol **)ats_malloc((l / MIN_VOL_SIZE + 1) * sizeof(DiskVol **));
53
53
  memset(disk_vols, 0, (l / MIN_VOL_SIZE + 1) * sizeof(DiskVol **));
54
54
  header_len = ROUND_TO_STORE_BLOCK(header_len);
55
55
  start = skip + header_len;
56
56
  num_usable_blocks = (off_t(len * STORE_BLOCK_SIZE) - (start - askip)) >> STORE_BLOCK_SHIFT;
57
57
 
58
 
#if defined(_WIN32)
59
 
  header = (DiskHeader *) malloc(header_len);
60
 
#else
61
 
  header = (DiskHeader *) valloc(header_len);
62
 
#endif
63
 
 
 
58
  header = (DiskHeader *)ats_memalign(sysconf(_SC_PAGESIZE), header_len);
64
59
  memset(header, 0, header_len);
65
60
  if (clear) {
66
61
    SET_HANDLER(&CacheDisk::clearDone);
79
74
CacheDisk::~CacheDisk()
80
75
{
81
76
  if (path) {
82
 
    xfree(path);
 
77
    ats_free(path);
83
78
    for (int i = 0; i < (int) header->num_volumes; i++) {
84
79
      DiskVolBlockQueue *q = NULL;
85
80
      while (disk_vols[i] && (q = (disk_vols[i]->dpb_queue.pop()))) {
86
81
        delete q;
87
82
      }
88
83
    }
89
 
    xfree(disk_vols);
 
84
    ats_free(disk_vols);
90
85
    free(header);
91
86
  }
92
87
  if (free_blocks) {