openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/systemd/1_242+AUTOINC+db2e367bfc-r0/git/src/journal/journal-send.c
static int journal_fd(void)
{
    int fd;
    static int fd_plus_one = 0;

retry:
    if (fd_plus_one > 0)
        return fd_plus_one - 1;

    fd = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0);
    if (fd < 0)
        return -errno;

    fd_inc_sndbuf(fd, SNDBUF_SIZE);

    if (!__sync_bool_compare_and_swap(&fd_plus_one, 0, fd + 1))
    {
        safe_close(fd);
        goto retry;
    }

    return fd;
}
/* We open a single fd, and we'll share it with the current process,
 * all its threads, and all its subprocesses. This means we need to
 * initialize it atomically, and need to operate on it atomically
 * never assuming we are the only user */
We open a single fd, and we'll share it with the current process,
all its threads, and all its subprocesses. This means we need to
initialize it atomically, and need to operate on it atomically
never assuming we are the only user
We open a single fd and we ' ll share it with the current process all its threads and all its subprocesses . This means we need to initialize it atomically and need to operate on it atomically never assuming we are the only user
static int journal_fd(void)
{
    int fd;
    static int fd_plus_one = 0;
retry:
    if (fd_plus_one > 0)
        return fd_plus_one - 1;
    fd = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0);
    if (fd < 0)
        return -errno;
    fd_inc_sndbuf(fd, SNDBUF_SIZE);
    if (!__sync_bool_compare_and_swap(&fd_plus_one, 0, fd + 1))
    {
        safe_close(fd);
        goto retry;
    }
    return fd;
}
static int journal_fd ( void ) { int fd ; static int fd_plus_one = 0 ; retry : if ( fd_plus_one > 0 ) return fd_plus_one - 1 ; fd = socket ( AF_UNIX , SOCK_DGRAM | SOCK_CLOEXEC , 0 ) ; if ( fd < 0 ) return - errno ; fd_inc_sndbuf ( fd , SNDBUF_SIZE ) ; if ( ! __sync_bool_compare_and_swap ( & fd_plus_one , 0 , fd + 1 ) ) { safe_close ( fd ) ; goto retry ; } return fd ; }
We open a single fd, and we'll share it with the current process,
 all its threads, and all its subprocesses.
We open a single fd and we ' ll share it with the current process all its threads and all its subprocesses .