tor-android
tor-android copied to clipboard
add control port buffer so setEvents() can be called anytime
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
STOPPINGandOFF, 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?
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:
- A race condition where the app using tor-android calls
setEvents()beforeTorServicedoes withCIRCcausing which makes the app only receive CIRC events - 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