connection: do not abort when dup(fd) fails

Instead, cleanly exit wl_closure_marshal and let the caller handler
the error. For wayland-client, the sole calling function will call
wl_abort() anyway. For wayland-server, the calling function will
cleanly shutdown the client.

This change ensures that compositors run with low file descriptor
limits or internal leaks need not crash suddenly (and sometimes
far from the problem) when space runs out.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
This commit is contained in:
Manuel Stoeckl 2019-07-05 19:48:18 -04:00 committed by Simon Ser
parent a281783339
commit 9d63c9ff84

View file

@ -644,8 +644,12 @@ wl_closure_marshal(struct wl_object *sender, uint32_t opcode,
case 'h':
fd = args[i].h;
dup_fd = wl_os_dupfd_cloexec(fd, 0);
if (dup_fd < 0)
wl_abort("dup failed: %s\n", strerror(errno));
if (dup_fd < 0) {
wl_closure_destroy(closure);
wl_log("error marshalling arguments for %s: dup failed: %s\n",
message->name, strerror(errno));
return NULL;
}
closure->args[i].h = dup_fd;
break;
default: