Sarthak-Pandey commented on PR #20702:
URL: https://github.com/apache/nuttx/pull/20702#issuecomment-6502524330
Hi @casaroli,
Thank you so much for the detailed and constructive review! I have addressed
all of your feedback and squashed the changes into a clean commit:
1. **Default CAN send path (`can_sendmsg.c`)**:
- Added multi-`iovec` support to the unbuffered CAN send path by
calculating `total_len` across all `iov` segments, validating against
CAN/CAN-FD MTU, and gathering multiple buffers into a stack buffer (`uint8_t
buf[CANFD_MTU]`) without heap overhead before sending.
- For single-iov sends, zero-copy pointer passthrough is preserved.
2. **TCP send (`inet_sockif.c`)**:
- Gated the sequential zero-allocation loop with `#if
defined(CONFIG_NET_TCP) && defined(CONFIG_NET_TCP_WRITE_BUFFERS)`.
- When write buffers are disabled (`CONFIG_NET_TCP_WRITE_BUFFERS=n`,
default), it preserves the gather-into-one-buffer fallback, preventing
multi-RTT latency from delayed ACKs and eliminating thread-interleaving race
conditions.
3. **`MSG_WAITALL` handling (`local_recvmsg.c`)**:
- Added an inner loop in `local_recvmsg()` to repeatedly read into the
current `iov[i]` buffer until it is completely filled before advancing to
`iov[i + 1]`.
- This ensures contiguous stream data without leaving uninitialized gaps
in previous `iovec` elements when `MSG_WAITALL` is set.
4. **`PIPEIOC_PEEK` (`local_recvmsg.c`)**:
- Reverted the `*readlen = ret;` assignment in `psock_fifo_read` to keep
this PR strictly focused on scatter-gather `msg_iov` transfers and prevent
false EOF returns on empty blocking streams or affecting datagram peek logic.
5. **POSIX Error Codes**:
- Updated all `msg_iovlen == 0` validation checks across the network
stack (`inet_sockif.c`, `can_recvmsg.c`, `can_sendmsg.c`,
`can_sendmsg_buffered.c`, `udp_recvfrom.c`, and `local_recvmsg.c`) to return
standard `-EMSGSIZE` per POSIX.1-2017 specification.
6. **Merge Conflicts Resolved**:
- Resolved conflicts with `master` in `can_recvmsg.c` (preserving the new
`MSG_CONFIRM` check alongside `iob_copyout_iov`) and in
`can_sendmsg_buffered.c` (incorporating the `while (!IOB_QEMPTY(...))` queue
wait loop using `total_len`).
All modified files pass `nxstyle` cleanly with 0 errors and 0 warnings.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]