BIND 10 #2831: define and implement MemorySegmentMapped

BIND 10 Development do-not-reply at isc.org
Fri Mar 1 07:23:38 UTC 2013


#2831: define and implement MemorySegmentMapped
-------------------------------------+-------------------------------------
                   Reporter:         |                 Owner:
  jinmei                             |                Status:  new
                       Type:  task   |             Milestone:  Next-Sprint-
                   Priority:         |  Proposed
  medium                             |              Keywords:
                  Component:         |             Sensitive:  0
  Unclassified                       |           Sub-Project:  DNS
               CVSS Scoring:         |  Estimated Difficulty:  0
            Defect Severity:  N/A    |           Total Hours:  0
Feature Depending on Ticket:         |
  shared memory data source          |
        Add Hours to Ticket:  0      |
                  Internal?:  0      |
-------------------------------------+-------------------------------------
 This is one of the obvious backend of #2830.

 It's derived from util::MemorySegment, and has the following methods:

 {{{#!cpp
 class MemorySegmentMapped : public MemorySegment {
     // read-write mode.  if create is true, create a new file if not
     // yet exist.  initial_size specifies the size of the newly created
     // file (and memory region).
     MemorySegmentMmap(const std::string& filename, bool create,
                       size_t initial_size = INITIAL_SIZE_DEFAULT);

     // read only mode
     MemorySegmentMmap(const std::string& filename);

     // These will be used to identify the zone table header part of the
     // segment by associating a specific address with a C-string name.
     // use Boost managed_mapped_file::find_or_construct(), find(),
     // and destroy().  These are virtual and should also be implemented
     // in the "local" segment.  For now, we can return NULL for get
     // and do nothing for others.
     virtual void* getNamedAddress(const char* name);
     virtual void setNamedAddress(const char* name, void* addr);
     virtual void clearNamedAddress(const char* name);

     // It returns a lightweight checksum over the entire mapped region.
     // this will be a better-than-nothing tool to detect corrupt image,
     // and it will also help ensure the entire region is really on memory.
     // any internal implementation is okay as long as it's not heavy;
     // for example, we can simply sum the first byte of each page
     // (managed_mapped_file::get_size() and get_address() can be used).
     // note that this is not a virtual method.
     uint32_t getCheckSum() const;
 };
 }}}

 Internally, use Boost managed_mapped_file object.  One tricky part is
 the implementation of allocate().  It would internally call
 managed_mapped_file::allocate(), but it can fail (and we shouldn't
 give up and grow the region/file size).  You'll first need to destroy
 the original managed_mapped_file object, use
 managed_mapped_file::grow() and re-create managed_mapped_file.
 Consider a reasonable way of the amount of increment.

-- 
Ticket URL: <http://bind10.isc.org/ticket/2831>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development


More information about the bind10-tickets mailing list