socket-wrapper fd-passing

Stefan Metzmacher metze at
Tue Jun 30 05:33:41 UTC 2020

Hi Anoop,

>> In short, I could successfully run `make test` with changes to work out
>> of a common shared file. Still there is one
>> test(test_thread_echo_tcp_sendmsg_recvmsg, which I added) failing
>> almost consistently on my local system and not on GitLab CI. I have
>> been trying to root cause this failure for quite sometime now(as and
>> when time allows me) without any luck in fixing it. I would love to see
>> another pair of eyes reviewing the changes.
> I guess the problem I described above and the code that tries to
> construct the updated SCM_RIGHTS fd array, seems wrong, as far as I can
> see it only tries to pass the tmp pipe read end, but not the actual fd
> array passed from the caller.
> I tried to get the SCM_RIGHTS passing working here:
> Once I got this working I'll try to integrate this with the rest of your
> patches.

I got the basics working. I took your shared space patches on top, but
that just fails immediately in Samba's make test.

>>> An additional idea would be using temporary anonymous files (maybe
>>> memfd_create() or an similation for it) for shared structures for
>>> passed
>>> sockets. In sendmsg() the sender would move the
>>> socket_info[_container]
>>> structures from malloc'ed memory to an temporary memory file.
>>> This will replace the pipe fd of the original design.
>>> If multiple fd's are passed, the memory file contains an array of
>>> socket_info[_container] structures.
>>> int *socket_fds_idx would be changed to an array of structures
>>> or we have an additional array to store possible fd for the temporary
>>> files and have the destructing code lock at it and select between
>>> free() and munmap()/close().
>>> This design would not require a named file, like the one specified
>> Hm.. this is new to me. I will think about it.
> I guess it means we would need to undo some of the changes we made
> to one array of socket_info structures.
> I'll let you know if I get the basic passing of information via the tmp
> pipe working...

As Samba does not require that the socket is usable from two processes
at the same time, I guess we can take a short cut and just pass
the socket_info structure (an array of them) through the pipe.
That would allow us to have multichannel tested in gitlab/autobuild.
I'll see if I can get this to work. Once we have these basics,
we can try to improve the design to be more generic with shared
structures, when we really need it.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the samba-technical mailing list