diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-09-30 22:33:50 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-09-30 22:33:50 +0200 |
commit | 32c6d387bf8bef65edab442d521c2f93bbf2cd2d (patch) | |
tree | 26f650e6d6e3c51c748c2b4c545f3a87dbe67696 /src/libsystemd/sd-daemon/sd-daemon.c | |
parent | 23a749f2857088547c8ef3966e96b37c71510a1b (diff) | |
parent | 0260d1d542da73b3358fa659fb1fa634badbf00e (diff) |
Merge pull request #1422 from keszybz/sd-daemon-mq-badf
sd-daemon: fix return value for sd_is_mq
Diffstat (limited to 'src/libsystemd/sd-daemon/sd-daemon.c')
-rw-r--r-- | src/libsystemd/sd-daemon/sd-daemon.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libsystemd/sd-daemon/sd-daemon.c b/src/libsystemd/sd-daemon/sd-daemon.c index ba7b8da85f..5fb0b73d02 100644 --- a/src/libsystemd/sd-daemon/sd-daemon.c +++ b/src/libsystemd/sd-daemon/sd-daemon.c @@ -310,10 +310,15 @@ _public_ int sd_is_socket_unix(int fd, int type, int listening, const char *path _public_ int sd_is_mq(int fd, const char *path) { struct mq_attr attr; - assert_return(fd >= 0, -EBADF); + /* Check that the fd is valid */ + assert_return(fcntl(fd, F_GETFD) >= 0, -errno); - if (mq_getattr(fd, &attr) < 0) + if (mq_getattr(fd, &attr) < 0) { + if (errno == EBADF) + /* A non-mq fd (or an invalid one, but we ruled that out above) */ + return 0; return -errno; + } if (path) { char fpath[PATH_MAX]; |