[tor-bugs] #25821 [Core Tor/Stem]: Stem getconf cache doesn't clear for CONF_CHANGED events; probably should set value

Tor Bug Tracker & Wiki blackhole at torproject.org
Mon Apr 16 20:43:56 UTC 2018


#25821: Stem getconf cache doesn't clear for CONF_CHANGED events; probably should
set value
---------------------------+------------------------
 Reporter:  dmr            |          Owner:  atagar
     Type:  defect         |         Status:  new
 Priority:  Medium         |      Milestone:
Component:  Core Tor/Stem  |        Version:
 Severity:  Normal         |     Resolution:
 Keywords:                 |  Actual Points:
Parent ID:                 |         Points:
 Reviewer:                 |        Sponsor:
---------------------------+------------------------

Comment (by dmr):

 So I propose that stem changes its cache behavior to //set// the
 `'getconf'` cache //only// within `_confchanged_listener()`, to the
 value(s) provided by the event.
 It seems superfluous to do it within `set_options()` if it's going to be
 set soon after.

 However, one advantage I could see to setting the cache in `set_options()`
 is so that code like this would work intuitively without issuing a GETCONF
 again:
 {{{
 #!python
 SETCONF ContactInfo=me

 def some_actions_together():
   global controller

   contact_1 = controller.get_conf('ContactInfo')
   controller.set_conf('ContactInfo', 'someone else')
   contact_2 = controller.get_conf('ContactInfo')
   print(contact_2)

 some_actions_together()
 }}}
 But code like this //currently doesn't// work intuitively because
 `load_conf()` doesn't have the configuration values
 [[https://gitweb.torproject.org/torspec.git/tree/control-
 spec.txt?id=d4a64fbf5aaba383638d9f3c70bd2951f8c5ad89#n1365|specified in
 its response]]:
 {{{
 #!python
 SETCONF ContactInfo=me

 def some_actions_together():
   global controller

   contact_1 = controller.get_conf('ContactInfo')

   new_config = controller.get_info('config-text').replace("ContactInfo
 me", "ContactInfo someone else")
   controller.load_conf(new_config)

   contact_2 = controller.get_conf('ContactInfo')

 some_actions_together()
 }}}
 (that could be improved if `load_conf()` clears the `'getconf'` cache.)

 No matter what we pick, I think there's potential for race conditions in
 complex scenarios...

 atagar: thoughts?

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/25821#comment:2>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list