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

Last change on this file since 10643 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
RevLine 
[6266]1#include "DHTMessage.h"
2
3#include<boost/foreach.hpp>
4
5namespace ariba {
6namespace overlay {
7
8vsznDefault(DHTMessage);
9
[10572]10DHTMessage::DHTMessage() :
11 ttl( 0 ),
12 replace( false )
13{}
[6266]14
[10572]15DHTMessage::DHTMessage( const Data& key ) :
16 ttl( 0 ),
17 replace( false ),
18 key( key.clone() )
19{}
[6266]20
[10572]21DHTMessage::DHTMessage( const Data& key, const Data& value ) :
22 ttl( 0 ),
23 replace( false ),
24 key( key.clone() ),
25 values(1, value.clone())
26{}
[6266]27
[10572]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());
[6266]35 BOOST_FOREACH(const Data value, values )
[6919]36 this->values.push_back( value.clone() );
[6266]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.