Don't fire an error when timerfd socket read returned 0
diff mbox series

Message ID 1583962106-3058-1-git-send-email-pavel.contrib@gmail.com
State New
Headers show
Series
  • Don't fire an error when timerfd socket read returned 0
Related show

Commit Message

Pavel Shirshov March 11, 2020, 9:28 p.m. UTC
It is possible to read 0 bytes from timerfd descriptor
despite the fact that descriptor notified poll() that descriptor
is ready. We saw such behaviour on some hardware platforms.

This patch is solving this by treating such situation as normal.

Signed-off-by: Pavel Shirshov <pavel.contrib@gmail.com>
---
 teamd/teamd.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Jiri Pirko March 12, 2020, 5:36 p.m. UTC | #1
Wed, Mar 11, 2020 at 10:28:26PM CET, pavel.contrib@gmail.com wrote:
>It is possible to read 0 bytes from timerfd descriptor
>despite the fact that descriptor notified poll() that descriptor
>is ready. We saw such behaviour on some hardware platforms.
>
>This patch is solving this by treating such situation as normal.

Do not talk about "This patch" in the patch description.
Tell the codebase what to do:
"Solve this by treating such situation as normal."


>
>Signed-off-by: Pavel Shirshov <pavel.contrib@gmail.com>
>---
> teamd/teamd.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
>diff --git a/teamd/teamd.c b/teamd/teamd.c
>index e035ac5..8cdc16d 100644
>--- a/teamd/teamd.c
>+++ b/teamd/teamd.c
>@@ -265,6 +265,10 @@ static int handle_period_fd(int fd)
> 		teamd_log_err("read() failed.");
> 		return -errno;
> 	}
>+	if (ret == 0) {
>+		teamd_log_warn("read() for timer_fd returned 0.");
>+		return 0;
>+	}
> 	if (ret != sizeof(uint64_t)) {
> 		teamd_log_err("read() returned unexpected number of bytes.");
> 		return -EINVAL;
>-- 
>2.7.4
>_______________________________________________
>libteam mailing list -- libteam@lists.fedorahosted.org
>To unsubscribe send an email to libteam-leave@lists.fedorahosted.org
>Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
>List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
>List Archives: https://lists.fedorahosted.org/archives/list/libteam@lists.fedorahosted.org

Patch
diff mbox series

diff --git a/teamd/teamd.c b/teamd/teamd.c
index e035ac5..8cdc16d 100644
--- a/teamd/teamd.c
+++ b/teamd/teamd.c
@@ -265,6 +265,10 @@  static int handle_period_fd(int fd)
 		teamd_log_err("read() failed.");
 		return -errno;
 	}
+	if (ret == 0) {
+		teamd_log_warn("read() for timer_fd returned 0.");
+		return 0;
+	}
 	if (ret != sizeof(uint64_t)) {
 		teamd_log_err("read() returned unexpected number of bytes.");
 		return -EINVAL;