From 92e7a4f3c9bc888a663ec73417a1c42e5165e873 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 21 Feb 2005 03:50:50 +0000 Subject: [PATCH] Fix usage of nanosleep(). (#163039, Bastien Nocera) 2005-02-20 Matthias Clasen * glib/gtimer.c (g_usleep): Fix usage of nanosleep(). (#163039, Bastien Nocera) --- ChangeLog | 5 +++++ ChangeLog.pre-2-10 | 5 +++++ ChangeLog.pre-2-12 | 5 +++++ ChangeLog.pre-2-8 | 5 +++++ glib/gtimer.c | 14 ++++++++++++-- 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 74da465..cb64020 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-02-20 Matthias Clasen + + * glib/gtimer.c (g_usleep): Fix usage of + nanosleep(). (#163039, Bastien Nocera) + 2005-02-16 Adi Attar * configure.in: Added "xh" to ALL_LINGUAS. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 74da465..cb64020 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +2005-02-20 Matthias Clasen + + * glib/gtimer.c (g_usleep): Fix usage of + nanosleep(). (#163039, Bastien Nocera) + 2005-02-16 Adi Attar * configure.in: Added "xh" to ALL_LINGUAS. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 74da465..cb64020 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,8 @@ +2005-02-20 Matthias Clasen + + * glib/gtimer.c (g_usleep): Fix usage of + nanosleep(). (#163039, Bastien Nocera) + 2005-02-16 Adi Attar * configure.in: Added "xh" to ALL_LINGUAS. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 74da465..cb64020 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,8 @@ +2005-02-20 Matthias Clasen + + * glib/gtimer.c (g_usleep): Fix usage of + nanosleep(). (#163039, Bastien Nocera) + 2005-02-16 Adi Attar * configure.in: Added "xh" to ALL_LINGUAS. diff --git a/glib/gtimer.c b/glib/gtimer.c index 6a05198..0a660f7 100644 --- a/glib/gtimer.c +++ b/glib/gtimer.c @@ -240,8 +240,18 @@ g_usleep (gulong microseconds) struct timespec request, remaining; request.tv_sec = microseconds / G_USEC_PER_SEC; request.tv_nsec = 1000 * (microseconds % G_USEC_PER_SEC); - while (nanosleep (&request, &remaining) == EINTR) - request = remaining; + while (1) + { + if (nanosleep (&request, &remaining) == -1) + { + if (errno == EINTR) + request = remaining; + else + break; + } + else + break; + } # else /* !HAVE_NANOSLEEP */ if (g_thread_supported ()) { -- 2.7.4