diff options
author | Wim Taymans <wtaymans@redhat.com> | 2020-02-21 15:05:43 +0100 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2020-02-21 15:05:43 +0100 |
commit | 5074ca37ff4ed6013835bf6adb6f9e0a20935a2d (patch) | |
tree | 9707f9dc03d8d977763dab60d917f37f2adf1d20 /src/modules | |
parent | b33bd68bac81beb90d0a84e630bdb2fb779f2419 (diff) |
protocol-native: Improve errors
A missing XDG_RUNTIME_DIR results in ENOENT, like on the server
side.
A too long name results in ENAMETOOLONG, like on the server side.
When we can't find the socket, return EHOSTDOWN to make it more
obvious what is going.
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/module-protocol-native/local-socket.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/modules/module-protocol-native/local-socket.c b/src/modules/module-protocol-native/local-socket.c index 0c0ee231..14e1c14e 100644 --- a/src/modules/module-protocol-native/local-socket.c +++ b/src/modules/module-protocol-native/local-socket.c @@ -62,7 +62,7 @@ int pw_protocol_native_connect_local_socket(struct pw_protocol_client *client, if ((runtime_dir = getenv("XDG_RUNTIME_DIR")) == NULL) { pw_log_error("connect failed: XDG_RUNTIME_DIR not set in the environment"); - res = -EIO; + res = -ENOENT; goto error; } @@ -80,13 +80,15 @@ int pw_protocol_native_connect_local_socket(struct pw_protocol_client *client, if (name_size > (int) sizeof addr.sun_path) { pw_log_error("socket path \"%s/%s\" plus null terminator exceeds 108 bytes", runtime_dir, name); - res = -ENOSPC; - goto error_close; + res = -ENAMETOOLONG; + goto error_close; }; size = offsetof(struct sockaddr_un, sun_path) + name_size; if (connect(fd, (struct sockaddr *) &addr, size) < 0) { + if (errno == ENOENT) + errno = EHOSTDOWN; res = -errno; goto error_close; } |