ffi: arti_rpc_handle API is a bug waiting to happen
Right now, arti_rpc_handle_wait
semantically takes &mut RequestHandle
. Thus, undefined behavior will ensue if two threads try to wait on the same handle at the same time. (In fact, undefined behavior will ensure if one thread tries to wait on a handle while another tries to find out its request ID.)
This is probably not so great. Other possible behaviors:
- We could say that multiple simultaneous waiters are allowed, and that they get responses in an arbitrary order.
- We could say that only one waiter is allowed at a time, but check for attempts by multiple threads to wait on the same request at once, and give an error in that case.
I think that the second behavior is slightly more reasonable. Any other opinions?