Changeset 5516 for source/ariba/utility/bootstrap/modules/periodicbroadcast
- Timestamp:
- Jul 31, 2009, 8:34:35 AM (15 years ago)
- Location:
- source/ariba/utility/bootstrap/modules/periodicbroadcast
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/utility/bootstrap/modules/periodicbroadcast/PeriodicBroadcast.cpp
r5514 r5516 102 102 103 103 Timer::stop(); 104 105 boost::mutex::scoped_lock lock( localServicesMutex );106 localServices.clear();107 104 } 108 105 … … 153 150 154 151 if( time(NULL) > (i->second.lastseen + servicetimeout) ){ 155 //remoteServices.erase( i );152 remoteServices.erase( i ); 156 153 deleted = true; 157 154 break; … … 159 156 } 160 157 161 } while(deleted);158 } while(deleted); 162 159 } 163 160 -
source/ariba/utility/bootstrap/modules/periodicbroadcast/PeriodicBroadcast.h
r5479 r5516 102 102 103 103 _Service(const string& _name, const string& _info1, 104 const string& _info2, const string& _info3, const time_t& _lastseen = 0) 105 : name(_name), info1(_info1), info2(_info2), info3(_info3), lastseen(_lastseen){ 106 } 107 108 _Service(const _Service& rh) 109 : name(rh.name), info1(rh.info1), info2(rh.info2), 110 info3(rh.info3), lastseen(rh.lastseen){ 104 const string& _info2, const string& _info3, const time_t& _lastseen = 0){ 105 name.assign (_name); 106 info1.assign(_info1); 107 info2.assign(_info2); 108 info3.assign(_info3); 109 lastseen = _lastseen; 110 } 111 112 _Service(const _Service& rh){ 113 name.assign (rh.name); 114 info1.assign(rh.info1); 115 info2.assign(rh.info2); 116 info3.assign(rh.info3); 117 lastseen = rh.lastseen; 111 118 } 112 119 } Service; 113 120 114 121 typedef map<string,Service> ServiceList; 122 115 123 ServiceList localServices; 116 124 boost::mutex localServicesMutex; … … 141 149 socket_v4(io_service), socket_v6(io_service) { 142 150 151 if( open4() ) start_receive_4(); 152 if( open6() ) start_receive_6(); 153 } 154 155 bool open4(){ 156 boost::system::error_code err; 157 143 158 boost::asio::ip::udp::endpoint listen_endpoint_v4( 144 159 boost::asio::ip::address_v4::any(), 145 160 PeriodicBroadcast::serverport_v4); 146 161 162 err = socket_v4.open( listen_endpoint_v4.protocol(), err ); 163 if(err){ 164 logging_warn("failed opening ipv4 socket"); 165 return false; 166 } 167 168 err = socket_v4.set_option( boost::asio::ip::udp::socket::reuse_address(true), err ); 169 if(err){ 170 logging_warn("failed setting reuse address option on ipv4 socket"); 171 return false; 172 } 173 174 err = socket_v4.set_option( boost::asio::socket_base::broadcast(true), err ); 175 if(err){ 176 logging_warn("failed setting broadcast option on ipv4 socket"); 177 return false; 178 } 179 180 err = socket_v4.bind( listen_endpoint_v4, err ); 181 if(err){ 182 logging_warn("failed binding ipv4 socket"); 183 return false; 184 } 185 186 return true; 187 } 188 189 bool open6(){ 190 boost::system::error_code err; 191 147 192 boost::asio::ip::udp::endpoint listen_endpoint_v6( 148 193 boost::asio::ip::address_v6::any(), 149 194 PeriodicBroadcast::serverport_v6); 150 195 151 boost::system::error_code err;152 153 err = socket_v4.open( listen_endpoint_v4.protocol(), err );154 if(err) logging_warn("failed opening ipv4 socket");155 156 196 err = socket_v6.open( listen_endpoint_v6.protocol(), err ); 157 if(err) logging_warn("failed opening ipv6 socket");158 159 err = socket_v4.set_option( boost::asio::ip::udp::socket::reuse_address(true), err );160 if(err) logging_warn("failed setting reuse address option on ipv4 socket");197 if(err){ 198 logging_warn("failed opening ipv6 socket"); 199 return false; 200 } 161 201 162 202 err = socket_v6.set_option( boost::asio::ip::udp::socket::reuse_address(true), err ); 163 if(err) logging_warn("failed setting reuse address option on ipv6 socket");164 165 err = socket_v4.set_option( boost::asio::socket_base::broadcast(true), err );166 if(err) logging_warn("failed setting broadcast option on ipv4 socket");203 if(err){ 204 logging_warn("failed setting reuse address option on ipv6 socket"); 205 return false; 206 } 167 207 168 208 err = socket_v6.set_option( boost::asio::socket_base::broadcast(true), err ); 169 if(err) logging_warn("failed setting broadcast option on ipv6 socket");170 171 err = socket_v4.bind( listen_endpoint_v4, err );172 if(err) logging_warn("failed binding ipv4 socket");209 if(err){ 210 logging_warn("failed setting broadcast option on ipv6 socket"); 211 return false; 212 } 173 213 174 214 err = socket_v6.bind( listen_endpoint_v6, err ); 175 if(err) logging_warn("failed binding ipv6 socket"); 176 177 start_receive_4(); 178 start_receive_6(); 215 if(err){ 216 logging_warn("failed binding ipv6 socket"); 217 return false; 218 } 219 220 return true; 179 221 } 180 222 … … 259 301 if( it != services->end() ){ 260 302 261 it->second.info1 = msg.getInfo1();262 it->second.info2 = msg.getInfo2();263 it->second.info3 = msg.getInfo3();303 it->second.info1.assign( msg.getInfo1() ); 304 it->second.info2.assign( msg.getInfo2() ); 305 it->second.info3.assign( msg.getInfo3() ); 264 306 it->second.lastseen = time(NULL); 265 307
Note:
See TracChangeset
for help on using the changeset viewer.