net: sockets: socketpair: do not allow blocking IO in ISR context
Using a socketpair for communication in an ISR is not a great solution, but the implementation should be robust in that case as well. It is not acceptible to block in ISR context, so robustness here means to return -1 to indicate an error, setting errno to `EAGAIN` (which is synonymous with `EWOULDBLOCK`). Fixes #25417 Signed-off-by: Chris Friedt <cfriedt@meta.com>
This commit is contained in:
parent
fa54e3aa1d
commit
d832b04e96
1 changed files with 10 additions and 0 deletions
|
|
@ -460,6 +460,11 @@ static ssize_t spair_write(void *obj, const void *buffer, size_t count)
|
|||
}
|
||||
|
||||
if (will_block) {
|
||||
if (k_is_in_isr()) {
|
||||
errno = EAGAIN;
|
||||
res = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (int signaled = false, result = -1; !signaled;
|
||||
result = -1) {
|
||||
|
|
@ -646,6 +651,11 @@ static ssize_t spair_read(void *obj, void *buffer, size_t count)
|
|||
}
|
||||
|
||||
if (will_block) {
|
||||
if (k_is_in_isr()) {
|
||||
errno = EAGAIN;
|
||||
res = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (int signaled = false, result = -1; !signaled;
|
||||
result = -1) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue