source: source/ariba/overlay/messages/DHTMessage.cpp@ 10572

Last change on this file since 10572 was 10572, checked in by Michael Tänzer, 12 years ago

Fix DHT: messages got lost if not communicating over a direct link.

Also:

  • Fix mem leak
  • Code clean up
File size: 841 bytes
Line 
1#include "DHTMessage.h"
2
3#include<boost/foreach.hpp>
4
5namespace ariba {
6namespace overlay {
7
8vsznDefault(DHTMessage);
9
10DHTMessage::DHTMessage() :
11 ttl( 0 ),
12 replace( false )
13{}
14
15DHTMessage::DHTMessage( const Data& key ) :
16 ttl( 0 ),
17 replace( false ),
18 key( key.clone() )
19{}
20
21DHTMessage::DHTMessage( const Data& key, const Data& value ) :
22 ttl( 0 ),
23 replace( false ),
24 key( key.clone() ),
25 values(1, value.clone())
26{}
27
28DHTMessage::DHTMessage( const Data& key, const vector<Data>& values ) :
29 ttl( 0 ),
30 replace( false ),
31 key( key.clone() )
32{
33 // preallocate enough room so we don't need to copy a lot
34 this->values.reserve(values.size());
35 BOOST_FOREACH(const Data value, values )
36 this->values.push_back( value.clone() );
37}
38
39DHTMessage::~DHTMessage() {
40 this->key.release();
41 BOOST_FOREACH( Data& value, values ) value.release();
42}
43
44}}
Note: See TracBrowser for help on using the repository browser.