:: Re: [Dng] Readiness notification
Top Page
Delete this message
Reply to this message
Author: Laurent Bercot
Date:  
To: dng
Subject: Re: [Dng] Readiness notification
On 12/06/2015 20:09, Tomasz Torcz wrote:
>    Hey, it's almost exactly what sd_notify() does.  Instead of one character,
> it writes "READY=1" to a socket. Nothing more, no D-Bus, no additional
> libraries needed.  In basic form it few lines of C code.
>    Of course https://github.com/systemd/systemd/blob/0e4061c4d5de6b41326740ee8f8f13c168eea28d/src/libsystemd-daemon/sd-daemon.c#L414
> looks much worse, but it packs more functionality than simply
> readiness signalling.


Which is exactly the problem: it packs more functionality.
More functionality, that can be added to at a developer's whim, is
something that a stub has to support - if only to not crash on
functionality it doesn't understand.
More functionality means that daemon authors will rely on it, and
use the readiness notification mechanism for things entirely unrelated.
More functionality means feature creep that you will have to follow
to remain compatible.

It's easy to write a notification server that listens to connections
from sd_notify() and does things when it reads READY=1. It's not so
easy to implement all the sd_notify protocol, even right now, and with
all the random stuff that will inevitably get added over the years,
when daemons start relying on it.

Instead of those 68 lines of code, I suggest the following:

void notify_readiness (void)
{
write(1, "\n", 1) ;
close(1) ;
}

You really don't need anything more.

--
Laurent