diff options
author | Wim Taymans <wtaymans@redhat.com> | 2020-02-21 15:02:55 +0100 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2020-02-21 15:02:55 +0100 |
commit | b33bd68bac81beb90d0a84e630bdb2fb779f2419 (patch) | |
tree | 3b90d65d7222c6f32dd87bd8372d5e939e705870 /src/modules | |
parent | ee617682c3545b0bd8f35bddf401fb6dbcc4a16d (diff) |
improve error messages
Log an error when we send an error to the client so that we don't need
to log and error anymore.
Improve the error messages when we can
Move some warnings and errors to debug
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/module-link-factory.c | 23 | ||||
-rw-r--r-- | src/modules/module-protocol-native.c | 20 | ||||
-rw-r--r-- | src/modules/module-protocol-native/connection.c | 4 | ||||
-rw-r--r-- | src/modules/module-protocol-native/protocol-native.c | 2 |
4 files changed, 19 insertions, 30 deletions
diff --git a/src/modules/module-link-factory.c b/src/modules/module-link-factory.c index 77a735b8..f673c2a7 100644 --- a/src/modules/module-link-factory.c +++ b/src/modules/module-link-factory.c @@ -285,36 +285,31 @@ static void *create_object(void *_data, error_properties: res = -EINVAL; - pw_log_error(NAME" usage:" FACTORY_USAGE); - pw_resource_error(resource, res, "no properties"); + pw_resource_error(resource, res, NAME": no properties. usage:"FACTORY_USAGE); goto error_exit; error_output: res = -EINVAL; - pw_log_error(NAME" unknown output node %u", output_node_id); - pw_resource_errorf(resource, res, "unknown output node %u", output_node_id); + pw_resource_errorf(resource, res, NAME": unknown output node %u", output_node_id); goto error_exit; error_input: res = -EINVAL; - pw_log_error(NAME" unknown input node %u", input_node_id); - pw_resource_errorf(resource, res, "unknown input node %u", input_node_id); + pw_resource_errorf(resource, res, NAME": unknown input node %u", input_node_id); goto error_exit; error_output_port: res = -EINVAL; - pw_log_error(NAME" unknown output port %u", output_port_id); - pw_resource_errorf(resource, res, "unknown output port %u", output_port_id); + pw_resource_errorf(resource, res, NAME": unknown output port %u", output_port_id); goto error_exit; error_input_port: res = -EINVAL; - pw_log_error(NAME" unknown input port %u", input_port_id); - pw_resource_errorf(resource, res, "unknown input port %u", input_port_id); + pw_resource_errorf(resource, res, NAME": unknown input port %u", input_port_id); goto error_exit; error_create_link: - pw_log_error("can't create link: %s", spa_strerror(res)); - pw_resource_errorf(resource, res, "can't create link: %s", spa_strerror(res)); + pw_resource_errorf(resource, res, NAME": can't link ports %d and %d: %s", + pw_impl_port_get_id(outport), pw_impl_port_get_id(inport), + spa_strerror(res)); goto error_exit; error_link_register: - pw_log_error("can't register link: %s", spa_strerror(res)); - pw_resource_errorf(resource, res, "can't register link: %s", spa_strerror(res)); + pw_resource_errorf(resource, res, NAME": can't register link: %s", spa_strerror(res)); goto error_exit; error_exit: if (properties) diff --git a/src/modules/module-protocol-native.c b/src/modules/module-protocol-native.c index 22179c2f..0755fc07 100644 --- a/src/modules/module-protocol-native.c +++ b/src/modules/module-protocol-native.c @@ -179,8 +179,6 @@ process_messages(struct client_data *data) resource = pw_impl_client_find_resource(client, msg->id); if (resource == NULL) { - pw_log_error(NAME" %p: unknown resource %u op:%u", - client->protocol, msg->id, msg->opcode); pw_resource_errorf(client->core_resource, -EINVAL, "unknown resource %u op:%u", msg->id, msg->opcode); continue; @@ -202,10 +200,9 @@ process_messages(struct client_data *data) required = demarshal[msg->opcode].permissions | PW_PERM_X; if ((required & permissions) != required) { - pw_log_error(NAME" %p: method %u on %u requires %08x, have %08x", - client->protocol, msg->opcode, msg->id, required, permissions); pw_resource_errorf(resource, - -EACCES, "no permission to call method %u on %u", msg->opcode, msg->id); + -EACCES, "no permission to call method %u on %u (requires %08x, have %08x)", + msg->opcode, msg->id, required, permissions); continue; } @@ -218,20 +215,17 @@ done: return res; invalid_method: - pw_log_error(NAME" %p: invalid method id:%u op:%u", - client->protocol, msg->id, msg->opcode); pw_resource_errorf(resource, res, "invalid method id:%u op:%u", msg->id, msg->opcode); goto done; invalid_message: - pw_log_error(NAME" %p: invalid message received id:%u op:%u (%s)", - client->protocol, msg->id, msg->opcode, spa_strerror(res)); pw_resource_errorf(resource, res, "invalid message received id:%u op:%u (%s)", msg->id, msg->opcode, spa_strerror(res)); debug_msg("*invalid message*", msg, true); goto done; error: - pw_log_error(NAME" %p: client error (%s)", client->protocol, spa_strerror(res)); + pw_resource_errorf(client->core_resource, res, "client error %d (%s)", + res, spa_strerror(res)); goto done; } @@ -358,7 +352,7 @@ static struct client_data *client_new(struct server *s, int fd) #ifndef __FreeBSD__ len = sizeof(ucred); if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) < 0) { - pw_log_error("server %p: no peercred: %m", s); + pw_log_warn("server %p: no peercred: %m", s); } else { pw_properties_setf(props, PW_KEY_SEC_PID, "%d", ucred.pid); pw_properties_setf(props, PW_KEY_SEC_UID, "%d", ucred.uid); @@ -668,7 +662,7 @@ process_remote(struct client *impl) pw_proxy_unref(proxy); if (res < 0) { - pw_log_error (NAME" %p: invalid message received %u for %u", + pw_log_error(NAME" %p: invalid message received %u for %u", this, msg->opcode, msg->id); debug_msg("*invalid*", msg, true); continue; @@ -709,7 +703,7 @@ on_remote_data(void *data, int fd, uint32_t mask) } return; error: - pw_log_error(NAME" %p: got connection error %d (%s)", impl, res, spa_strerror(res)); + pw_log_debug(NAME" %p: got connection error %d (%s)", impl, res, spa_strerror(res)); pw_proxy_notify((struct pw_proxy*)this, struct pw_core_events, error, 0, 0, this->recv_seq, res, "connection error"); diff --git a/src/modules/module-protocol-native/connection.c b/src/modules/module-protocol-native/connection.c index 4ab330ef..3a1c973c 100644 --- a/src/modules/module-protocol-native/connection.c +++ b/src/modules/module-protocol-native/connection.c @@ -118,7 +118,7 @@ uint32_t pw_protocol_native_connection_add_fd(struct pw_protocol_native_connecti index = buf->msg.n_fds; if (index + buf->n_fds >= MAX_FDS) { - pw_log_error("connection %p: too many fds", conn); + pw_log_error("connection %p: too many fds (%d)", conn, MAX_FDS); return SPA_IDX_INVALID; } @@ -204,7 +204,7 @@ static int refill_buffer(struct pw_protocol_native_connection *conn, struct buff /* ERRORS */ recv_error: - pw_log_error("could not recvmsg on fd:%d: %s", conn->fd, strerror(errno)); + pw_log_error("connection %p: could not recvmsg on fd:%d: %m", conn, conn->fd); return -errno; } diff --git a/src/modules/module-protocol-native/protocol-native.c b/src/modules/module-protocol-native/protocol-native.c index 31f8eaed..c854c538 100644 --- a/src/modules/module-protocol-native/protocol-native.c +++ b/src/modules/module-protocol-native/protocol-native.c @@ -648,7 +648,7 @@ static int core_method_demarshal_destroy(void *object, const struct pw_protocol_ return pw_resource_notify(resource, struct pw_core_methods, destroy, 0, r); no_resource: - pw_log_error("client %p: unknown resouce %u op:%u", client, id, msg->opcode); + pw_log_debug("client %p: unknown resouce %u op:%u", client, id, msg->opcode); pw_resource_errorf(resource, -EINVAL, "unknown resource %d op:%u", id, msg->opcode); return 0; } |