Re: unix_stream_connect and socket address resolution
From: John Ericson <hidden>
Date: 2026-07-19 15:38:04
Also in:
lkml, netdev
Hi David, On Sat, Jul 18, 2026, at 4:58 PM, David Laight wrote:
My $0.02
Thanks for weighing in here.
If you assume that the client isn't responsible for restarting the server, then there is no strong timing relation between creating a new server (by any means) and the connect request from the client. In other words both the above are very similar to the client being preempted at the start of the connect() system call. What you need to do is hard link foo to foo1, create the new socket at foo2/bar then mv foo2 to foo so that it is atomic. But I suspect hard links to directories aren't allowed any more :-( (Creating 'random' hard links to directories used to be 'fun', you could get 'find' in a right mess.) David
I think I am a little confused by your answer. I am not trying to do anything in particular in userland relating to dying and restarting servers. Rather, I am wondering why it was decided (long ago, pre the current repo's git history) for connect to re-resolve the path every loop iteration. I am working on a series of related af_unix refactors, and it would simplify things a lot if I could make `unix_stream_connect` just resolve the path once before the loop, but I do not know if that is an acceptable change in behavior. I was justifying the change in terms of the resolve-once behavior being less surprising in my original email, since that reason stands on its own, with or without my other planned work, but the truth is both that and the ease of refactoring with that change are my motivations. Hope that clarifies things, John