eis: don't warn about EPIPE, just debug-log it

While it's not the friendliest way of a client to exit, we do need to
expect clients to disconnect any time and that shouldn't trigger
warnings, it's somewhat expected behavior.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/337>
This commit is contained in:
Peter Hutterer 2025-06-13 16:10:40 +10:00
parent 8cd2b01bfa
commit edc8ea045a
2 changed files with 44 additions and 1 deletions

View file

@ -245,7 +245,11 @@ eis_client_send_message(struct eis_client *client, const struct brei_object *obj
eis_client_queue_unsent(client, client->source, steal(&buf));
rc = 0;
} else if (rc < 0){
log_warn(eis, "failed to send message: %s", strerror(-rc));
if (rc == -EPIPE) {
log_debug(eis, "failed to send message: %s", strerror(-rc));
} else {
log_warn(eis, "failed to send message: %s", strerror(-rc));
}
source_remove(client->source);
}
}

View file

@ -24,8 +24,11 @@
#include "config.h"
#include "unistd.h"
#include "util-munit.h"
#include "util-version.h"
#include "util-strings.h"
#include "eierpecken.h"
@ -604,3 +607,39 @@ MUNIT_TEST(test_eis_ping)
return MUNIT_OK;
}
MUNIT_TEST(eistest_ignore_EPIPE)
{
_unref_(peck) *peck = peck_new();
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_CLIENT);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_DEFAULT_SEAT);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_HANDLE_BIND_SEAT);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ADD_POINTER);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_RESUME_DEVICE);
peck_dispatch_until_stable(peck);
peck_dispatch_until_stable(peck);
/* Forcibly close the pipe */
with_client(peck) {
int fd = peck_get_ei_fd(peck);
close(fd);
}
with_server(peck) {
eis_log_set_priority(eis, EIS_LOG_PRIORITY_DEBUG);
peck_eis_enable_log_capture(peck);
/* Do something that tries to send a message to the client, doesn't matter what */
eis_device_pause(peck_eis_get_default_pointer(peck));
peck_eis_disable_log_capture(peck);
char **warnings = peck_eis_get_log_capture(peck, EIS_LOG_PRIORITY_WARNING);
munit_assert_false(strv_find_substring(warnings, "Broken pipe", NULL));
char **debugs = peck_eis_get_log_capture(peck, EIS_LOG_PRIORITY_DEBUG);
munit_assert_true(strv_find_substring(debugs, "Broken pipe", NULL));
}
return MUNIT_OK;
}