[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-bugs] #18362 [Tor]: Tor could use a generic 'handle' / 'weakref' implementation.



#18362: Tor could use a generic 'handle' / 'weakref' implementation.
------------------------+--------------------------------
     Reporter:  nickm   |      Owner:
         Type:  defect  |     Status:  new
     Priority:  High    |  Milestone:  Tor: 0.2.9.x-final
    Component:  Tor     |    Version:
     Severity:  Normal  |   Keywords:  modularity
Actual Points:          |  Parent ID:
       Points:  small   |    Sponsor:  SponsorS
------------------------+--------------------------------
 Frequently we want to have one object have a pointer to another, but we
 don't want to have the first object own the second.  In these cases, we
 need to do one of the following ugly C dances:
    * We make sure that the pointed-to object never outlives the pointing
 object.
    * We make sure that when the pointed-to object is freed, the pointer to
 it is set to NULL.
    * Instead of using a pointer, we use some kind of unique identifier,
 and look up the pointed-to object in a hash table.

 The first two options are error-prone, and the third is slower than
 regular pointer access.

 Instead of these choices, we could use a 'handle' pattern to create a
 standard way to look up objects indirectly; we could use some of the
 tricks from a usual 'weak reference' implementation.  Ideally, we could
 write the interface in such a way as to permit more than one possible
 implementation.

 The branch `weakref` in my public repository has some janky progress
 towards a solution here.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/18362>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs