If we can't read/write any data, the current logic waits until any readable data/write space is available. For example, here is the read wait workflow:
read() -> 0 bytes read
wait()
Check the current readable size in a shared buffer
Loop
Check the current readable size in a shared buffer
Compare 2.ii.a with 2.i
We don't acquire a lock between 1. and 2.i. If new data is arrived between 1. and 2.i, the new data isn't detected. It may cause a deadlock.
If we can't read/write any data, the current logic waits until any readable data/write space is available. For example, here is the read wait workflow:
read()
-> 0 bytes readwait()
We don't acquire a lock between 1. and 2.i. If new data is arrived between 1. and 2.i, the new data isn't detected. It may cause a deadlock.