* Added some debug output.

* Flags and timeout arguments to acquire_sem_etc() were swapped.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24886 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-04-10 04:12:40 +00:00
parent 65a0f233b9
commit 9c796e6e71
@@ -8,6 +8,11 @@
#include "unix.h" #include "unix.h"
#define UNIX_FIFO_DEBUG_LEVEL 1
#define UNIX_DEBUG_LEVEL UNIX_FIFO_DEBUG_LEVEL
#include "UnixDebug.h"
UnixBufferQueue::UnixBufferQueue(size_t capacity) UnixBufferQueue::UnixBufferQueue(size_t capacity)
: :
fSize(0), fSize(0),
@@ -180,6 +185,9 @@ UnixFifo::Shutdown(uint32 shutdown)
status_t status_t
UnixFifo::Read(size_t numBytes, bigtime_t timeout, net_buffer** _buffer) UnixFifo::Read(size_t numBytes, bigtime_t timeout, net_buffer** _buffer)
{ {
TRACE("[%ld] UnixFifo::Read(%lu, %lld)\n", find_thread(NULL), numBytes,
timeout);
if (IsReadShutdown()) if (IsReadShutdown())
return UNIX_FIFO_SHUTDOWN; return UNIX_FIFO_SHUTDOWN;
@@ -206,7 +214,7 @@ UnixFifo::Read(size_t numBytes, bigtime_t timeout, net_buffer** _buffer)
release_sem_etc(fWriterSem, 1, B_RELEASE_ALL); release_sem_etc(fWriterSem, 1, B_RELEASE_ALL);
} }
return error; RETURN_ERROR(error);
} }
@@ -239,7 +247,7 @@ UnixFifo::Write(net_buffer* buffer, bigtime_t timeout)
release_sem_etc(fReaderSem, 1, B_RELEASE_ALL); release_sem_etc(fReaderSem, 1, B_RELEASE_ALL);
} }
return error; RETURN_ERROR(error);
} }
@@ -287,18 +295,18 @@ UnixFifo::_Read(Request& request, size_t numBytes, bigtime_t timeout,
{ {
// wait for the request to reach the front of the queue // wait for the request to reach the front of the queue
if (fReaders.Head() != &request && timeout == 0) if (fReaders.Head() != &request && timeout == 0)
return B_WOULD_BLOCK; RETURN_ERROR(B_WOULD_BLOCK);
while (fReaders.Head() != &request && !IsReadShutdown()) { while (fReaders.Head() != &request && !IsReadShutdown()) {
benaphore_unlock(&fLock); benaphore_unlock(&fLock);
status_t error = acquire_sem_etc(fReaderSem, 1, timeout, status_t error = acquire_sem_etc(fReaderSem, 1, B_ABSOLUTE_TIMEOUT,
B_ABSOLUTE_TIMEOUT); timeout);
benaphore_lock(&fLock); benaphore_lock(&fLock);
if (error != B_OK) if (error != B_OK)
return error; RETURN_ERROR(error);
} }
if (IsReadShutdown()) if (IsReadShutdown())
@@ -306,24 +314,24 @@ UnixFifo::_Read(Request& request, size_t numBytes, bigtime_t timeout,
// wait for any data to become available // wait for any data to become available
if (fBuffer.Readable() == 0 && timeout == 0) if (fBuffer.Readable() == 0 && timeout == 0)
return B_WOULD_BLOCK; RETURN_ERROR(B_WOULD_BLOCK);
while (fBuffer.Readable() == 0 && !IsReadShutdown()) { while (fBuffer.Readable() == 0 && !IsReadShutdown()) {
benaphore_unlock(&fLock); benaphore_unlock(&fLock);
status_t error = acquire_sem_etc(fReaderSem, 1, timeout, status_t error = acquire_sem_etc(fReaderSem, 1, B_ABSOLUTE_TIMEOUT,
B_ABSOLUTE_TIMEOUT); timeout);
benaphore_lock(&fLock); benaphore_lock(&fLock);
if (error != B_OK) if (error != B_OK)
return error; RETURN_ERROR(error);
} }
if (IsReadShutdown()) if (IsReadShutdown())
return UNIX_FIFO_SHUTDOWN; return UNIX_FIFO_SHUTDOWN;
return fBuffer.Read(numBytes, _buffer); RETURN_ERROR(fBuffer.Read(numBytes, _buffer));
} }
@@ -332,18 +340,18 @@ UnixFifo::_Write(Request& request, net_buffer* buffer, bigtime_t timeout)
{ {
// wait for the request to reach the front of the queue // wait for the request to reach the front of the queue
if (fWriters.Head() != &request && timeout == 0) if (fWriters.Head() != &request && timeout == 0)
return B_WOULD_BLOCK; RETURN_ERROR(B_WOULD_BLOCK);
while (fWriters.Head() != &request && !IsWriteShutdown()) { while (fWriters.Head() != &request && !IsWriteShutdown()) {
benaphore_unlock(&fLock); benaphore_unlock(&fLock);
status_t error = acquire_sem_etc(fWriterSem, 1, timeout, status_t error = acquire_sem_etc(fWriterSem, 1, B_ABSOLUTE_TIMEOUT,
B_ABSOLUTE_TIMEOUT); timeout);
benaphore_lock(&fLock); benaphore_lock(&fLock);
if (error != B_OK) if (error != B_OK)
return error; RETURN_ERROR(error);
} }
if (IsWriteShutdown()) if (IsWriteShutdown())
@@ -351,22 +359,22 @@ UnixFifo::_Write(Request& request, net_buffer* buffer, bigtime_t timeout)
// wait for any space to become available // wait for any space to become available
if (fBuffer.Writable() < request.size && timeout == 0) if (fBuffer.Writable() < request.size && timeout == 0)
return B_WOULD_BLOCK; RETURN_ERROR(B_WOULD_BLOCK);
while (fBuffer.Writable() < request.size && !IsWriteShutdown()) { while (fBuffer.Writable() < request.size && !IsWriteShutdown()) {
benaphore_unlock(&fLock); benaphore_unlock(&fLock);
status_t error = acquire_sem_etc(fWriterSem, 1, timeout, status_t error = acquire_sem_etc(fWriterSem, 1, B_ABSOLUTE_TIMEOUT,
B_ABSOLUTE_TIMEOUT); timeout);
benaphore_lock(&fLock); benaphore_lock(&fLock);
if (error != B_OK) if (error != B_OK)
return error; RETURN_ERROR(error);
} }
if (IsWriteShutdown()) if (IsWriteShutdown())
return UNIX_FIFO_SHUTDOWN; return UNIX_FIFO_SHUTDOWN;
return fBuffer.Write(buffer); RETURN_ERROR(fBuffer.Write(buffer));
} }