BIND 10 #2850: Define and implement ZoneTableSegmentMapped

BIND 10 Development do-not-reply at isc.org
Mon May 13 08:07:15 UTC 2013


#2850: Define and implement ZoneTableSegmentMapped
-------------------------------------+-------------------------------------
            Reporter:  jinmei        |                        Owner:  muks
                Type:  task          |                       Status:
            Priority:  medium        |  reviewing
           Component:  data source   |                    Milestone:
            Keywords:                |  Sprint-20130514
           Sensitive:  0             |                   Resolution:
         Sub-Project:  DNS           |                 CVSS Scoring:
Estimated Difficulty:  5             |              Defect Severity:  N/A
         Total Hours:  0             |  Feature Depending on Ticket:
                                     |  shared memory data source
                                     |          Add Hours to Ticket:  0
                                     |                    Internal?:  0
-------------------------------------+-------------------------------------

Comment (by muks):

 Replying to [comment:20 jinmei]:
 > one more note: I've noticed another issue with
 > `MemorySegmentMapped::setNamedAddress(Impl)`.  If the underlying
 > segment grows inside this method, the given pointer can be invalidated
 > by the time the storage is allocated.

 Isn't this the same reason why we allocate the name with `NULL` address
 first, and repeat it with the real address after allocation? Or is it some
 other issue?

 > So, I think we need some more trick inside `MemorySegmentMapped`:
 >
 > - create a reserved, internal named address at the time of
 >   construction (in the read-write mode).  assume it's named
 >   "_reserved_set_named_address".
 > - in setNamedAddressImpl(), first store the given address in the
 >   reserved storage.  when the storage for the given name is allocated,
 >   extract the address using the reserved name and set it with the
 >   created name:
 > {{{#!cpp
 > MemorySegmentMapped::setNamedAddressImpl(const char* name, void* addr) {
 >     // validation
 >
 >     offset_ptr<void>* rsvd_storage =
 >         impl_->base_sgmt_->find<offset_ptr<void> >(
 >             "_reserved_set_named_address").first;
 >     assert(rsvd_storage);
 >     *rsvd_storage = addr;
 >
 >     bool grown = false;
 >     while (true) {
 >         offset_ptr<void>* storage =
 >             impl_->base_sgmt_->find_or_construct<offset_ptr<void> >(
 >                 name, std::nothrow)();
 >         if (storage) {
 >             offset_ptr<void>* rsvd_storage =
 >                 impl_->base_sgmt_->find<offset_ptr<void> >(
 >                     "_reserved_set_named_address").first;
 >             assert(rsvd_storage);
 >             *storage = *rsvd_storage;
 >             return (grown);
 >         }
 >
 >         impl_->growSegment();
 >         grown = true;
 >     }
 > }
 > }}}
 >
 > We may also want to specify some set of names (e.g. names beginning
 > with _)are officially reserved and shouldn't be used by apps.

 I've pushed this to the branch.  This commit introduces a problem that
 `allMemoryDeallocated()` doesn't work anymore, because the reserved
 memory is freed only when the segment is destroyed.

 One workaround is to temporarily release and re-reserve this memory in
 `allMemoryDeallocated()`, but that would make it a non-const method.  I
 don't see any other clean way of doing this.

-- 
Ticket URL: <http://bind10.isc.org/ticket/2850#comment:21>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development


More information about the bind10-tickets mailing list