Use a mutex instead of a benaphore.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25286 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -338,21 +338,20 @@ UnixFifo::UnixFifo(size_t capacity)
|
|||||||
{
|
{
|
||||||
fReadCondition.Init(this, "unix fifo read");
|
fReadCondition.Init(this, "unix fifo read");
|
||||||
fWriteCondition.Init(this, "unix fifo write");
|
fWriteCondition.Init(this, "unix fifo write");
|
||||||
fLock.sem = -1;
|
mutex_init(&fLock, "unix fifo");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UnixFifo::~UnixFifo()
|
UnixFifo::~UnixFifo()
|
||||||
{
|
{
|
||||||
if (fLock.sem >= 0)
|
mutex_destroy(&fLock);
|
||||||
benaphore_destroy(&fLock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
UnixFifo::Init()
|
UnixFifo::Init()
|
||||||
{
|
{
|
||||||
return benaphore_init(&fLock, "unix fifo");
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -498,9 +497,9 @@ UnixFifo::_Read(Request& request, size_t numBytes, bigtime_t timeout,
|
|||||||
ConditionVariableEntry entry;
|
ConditionVariableEntry entry;
|
||||||
fReadCondition.Add(&entry, B_CAN_INTERRUPT);
|
fReadCondition.Add(&entry, B_CAN_INTERRUPT);
|
||||||
|
|
||||||
benaphore_unlock(&fLock);
|
mutex_unlock(&fLock);
|
||||||
status_t error = entry.Wait(B_ABSOLUTE_TIMEOUT, timeout);
|
status_t error = entry.Wait(B_ABSOLUTE_TIMEOUT, timeout);
|
||||||
benaphore_lock(&fLock);
|
mutex_lock(&fLock);
|
||||||
|
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
@@ -526,9 +525,9 @@ UnixFifo::_Read(Request& request, size_t numBytes, bigtime_t timeout,
|
|||||||
ConditionVariableEntry entry;
|
ConditionVariableEntry entry;
|
||||||
fReadCondition.Add(&entry, B_CAN_INTERRUPT);
|
fReadCondition.Add(&entry, B_CAN_INTERRUPT);
|
||||||
|
|
||||||
benaphore_unlock(&fLock);
|
mutex_unlock(&fLock);
|
||||||
status_t error = entry.Wait(B_ABSOLUTE_TIMEOUT, timeout);
|
status_t error = entry.Wait(B_ABSOLUTE_TIMEOUT, timeout);
|
||||||
benaphore_lock(&fLock);
|
mutex_lock(&fLock);
|
||||||
|
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
@@ -558,9 +557,9 @@ UnixFifo::_Write(Request& request, net_buffer* buffer, bigtime_t timeout,
|
|||||||
ConditionVariableEntry entry;
|
ConditionVariableEntry entry;
|
||||||
fWriteCondition.Add(&entry, B_CAN_INTERRUPT);
|
fWriteCondition.Add(&entry, B_CAN_INTERRUPT);
|
||||||
|
|
||||||
benaphore_unlock(&fLock);
|
mutex_unlock(&fLock);
|
||||||
status_t error = entry.Wait(B_ABSOLUTE_TIMEOUT, timeout);
|
status_t error = entry.Wait(B_ABSOLUTE_TIMEOUT, timeout);
|
||||||
benaphore_lock(&fLock);
|
mutex_lock(&fLock);
|
||||||
|
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
@@ -585,9 +584,9 @@ UnixFifo::_Write(Request& request, net_buffer* buffer, bigtime_t timeout,
|
|||||||
ConditionVariableEntry entry;
|
ConditionVariableEntry entry;
|
||||||
fWriteCondition.Add(&entry, B_CAN_INTERRUPT);
|
fWriteCondition.Add(&entry, B_CAN_INTERRUPT);
|
||||||
|
|
||||||
benaphore_unlock(&fLock);
|
mutex_unlock(&fLock);
|
||||||
error = entry.Wait(B_ABSOLUTE_TIMEOUT, timeout);
|
error = entry.Wait(B_ABSOLUTE_TIMEOUT, timeout);
|
||||||
benaphore_lock(&fLock);
|
mutex_lock(&fLock);
|
||||||
|
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
|
|||||||
@@ -74,12 +74,12 @@ public:
|
|||||||
|
|
||||||
bool Lock()
|
bool Lock()
|
||||||
{
|
{
|
||||||
return benaphore_lock(&fLock) == B_OK;
|
return mutex_lock(&fLock) == B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unlock()
|
void Unlock()
|
||||||
{
|
{
|
||||||
benaphore_unlock(&fLock);
|
mutex_unlock(&fLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shutdown(uint32 shutdown);
|
void Shutdown(uint32 shutdown);
|
||||||
@@ -124,7 +124,7 @@ private:
|
|||||||
size_t& bytesWritten);
|
size_t& bytesWritten);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
benaphore fLock;
|
mutex fLock;
|
||||||
UnixBufferQueue fBuffer;
|
UnixBufferQueue fBuffer;
|
||||||
RequestList fReaders;
|
RequestList fReaders;
|
||||||
RequestList fWriters;
|
RequestList fWriters;
|
||||||
|
|||||||
Reference in New Issue
Block a user