From a5dbd67b8140ca051085f8de677f21efeaec822c Mon Sep 17 00:00:00 2001 From: DarkWyrm Date: Sun, 8 Dec 2002 12:32:34 +0000 Subject: [PATCH] Added optional locking timeouts to help stave off deadlocks git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2180 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/proto7/DisplayDriver.cpp | 7 +++++-- src/servers/app/proto7/DisplayDriver.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/servers/app/proto7/DisplayDriver.cpp b/src/servers/app/proto7/DisplayDriver.cpp index baf464b42e..43ad97cc23 100644 --- a/src/servers/app/proto7/DisplayDriver.cpp +++ b/src/servers/app/proto7/DisplayDriver.cpp @@ -103,9 +103,12 @@ BPoint DisplayDriver::GetHotSpot(void) // Private Methods //--------------------------------------------------------- -void DisplayDriver::Lock(void) +bool DisplayDriver::Lock(bigtime_t timeout) // defaults to B_INIFINITE_TIMEOUT { - acquire_sem(lock_sem); +// acquire_sem(lock_sem); + if(acquire_sem_etc(lock_sem,1,B_RELATIVE_TIMEOUT,timeout)!=B_NO_ERROR) + return false; + return true; } void DisplayDriver::Unlock(void) diff --git a/src/servers/app/proto7/DisplayDriver.h b/src/servers/app/proto7/DisplayDriver.h index fd3bb254ed..0088c4b7b2 100644 --- a/src/servers/app/proto7/DisplayDriver.h +++ b/src/servers/app/proto7/DisplayDriver.h @@ -110,7 +110,7 @@ public: BPoint GetHotSpot(void); protected: - void Lock(void); + bool Lock(bigtime_t timeout=B_INFINITE_TIMEOUT); void Unlock(void); void SetDepthInternal(uint8 d); void SetHeightInternal(uint16 h);