This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 0a0065467b27ae0066a820e94f32f0cb30748ba5 Author: Marco Casaroli <[email protected]> AuthorDate: Thu Nov 26 17:00:49 2026 +0100 net/local: Name the FIFOs of a socket pair with a counter. socketpair() gives both ends an internal name, and the FIFOs of the pair get their names from it. The name was "socketpair" and a hexadecimal number that was different in each build and each run. The name shows in F_GETPATH and FIOC_FILEPATH ("local:[name]"), in the file list of /proc/<pid>/group/fd and in the FIFO names in CONFIG_NET_LOCAL_VFS_PATH. So these outputs were long and changed from run to run. Now the name is "socketpair" and a decimal number from a counter: the first pair is socketpair0, the next socketpair1. The counter keeps the name unique, as before. It is an atomic_t, so it needs no lock. The names are short and the same in each run for the same order of socketpair() calls. The behavior is the same in all build modes. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- net/local/local_sockif.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/net/local/local_sockif.c b/net/local/local_sockif.c index 98d09b0c926..082f366d9fc 100644 --- a/net/local/local_sockif.c +++ b/net/local/local_sockif.c @@ -34,6 +34,8 @@ #include <string.h> #include <assert.h> #include <errno.h> +#include <inttypes.h> +#include <nuttx/atomic.h> #include <nuttx/debug.h> #include <nuttx/poll.h> @@ -1183,16 +1185,24 @@ static int local_ioctl(FAR struct socket *psock, int cmd, unsigned long arg) static int local_socketpair(FAR struct socket *psocks[2]) { + static atomic_t g_next_pair_id; FAR struct local_conn_s *conns[2]; + uint32_t id; bool nonblock; int ret; int i; + /* The name only names the FIFOs of the pair. A number from a counter + * keeps it unique. + */ + + id = atomic_add(&g_next_pair_id, 1); + for (i = 0; i < 2; i++) { conns[i] = psocks[i]->s_conn; snprintf(conns[i]->lc_path, - sizeof(conns[i]->lc_path), "socketpair%p", psocks[0]); + sizeof(conns[i]->lc_path), "socketpair%" PRIu32, id); conns[i]->lc_proto = psocks[i]->s_type; conns[i]->lc_type = LOCAL_TYPE_PATHNAME;
