2016-11-27 18:51:36

by Loic Poulain

[permalink] [raw]
Subject: [PATCH] shared/mainloop: Fix msec to nsec conversion in timerfd config

---
src/shared/mainloop.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/mainloop.c b/src/shared/mainloop.c
index 9fff615..eacb6a4 100644
--- a/src/shared/mainloop.c
+++ b/src/shared/mainloop.c
@@ -311,7 +311,7 @@ static inline int timeout_set(int fd, unsigned int msec)
itimer.it_interval.tv_sec = 0;
itimer.it_interval.tv_nsec = 0;
itimer.it_value.tv_sec = sec;
- itimer.it_value.tv_nsec = (msec - (sec * 1000)) * 1000;
+ itimer.it_value.tv_nsec = (msec - (sec * 1000)) * 1000 * 1000;

return timerfd_settime(fd, 0, &itimer, NULL);
}
--
1.9.1



2016-11-28 12:35:10

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH] shared/mainloop: Fix msec to nsec conversion in timerfd config

Hi Loic,

On Sun, Nov 27, 2016 at 8:51 PM, Loic Poulain <[email protected]> wrote:
> ---
> src/shared/mainloop.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/shared/mainloop.c b/src/shared/mainloop.c
> index 9fff615..eacb6a4 100644
> --- a/src/shared/mainloop.c
> +++ b/src/shared/mainloop.c
> @@ -311,7 +311,7 @@ static inline int timeout_set(int fd, unsigned int msec)
> itimer.it_interval.tv_sec = 0;
> itimer.it_interval.tv_nsec = 0;
> itimer.it_value.tv_sec = sec;
> - itimer.it_value.tv_nsec = (msec - (sec * 1000)) * 1000;
> + itimer.it_value.tv_nsec = (msec - (sec * 1000)) * 1000 * 1000;
>
> return timerfd_settime(fd, 0, &itimer, NULL);
> }
> --
> 1.9.1

Applied, thanks.


--
Luiz Augusto von Dentz