[BinderTransport] Fix BinderTransport server race conditions (#31654)
* Set `connected_` to true before `SendSetupTransport()` A race happens when the server has already sent setup transport to the client when it's actually not ready. So move `connected_ = true` before `SendSetupTransport()`. However, this may cause another race that `wire_writer_` being used when it's actually not being constructed yet. So add another Notification for others to wait for it to be ready. Note: simply moving `SendSetupTransport()` into the mutex section could potentially cause a deadlock since it's possible that `ProcessTransaction()` being called on the same call chain. This solution is considered a workaround before we figure out a better workable solution. It's not perfect as if the first request sends, e.g., 64K of data, we'll try to send an ACK and the system will still deadlock. Furthermore, this solution makes threads waiting (although the time frame should be very short). * Store `accept_stream_fn` call count and call it later when possible We might be signaled to call `accept_stream_fn` before it has been set. We should memorize this case and call it later once it has been set, or the stream will never be accepted. * Add comments and polish the changepull/31665/head
parent
3be177223e
commit
41a1d49320
4 changed files with 59 additions and 12 deletions
Loading…
Reference in new issue