[systemd-devel] [PATCH 2/3] sd-daemon: Use LISTEN_NAMES env when available

Lennart Poettering lennart at poettering.net
Fri May 15 08:40:43 PDT 2015


On Fri, 15.05.15 17:09, Krzysztof Opasiak (k.opasiak at samsung.com) wrote:

> LISTEN_NAMES environment variable contains details
> about received file descriptors. Let's try to use it
> instead of doing always two stats.

I am really not convinced that it is a good idea to store redundant
information in LISTEN_NAMES, especially if we don't have this
information in all cases anyway.

Please, let's keep this simple: LISTEN_NAMES should only carry actual
names, nothing else, and let's query the kernel for the actual fd
types.

There's really no point in storing the types in $LISTEN_NAMEs, since
this code is no way performance senstive...

> +static const char *sd_get_fd_name(int fd) {

The "sd_" prefix we add for exported functions, don't bother with it
for internal calls.

> +        static const char sep = ':';
> +        static const char escape = '\\';
> +        const char *env = NULL;
> +        const char *e = NULL;
> +        int i;
>  
> -        assert_return(fd >= 0, -EINVAL);
> +        assert_return(fd >= 3, NULL);

assert_return() we use for verifiying parameters passed in from
external users to check for programming errors. Since this function is
static this generally doesn't apply. See CODING_STYLE for details...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list