[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#733452: init system daemon readiness protocol





On Mon, Dec 30, 2013 at 9:38 AM, Ian Jackson <ijackson@chiark.greenend.org.uk> wrote:
(Sorry, 2nd copy here because I missed up the change of To field in the previous one.) cameron writes ("Re: Bug#733452: init system daemon readiness protocol"):
I was curious: why should SOCK_STREAM be used instead of SOCK_DGRAM in your proposed protocol?
SOCK_DGRAM sockets do not offer reliable delivery (at least, not on all unices).

I am pretty sure they are reliable for //local// sockets, at least on Linux.
see this reddit comment: http://www.reddit.com/r/linux/comments/1tya0c/lennarts_take_on_the_proposed_debian_daemon/cecstgq

Have you seen Lennart Poettering's pastebin of a short daemon side implementation of that protocol: http://fpaste.org/64821/32737713/? It meets all your desired criteria, it is used in one init system already, and it is very extensible. Now that you know that systemd does not actually use SOCK_SEQPACKET, but SOCK_DGRAM, do you have any changes in opinion of the systemd approach?
I still think it would be simpler to pass the ready-connected socket (or whatever) to the daemon by inheritance, rather than having the daemon call socket() etc. Do you know why in systemd it was done the way it was ?

Yes, here are Lennart's words:

>We use SOCK_DGRAM because we are interested in the message boundary and to get SCM_CREDENTIALS attached to each datagram by the kernel. Note that systemd only has a single notification socket set up for all the services it starts. All service hence queue their messages into the same socket, and we need to be able to identify exactly from which process each message originated, and need to make sure that the boundaries are intact and not messages from one service are half written and then mixed with messages from other services which write inbetween. By using SOCK_DGRAM we can be sure that each datagram is either fully written or never fully written, but never half-written interleaved with another half message from somebody else. And the kernel implicitly attaches SCM_CREDENTIALS to each of these datagrams, but this does not translate to SOCK_STREAM.

Thanks, Ian.

Bravo,
Cameron Norman

Reply to: