mirror of
https://github.com/versity/scoutfs.git
synced 2026-01-08 21:03:12 +00:00
Don't set ret = -ENOMEM and immediately overwrite.
It's possible that scoutfs_net_alloc_conn() fails due to -ENOMEM, which is legitimately a failure, thus the code here releases the sock again. But the code block here sets `ret = ENOMEM` and then restarts the loop, which immediately sets `ret = kernel_accept()`, thus overwriting the -ENOMEM error value. We can argue that an ENOMEM error situation here is not catastrophical. If this is the first that we're ever receiving an ENOMEM situation here while trying to accept a new client, we can just release the socket and wait for the client to try again. If the kernel at that point still is out of memory to handle the new incoming connection, that will then cascade down and clean up the while listener at that point. The alternative is to let this error path unwind out and break down the listener immediately, something the code today doesn't do. We're keeping the behavior therefore the same. I've opted therefore to replace the `ret = -ENOMEM` assignment with a comment explaining why we're ignoring the error situation here. Signed-off-by: Auke Kok <auke.kok@versity.com>
This commit is contained in:
@@ -1103,9 +1103,15 @@ static void scoutfs_net_listen_worker(struct work_struct *work)
|
||||
conn->notify_down,
|
||||
conn->info_size,
|
||||
conn->req_funcs, "accepted");
|
||||
/*
|
||||
* scoutfs_net_alloc_conn() can fail due to ENOMEM. If this
|
||||
* is the only thing that does so, there's no harm in trying
|
||||
* to see if kernel_accept() can get enough memory to try accepting
|
||||
* a new connection again. If that then fails with ENOMEM, it'll
|
||||
* shut down the conn anyway. So just retry here.
|
||||
*/
|
||||
if (!acc_conn) {
|
||||
sock_release(acc_sock);
|
||||
ret = -ENOMEM;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user