Last change
on this file since 10640 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 |
|
---|
5 | namespace ariba {
|
---|
6 | namespace overlay {
|
---|
7 |
|
---|
8 | vsznDefault(DHTMessage);
|
---|
9 |
|
---|
10 | DHTMessage::DHTMessage() :
|
---|
11 | ttl( 0 ),
|
---|
12 | replace( false )
|
---|
13 | {}
|
---|
14 |
|
---|
15 | DHTMessage::DHTMessage( const Data& key ) :
|
---|
16 | ttl( 0 ),
|
---|
17 | replace( false ),
|
---|
18 | key( key.clone() )
|
---|
19 | {}
|
---|
20 |
|
---|
21 | DHTMessage::DHTMessage( const Data& key, const Data& value ) :
|
---|
22 | ttl( 0 ),
|
---|
23 | replace( false ),
|
---|
24 | key( key.clone() ),
|
---|
25 | values(1, value.clone())
|
---|
26 | {}
|
---|
27 |
|
---|
28 | DHTMessage::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 |
|
---|
39 | DHTMessage::~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.