-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net: sockets: Add locking to receive callback #35466
net: sockets: Add locking to receive callback #35466
Conversation
@pfalcon I did testing with |
cc5a5f5
to
09ff600
Compare
Fix a regression when application is waiting data but does not notice that because socket layer is not woken up. This could happen because application was waiting condition variable but the signal to wake the condvar came before the wait started. Normally if there is constant flow of incoming data to the socket, the signal would be given later. But if the peer is waiting that Zephyr replies, there might be a timeout at peer. The solution is to add locking in socket receive callback so that we only signal the condition variable after we have made sure that the condition variable is actually waiting the data. Fixes zephyrproject-rtos#34964 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If we are waiting all the data i.e., the MSG_WAITALL flag is set, then if we have not yet received all the data at the end of the receive loop. We must use the condition variable to get the signal when the data is ready to be received. Otherwise the receive loop will not release the socket lock and receive_cb will not be able to indicate that data is received. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The k_fifo_ prefix is meant for kernel API functions, and not to our socket helper. So remove the k_ prefix in order to avoid confusion. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
09ff600
to
410c799
Compare
Sorry for the delay with response, I was on vacation. Confirming that that this patch resolved issue with dumb_http_server/qemu_x86 + ab for me. Also retested with big_http_download (as the test for "opposite" transfer direction), and it works as expected. Thanks for investigating this! |
Fix a regression when application is waiting data but does
not notice that because socket layer is not woken up.
This could happen because application was waiting condition
variable but the signal to wake the condvar came before the
wait started. Normally if there is constant flow of incoming
data to the socket, the signal would be given later. But if
the peer is waiting that Zephyr replies, there might be a
timeout at peer.
The solution is to add locking in socket receive callback so
that we only signal the condition variable after we have made
sure that the condition variable is actually waiting the data.
Fixes #34964
Signed-off-by: Jukka Rissanen jukka.rissanen@linux.intel.com