* 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
This commit is contained in:
@@ -10,6 +10,11 @@
|
|||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*! 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
|
static inline void
|
||||||
syscall_restart_handle_timeout_pre(bigtime_t& timeout)
|
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;
|
timeout = *(bigtime_t*)thread->syscall_restart.parameters;
|
||||||
else if (timeout >= 0) {
|
else if (timeout >= 0) {
|
||||||
timeout += system_time();
|
timeout += system_time();
|
||||||
|
// deal with overflow
|
||||||
if (timeout < 0)
|
if (timeout < 0)
|
||||||
timeout = B_INFINITE_TIMEOUT;
|
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
|
static inline void
|
||||||
syscall_restart_handle_timeout_pre(uint32& flags, bigtime_t& timeout)
|
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();
|
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;
|
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;
|
flags = (flags & ~B_RELATIVE_TIMEOUT) | B_ABSOLUTE_TIMEOUT;
|
||||||
} else if ((flags & B_RELATIVE_TIMEOUT) != 0) {
|
} else if ((flags & B_RELATIVE_TIMEOUT) != 0) {
|
||||||
if (timeout != 0) {
|
if (timeout > 0) {
|
||||||
timeout += system_time();
|
timeout += system_time();
|
||||||
|
// deal with overflow
|
||||||
if (timeout < 0)
|
if (timeout < 0)
|
||||||
timeout = B_INFINITE_TIMEOUT;
|
timeout = B_INFINITE_TIMEOUT;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user