mirror of
https://github.com/apache/nuttx.git
synced 2026-10-19 04:43:03 +00:00
This commit removes unnecessary file duplication and memory allocation when passing file descriptors through Unix domain sockets, leveraging the new filep reference counting framework. Background: With the new filep framework, file structures (filep) can be safely shared across processes using reference counting. When passing file descriptors through SCM_RIGHTS control messages on local sockets, the previous implementation unnecessarily duplicated the entire file structure. Changes: 1. In local_sendctl() (sender side): - Removed allocation of filep2 structure (kmm_zalloc) - Removed file_dup2() call that copied the file structure - Now directly stores the original filep with its reference count - Eliminates memory allocation overhead and potential failure points 2. In local_recvctl() (receiver side): - Changed from file_close() + kmm_free() to file_put() - file_put() properly decrements reference count and handles cleanup - Consistent with the new filep reference counting model 3. In local_freectl() (cleanup on error): - Changed from file_close() + kmm_free() to file_put() - Ensures proper reference count management during error paths Technical Details: The new filep framework ensures that: - Multiple file descriptors across different processes can reference the same underlying filep structure safely - Reference counting (via file_get/file_put) manages lifetime correctly - The underlying file object is only released when all references are gone This change is safe because file_dup() in the receiver already calls file_get() internally to increment the reference count for the new fd, so the filep remains valid after the sender calls file_put(). Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com> |
||
|---|---|---|
| .. | ||
| arp | ||
| bluetooth | ||
| can | ||
| devif | ||
| icmp | ||
| icmpv6 | ||
| ieee802154 | ||
| igmp | ||
| inet | ||
| ipfilter | ||
| ipforward | ||
| ipfrag | ||
| local | ||
| mld | ||
| nat | ||
| neighbor | ||
| netdev | ||
| netfilter | ||
| netlink | ||
| pkt | ||
| procfs | ||
| route | ||
| rpmsg | ||
| sixlowpan | ||
| socket | ||
| tcp | ||
| udp | ||
| usrsock | ||
| utils | ||
| CMakeLists.txt | ||
| Kconfig | ||
| Makefile | ||
| net_initialize.c | ||