Changeset 1360 for code/trunk/src/network/PacketBuffer.cc
- Timestamp:
- May 22, 2008, 2:02:06 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/network/PacketBuffer.cc
r1293 r1360 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 last->address = ev->peer->address; 65 66 //last->address = ev->peer->address; 66 67 } else { … … 72 73 // save the packet to the new element 73 74 last->packet = ev->packet; 75 last->address = ev->peer->address; 74 76 //last->address = ev->peer->address; 75 77 } 76 // pseudo bugfix: added a return false statement for error handling 77 if ( last->packet == ev->packet ) return true; 78 return false; 78 lock.unlock(); 79 return true; 79 80 } 80 81 … … 82 83 //moving first pointer to next element 83 84 ENetPacket *PacketBuffer::pop() { 84 boost::mutex::scoped_lock lock(networkPacketBufferMutex); 85 //std::cout << "packetbuffer pop" << std::endl; 86 if(first!=NULL /*&& !closed*/){ 87 QueueItem *temp = first; 88 // get packet 89 ENetPacket *pck=first->packet; 90 // remove first element 91 first = first->next; 92 delete temp; 93 //std::cout << "pop size of packet " << pck->dataLength << std::endl; 94 return pck; 95 } else{ 96 //std::cout << "nothing to return" << std::endl; 97 return NULL; 98 } 85 ENetAddress address; 86 return pop(address); 99 87 } 100 88 101 89 ENetPacket *PacketBuffer::pop(ENetAddress &address) { 102 boost:: mutex::scoped_lock lock(networkPacketBufferMutex);90 boost::recursive_mutex::scoped_lock lock(mutex_); 103 91 //std::cout << "packetbuffer pop(address)" << std::endl; 104 92 if(first!=NULL /*&& !closed*/){ … … 110 98 first = first->next; 111 99 delete temp; 100 lock.unlock(); 112 101 //std::cout << "pop(address) size of packet " << pck->dataLength << std::endl; 113 102 return pck; 114 103 } else{ 104 lock.unlock(); 115 105 return NULL; 116 106 }
Note: See TracChangeset
for help on using the changeset viewer.