version 1.45, 2005/07/08 22:24:10
|
version 1.46, 2005/12/05 07:35:07
|
|
|
// Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for Bug#2076 | // Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for Bug#2076 |
// David Dillard, VERITAS Software Corp. | // David Dillard, VERITAS Software Corp. |
// (david.dillard@veritas.com) | // (david.dillard@veritas.com) |
|
// Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3475 |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include <Pegasus/Common/HashTable.h> | #include <Pegasus/Common/HashTable.h> |
#include <Pegasus/Common/IPC.h> | #include <Pegasus/Common/IPC.h> |
#include <Pegasus/Common/Tracer.h> | #include <Pegasus/Common/Tracer.h> |
|
#include "Stack.h" |
#include "MessageQueue.h" | #include "MessageQueue.h" |
#include "MessageQueueService.h" | #include "MessageQueueService.h" |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
|
|
_queueTable.remove(qid); | _queueTable.remove(qid); |
} | } |
| |
|
static Stack<Uint32> _qid_stack; |
|
static Uint32 _qid_next = CIMOM_Q_ID + 1; |
|
static Mutex _qid_mutex; |
| |
Uint32 MessageQueue::getNextQueueId() | Uint32 MessageQueue::getNextQueueId() |
{ | { |
static Uint32 _nextQueueId = 2; |
// If _qid_stack is empty, return _qid_next (and then increment _qid_next). |
|
// Else return the top of the stack. |
| |
// |
AutoMutex autoMutex(_qid_mutex); |
// Lock mutex: |
|
// |
|
static Mutex _id_mut ; |
|
AutoMutex autoMut(_id_mut); |
|
| |
Uint32 queueId; |
if (_qid_stack.isEmpty()) |
|
return _qid_next++; |
| |
// Assign the next queue ID that is not already in use |
Uint32 queueId = _qid_stack.top(); |
do |
_qid_stack.pop(); |
{ |
return queueId; |
// Handle wrap around and never assign zero or one as a queue id: |
|
if (_nextQueueId == 0) |
|
{ |
|
_nextQueueId = 2; |
|
} | } |
| |
queueId = _nextQueueId++; |
void MessageQueue::putQueueId(Uint32 queueId) |
} while (lookup(queueId) != 0); |
{ |
|
// Put the queueId on the top of the stack. |
| |
return queueId; |
AutoMutex autoMutex(_qid_mutex); |
} |
// Ignore an attempt to return the well-known queue id (CIMOM_Q_ID). |
|
// This id is reserved for the CIMOM queue. |
| |
|
if (queueId == CIMOM_Q_ID) |
|
return; |
| |
|
_qid_stack.push(queueId); |
|
} |
| |
MessageQueue::MessageQueue( | MessageQueue::MessageQueue( |
const char* name, | const char* name, |
|
|
delete tmp; | delete tmp; |
} | } |
| |
|
// Return the queue id. |
|
|
|
putQueueId(_queueId); |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |