Beispiel #1
0
RegionSnapshot sparse_region(RegionType region_type,
  void *start_addr, void* permanent_addr, size_t size,
  RegionSnapshot const* ref_region)
{
  simgrid::mc::Process* process = &mc_model_checker->process();

  bool use_soft_dirty = _sg_mc_sparse_checkpoint && _sg_mc_soft_dirty
    && ref_region != nullptr
    && ref_region->storage_type() == simgrid::mc::StorageType::Chunked;

  xbt_assert((((uintptr_t)start_addr) & (xbt_pagesize-1)) == 0,
    "Not at the beginning of a page");
  xbt_assert((((uintptr_t)permanent_addr) & (xbt_pagesize-1)) == 0,
    "Not at the beginning of a page");
  size_t page_count = mc_page_count(size);

  std::vector<std::uint64_t> pagemap;
  const size_t* ref_page_numbers = nullptr;
  if (use_soft_dirty) {
    pagemap.resize(page_count);
    process->read_pagemap(pagemap.data(),
      mc_page_number(nullptr, permanent_addr), page_count);
    ref_page_numbers = ref_region->page_data().pagenos();
  }

  simgrid::mc::ChunkedData page_data(
    mc_model_checker->page_store(), *process, permanent_addr, page_count,
    ref_page_numbers,
    use_soft_dirty ? pagemap.data() : nullptr);

  simgrid::mc::RegionSnapshot region(
    region_type, start_addr, permanent_addr, size);
  region.page_data(std::move(page_data));
  return std::move(region);
}
Beispiel #2
0
void StaticPageHost::ProcessRequest(http::HttpRequest& request,
                                    HttpReply& reply) {

    static const char default_page[] = {"index.html"};
    std::string page = request.uri;
    static const string badbad("..");

    WAR_ASSERT(!page.empty());
    if (page.back() == '/')
        page += default_page;

    if (page.find(badbad)) {
        LOG_WARN << "Possible cracking attempt at URL: " << log::Esc(page)
            << " for site #" << id_
            << request;
        WAR_THROW_T(ExceptionInvalidResource, page);
    }

    IncHitCount(); // Site hit count shared by all uri's.

    if (!boost::filesystem::is_regular_file(page)) {
        LOG_DEBUG_FN << "File not found" << log::Esc(page)
            << ' ' << request;
        WAR_THROW_T(ExceptionInvalidResource, page);
    }

    PageData page_data(page);
    const auto content = page_data.GetData();

    // We will in almost all cases use compression, so it does not make
    // sense to keep the mapped file in memory, unless we implement
    // caching. However, Linux probably does a reasonable good job
    // in that area anyway.
    reply.Out().write(&content[0], content.size());
}