tor-android icon indicating copy to clipboard operation
tor-android copied to clipboard

add control port buffer so setEvents() can be called anytime

Open eighthave opened this issue 3 years ago • 1 comments

I just had an idea that I think will cover this issue, be relatively easy to implement, and replace this pull request:

  • accept setEvents() calls any time
  • if the control port is not active, cache the value of last setEvents() call
  • after TorService receives the first CIRC event, send the cached setEvents() value
  • further setEvents() calls are sent directly to the control port
  • this buffer should probably be a queue that stores all recieved messages in order and replays them
  • when TorService sends STOPPING and OFF, the queue should be cleared.

This should allow setEvents() calls to work any time.

@n8fr8 @bitmold Should it queue events when it is OFF? Or only when STARTING?

eighthave avatar Apr 29 '22 05:04 eighthave

Replace which pull request? I think there has been some confusion here because at one point in my troubleshooting I had conflated two bugs in tor-android with one another; in the interest of clarity:

  1. A race condition where the app using tor-android calls setEvents() before TorService does with CIRC causing which makes the app only receive CIRC events
  2. The waiting for lock issue, which is separate and pertains to the tor and control socket threads being unable to recover from a crash state

This idea of yours seems like a good approach to the first one. As for your question of OFF and STARTING I think it should only queue calls before TorService calls setEvents

bitmold avatar Apr 29 '22 16:04 bitmold