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