109 |
return -1; |
return -1; |
110 |
} |
} |
111 |
|
|
112 |
|
const Stream::OrderID_t newOrder = CreateOrderID(); |
113 |
|
if (!newOrder) { |
114 |
|
dmsg(1,("DiskThread: there was no free slot\n")); |
115 |
|
return -1; // there was no free slot |
116 |
|
} |
117 |
|
|
118 |
pStreamRef->State = Stream::state_active; |
pStreamRef->State = Stream::state_active; |
119 |
pStreamRef->OrderID = CreateOrderID(); |
pStreamRef->OrderID = newOrder; |
120 |
pStreamRef->hStream = CreateHandle(); |
pStreamRef->hStream = CreateHandle(); |
121 |
pStreamRef->pStream = NULL; // a stream has to be activated by the disk thread first |
pStreamRef->pStream = NULL; // a stream has to be activated by the disk thread first |
122 |
|
|
|
if (!pStreamRef->OrderID) return -1; // there was no free slot |
|
|
|
|
123 |
create_command_t cmd; |
create_command_t cmd; |
124 |
cmd.OrderID = pStreamRef->OrderID; |
cmd.OrderID = pStreamRef->OrderID; |
125 |
cmd.hStream = pStreamRef->hStream; |
cmd.hStream = pStreamRef->hStream; |
339 |
|
|
340 |
/// order ID Generator |
/// order ID Generator |
341 |
Stream::OrderID_t DiskThread::CreateOrderID() { |
Stream::OrderID_t DiskThread::CreateOrderID() { |
342 |
static uint32_t counter = 0; |
static Stream::OrderID_t counter(0); |
343 |
for (int i = 0; i < MAX_INPUT_STREAMS; i++) { |
for (int i = 0; i < MAX_INPUT_STREAMS; i++) { |
344 |
if (counter == MAX_INPUT_STREAMS) counter = 1; // we use '0' as 'invalid order' only, so we skip 0 |
if (counter == MAX_INPUT_STREAMS) counter = 1; // we use '0' as 'invalid order' only, so we skip 0 |
345 |
else counter++; |
else counter++; |