Changeset 3214 for code/trunk/src/network/packet/Packet.cc
- Timestamp:
- Jun 23, 2009, 6:02:25 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/network/packet/Packet.cc
r3097 r3214 31 31 32 32 #include <cassert> 33 #include <cstring> 33 34 #include <enet/enet.h> 34 #include <boost/bind.hpp> 35 #include <boost/thread/recursive_mutex.hpp> 36 37 #include "network/ConnectionManager.h" 38 #include "network/ClientInformation.h" 39 35 #include <boost/static_assert.hpp> 36 37 #include "util/Debug.h" 40 38 #include "Acknowledgement.h" 41 #include "DeleteObjects.h"42 39 #include "Chat.h" 43 40 #include "ClassID.h" 41 #include "DeleteObjects.h" 44 42 #include "FunctionCalls.h" 45 43 #include "FunctionIDs.h" … … 47 45 #include "Welcome.h" 48 46 #include "network/Host.h" 49 #include " core/CoreIncludes.h"47 #include "network/ClientInformation.h" 50 48 51 49 namespace orxonox{ … … 53 51 namespace packet{ 54 52 55 #define PACKET_FLAG_DEFAULT ENET_PACKET_FLAG_NO_ALLOCATE 53 // Make sure we assume the right values 54 BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Reliable) == static_cast<int>(ENET_PACKET_FLAG_RELIABLE)); 55 BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Unsequence) == static_cast<int>(ENET_PACKET_FLAG_UNSEQUENCED)); 56 BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::NoAllocate) == static_cast<int>(ENET_PACKET_FLAG_NO_ALLOCATE)); 57 58 #define PACKET_FLAG_DEFAULT PacketFlag::NoAllocate 56 59 #define _PACKETID 0 57 60 58 61 std::map<size_t, Packet *> Packet::packetMap_; 59 //! Static mutex for any packetMap_ access60 static boost::recursive_mutex packetMap_mutex_g;61 62 62 63 Packet::Packet(){ … … 108 109 } 109 110 else if (this->data_) { 110 // This destructor was probably called as a consequence toENet executing our callback.111 // This destructor was probably called as a consequence of ENet executing our callback. 111 112 // It simply serves us to be able to deallocate the packet content (data_) ourselves since 112 113 // we have created it in the first place. … … 142 143 // Assures we don't create a packet and destroy it right after in another thread 143 144 // without having a reference in the packetMap_ 144 boost::recursive_mutex::scoped_lock lock(packetMap_mutex_g);145 145 packetMap_[(size_t)(void*)enetPacket_] = this; 146 146 } … … 218 218 // Data was created by ENet 219 219 p->bDataENetAllocated_ = true; 220 p->enetPacket_ = packet; 220 221 221 222 return p; … … 228 229 */ 229 230 void Packet::deletePacket(ENetPacket *enetPacket){ 230 boost::recursive_mutex::scoped_lock lock(packetMap_mutex_g);231 231 // Get our Packet from a gloabal map with all Packets created in the send() method of Packet. 232 232 std::map<size_t, Packet*>::iterator it = packetMap_.find((size_t)enetPacket); … … 236 236 delete it->second; 237 237 packetMap_.erase(it); 238 COUT( 4) << "PacketMap size: " << packetMap_.size() << std::endl;238 COUT(6) << "PacketMap size: " << packetMap_.size() << std::endl; 239 239 } 240 240
Note: See TracChangeset
for help on using the changeset viewer.