From c72d22a5e897f54592734173f93d21cff5d2cb2d Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 17 Feb 2008 18:05:49 +0000 Subject: [PATCH] Converting relative timeouts into absolute ones is fine in principle, but there's a special handling for 0 us relative timeouts. Syscalls usually return B_WOULD_BLOCK instead of B_TIMED_OUT in this case, and callers might explicitely check for it. Hence we don't convert 0 us timeouts anymore. gdb works again. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23989 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/syscall_restart.h | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/headers/private/kernel/syscall_restart.h b/headers/private/kernel/syscall_restart.h index 2190e5d76c..8e3c202317 100644 --- a/headers/private/kernel/syscall_restart.h +++ b/headers/private/kernel/syscall_restart.h @@ -30,19 +30,23 @@ static inline void syscall_restart_handle_timeout_pre(uint32& flags, bigtime_t& timeout) { // If restarted, get the timeout from the restart parameters. Otherwise - // convert relative timeout to an absolute one. + // convert relative timeout to an absolute one. Note that we preserve + // relative 0 us timeouts, so that the syscall can still decide whether to + // return B_WOULD_BLOCK instead of B_TIMED_OUT. struct thread* thread = thread_get_current_thread(); - if ((thread->flags & THREAD_FLAGS_SYSCALL_RESTARTED) != 0) + if ((thread->flags & THREAD_FLAGS_SYSCALL_RESTARTED) != 0) { timeout = *(bigtime_t*)thread->syscall_restart.parameters; - else if ((flags & B_RELATIVE_TIMEOUT) != 0) { - timeout += system_time(); - if (timeout < 0) - timeout = B_INFINITE_TIMEOUT; - } + 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) { + timeout += system_time(); + if (timeout < 0) + timeout = B_INFINITE_TIMEOUT; - // any timeout is absolute at this point - if ((flags & B_RELATIVE_TIMEOUT) != 0) - flags = (flags & ~B_RELATIVE_TIMEOUT) | B_ABSOLUTE_TIMEOUT; + flags = (flags & ~B_RELATIVE_TIMEOUT) | B_ABSOLUTE_TIMEOUT; + } + } }