Changeset 1318 for code/branches/merge/src/network/PacketBuffer.cc
- Timestamp:
- May 18, 2008, 10:00:17 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/merge/src/network/PacketBuffer.cc
r1299 r1318 41 41 namespace network 42 42 { 43 boost::mutex networkPacketBufferMutex;43 boost::recursive_mutex PacketBuffer::mutex_; 44 44 45 45 PacketBuffer::PacketBuffer() { … … 52 52 53 53 bool PacketBuffer::push(ENetEvent *ev) { 54 boost:: mutex::scoped_lock lock(networkPacketBufferMutex);54 boost::recursive_mutex::scoped_lock lock(mutex_); 55 55 //std::cout << "event size inside packetbuffer " << ev->packet->dataLength << std::endl; 56 56 // if(closed) … … 61 61 last=first; 62 62 last->next=NULL; 63 // change this!!!!!!! 63 // change this!!!!!!! ---- we are not doing stl so we won't change this 64 64 last->packet = ev->packet; 65 65 last->address = ev->peer->address; … … 76 76 //last->address = ev->peer->address; 77 77 } 78 // pseudo bugfix: added a return false statement for error handling 79 if ( last->packet == ev->packet ) return true; 80 return false; 78 lock.unlock(); 79 return true; 81 80 } 82 81 … … 84 83 //moving first pointer to next element 85 84 ENetPacket *PacketBuffer::pop() { 86 boost::mutex::scoped_lock lock(networkPacketBufferMutex); 87 //std::cout << "packetbuffer pop" << std::endl; 88 if(first!=NULL /*&& !closed*/){ 89 QueueItem *temp = first; 90 // get packet 91 ENetPacket *pck=first->packet; 92 // remove first element 93 first = first->next; 94 delete temp; 95 //std::cout << "pop size of packet " << pck->dataLength << std::endl; 96 return pck; 97 } else{ 98 //std::cout << "nothing to return" << std::endl; 99 return NULL; 100 } 85 ENetAddress address; 86 return pop(address); 101 87 } 102 88 103 89 ENetPacket *PacketBuffer::pop(ENetAddress &address) { 104 boost:: mutex::scoped_lock lock(networkPacketBufferMutex);90 boost::recursive_mutex::scoped_lock lock(mutex_); 105 91 //std::cout << "packetbuffer pop(address)" << std::endl; 106 92 if(first!=NULL /*&& !closed*/){ … … 112 98 first = first->next; 113 99 delete temp; 100 lock.unlock(); 114 101 //std::cout << "pop(address) size of packet " << pck->dataLength << std::endl; 115 102 return pck; 116 103 } else{ 104 lock.unlock(); 117 105 return NULL; 118 106 }
Note: See TracChangeset
for help on using the changeset viewer.