From 7dc065bdb0cedc86ef41c16fb242a80647b9e173 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 23 Feb 2008 15:56:56 +0000 Subject: [PATCH] * syscall_restart_handle_timeout_pre(uint32&, bigtime_t&): A huge negative relative timeout would be converted to B_INFINITE_TIMEOUT. For some reason the ScreenSaver preflet is snooze()ing with such a value. * Some more comments. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24080 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/syscall_restart.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/headers/private/kernel/syscall_restart.h b/headers/private/kernel/syscall_restart.h index 8e3c202317..1cb0629ba0 100644 --- a/headers/private/kernel/syscall_restart.h +++ b/headers/private/kernel/syscall_restart.h @@ -10,6 +10,11 @@ #include +/*! Helper function for syscalls with relative timeout. + Converts the given relative timeout to an absolute timeout or retrieves + the value from the syscall restart parameters, if the syscall has been + restarted. A negative value means infinite timeout. +*/ static inline void syscall_restart_handle_timeout_pre(bigtime_t& timeout) { @@ -20,12 +25,18 @@ syscall_restart_handle_timeout_pre(bigtime_t& timeout) timeout = *(bigtime_t*)thread->syscall_restart.parameters; else if (timeout >= 0) { timeout += system_time(); + // deal with overflow if (timeout < 0) timeout = B_INFINITE_TIMEOUT; } } +/*! Helper function for syscalls with flags + timeout. + If necessary converts the given timeout to an absolute timeout or retrieves + the value from the syscall restart parameters, if the syscall has been + restarted. +*/ static inline void syscall_restart_handle_timeout_pre(uint32& flags, bigtime_t& timeout) { @@ -36,11 +47,12 @@ syscall_restart_handle_timeout_pre(uint32& flags, bigtime_t& timeout) struct thread* thread = thread_get_current_thread(); if ((thread->flags & THREAD_FLAGS_SYSCALL_RESTARTED) != 0) { timeout = *(bigtime_t*)thread->syscall_restart.parameters; - if (timeout != 0 && (flags & B_RELATIVE_TIMEOUT) != 0) + if (timeout > 0 && (flags & B_RELATIVE_TIMEOUT) != 0) flags = (flags & ~B_RELATIVE_TIMEOUT) | B_ABSOLUTE_TIMEOUT; } else if ((flags & B_RELATIVE_TIMEOUT) != 0) { - if (timeout != 0) { + if (timeout > 0) { timeout += system_time(); + // deal with overflow if (timeout < 0) timeout = B_INFINITE_TIMEOUT;