In the tsi_accept function, we must release the lock before tsi_accept_inet or tsi_accept_vsock. Otherwise, starvation might occur.
For example, in a thread, call accept() to block and wait for a connection to arrive. At this time, the lock of sock is acquired by the tsi_accept method. Then, in another thread, we are trying to call any syscall, e.g. shutdown(). If no connection comes, the shutdown() never gets a chance to acquire the lock.
I believe that, apart from tsi_accept(), all functions that call another function which might block the operation share this issue.
void tsi_accept() {
lock_sock(sk);
// omitted
release_sock(sk);
// a possible function to block the operation
tsi_accept_inet();
lock_sock(sk);
// omitted
release_sock(sk);
}
@slp Please take a look at this issue. Thanks!
In the
tsi_acceptfunction, we must release the lock beforetsi_accept_inetortsi_accept_vsock. Otherwise, starvation might occur.For example, in a thread, call
accept()to block and wait for a connection to arrive. At this time, the lock of sock is acquired by thetsi_acceptmethod. Then, in another thread, we are trying to call any syscall, e.g.shutdown(). If no connection comes, theshutdown()never gets a chance to acquire the lock.I believe that, apart from
tsi_accept(), all functions that call another function which might block the operation share this issue.@slp Please take a look at this issue. Thanks!