From d03b33acbdac75920814a3c3032c90c809ce13e3 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Thu, 12 Sep 2013 13:38:10 +0800 Subject: [PATCH v2] Check EINVAL for accept4() It was reported that accept4() will return -1 with errrno is EINVAL on arm platform, so check EINVAL for accept4() and retry accept(). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69026 --- dbus/dbus-sysdeps-unix.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 1cb4a58..00d46da 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -1942,11 +1942,15 @@ _dbus_accept (int listen_fd) retry: #ifdef HAVE_ACCEPT4 - /* We assume that if accept4 is available SOCK_CLOEXEC is too */ + /* + * At compile-time, we assume that if accept4() is available in + * libc headers, SOCK_CLOEXEC is too. At runtime, it is still + * not necessarily true that either is supported by the running kernel. + */ client_fd = accept4 (listen_fd, &addr, &addrlen, SOCK_CLOEXEC); cloexec_done = client_fd >= 0; - if (client_fd < 0 && errno == ENOSYS) + if (client_fd < 0 && (errno == ENOSYS || errno == EINVAL)) #endif { client_fd = accept (listen_fd, &addr, &addrlen); -- 1.7.9.5