加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
sd-bus-fix-error-handling-on-readv.patch 1.78 KB
一键复制 编辑 原始数据 按行查看 历史
hexiaowen 提交于 2020-09-09 19:20 . fix error for handling on readv()
From c1093c34d7d81b5b13cc72d4d1941000813001da Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 20 Aug 2020 12:59:23 +0200
Subject: [PATCH] sd-bus: fix error handling on readv()
let's make sure we collect the right error code from errno, otherwise
we'll see EPERM (i.e. error 1) for all errors readv() returns (since it
returns -1 on error), including EAGAIN.
This is definitely backport material.
A fix-up for 3691bcf3c5eebdcca5b4f1c51c745441c57a6cd1.
Fixes: #16699
---
src/libsystemd/sd-bus/bus-socket.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c
index fc7e8e844ab..de36a1f278a 100644
--- a/src/libsystemd/sd-bus/bus-socket.c
+++ b/src/libsystemd/sd-bus/bus-socket.c
@@ -544,9 +544,11 @@ static int bus_socket_read_auth(sd_bus *b) {
iov = IOVEC_MAKE((uint8_t *)b->rbuffer + b->rbuffer_size, n - b->rbuffer_size);
- if (b->prefer_readv)
+ if (b->prefer_readv) {
k = readv(b->input_fd, &iov, 1);
- else {
+ if (k < 0)
+ k = -errno;
+ } else {
mh = (struct msghdr) {
.msg_iov = &iov,
.msg_iovlen = 1,
@@ -1187,9 +1189,11 @@ int bus_socket_read_message(sd_bus *bus) {
iov = IOVEC_MAKE((uint8_t *)bus->rbuffer + bus->rbuffer_size, need - bus->rbuffer_size);
- if (bus->prefer_readv)
+ if (bus->prefer_readv) {
k = readv(bus->input_fd, &iov, 1);
- else {
+ if (k < 0)
+ k = -errno;
+ } else {
mh = (struct msghdr) {
.msg_iov = &iov,
.msg_iovlen = 1,
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化