Changeset 9964 for source/ariba
- Timestamp:
- Jul 8, 2011, 5:02:48 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/BaseOverlay.cpp
r9946 r9964 110 110 111 111 // return true, if ttl is elapsed 112 return ( difftime( time(NULL), this->last_update ) > =ttl );112 return ( difftime( time(NULL), this->last_update ) > ttl ); 113 113 } 114 114 … … 128 128 vector<Data> vect; 129 129 BOOST_FOREACH( ValueEntry& e, values ) 130 vect.push_back( e.get_value() );130 vect.push_back( e.get_value() ); 131 131 return vect; 132 132 } … … 154 154 155 155 void put( const Data& key, const Data& value, uint16_t ttl = 0 ) { 156 cleanup(); 156 157 157 158 // find entry … … 209 210 210 211 bool remove( const Data& key ) { 212 cleanup(); 213 211 214 // find entry 212 215 for (Entries::iterator i = entries.begin(); i != entries.end(); i++) { … … 215 218 // found? yes-> delete entry 216 219 if ( equals(entry.key, key) ) { 217 i = entries.erase(i)-1;220 entries.erase(i); 218 221 return true; 219 222 } … … 223 226 224 227 bool remove( const Data& key, const Data& value ) { 228 cleanup(); 225 229 // find entry 226 230 for (Entries::iterator i = entries.begin(); i != entries.end(); i++) { … … 244 248 245 249 void cleanup() { 246 // find entry247 250 for (Entries::iterator i = entries.begin(); i != entries.end(); i++) { 248 251 DHTEntry& entry = *i; 249 250 for (Values::iterator j = entry.values.begin(); 251 j != entry.values.end(); j++) { 252 253 // value found? yes-> delete 254 if (j->is_ttl_elapsed()) 255 j = entry.values.erase(j)-1; 256 } 257 258 if (entry.values.size()==0) i = entries.erase(i)-1; 252 entry.erase_expired_entries(); 253 if (entry.values.size()==0) 254 i = entries.erase(i)-1; 259 255 } 260 256 }
Note:
See TracChangeset
for help on using the changeset viewer.