MCPcopy Create free account
hub / github.com/apache/qpid-proton / reconnect

Method reconnect

cpp/src/proactor_container_impl.cpp:226–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226void container::impl::reconnect(pn_connection_t* pnc) {
227 --reconnecting_;
228
229 if (stopping_ && reconnecting_==0) {
230 pn_connection_free(pnc);
231 //TODO: We've lost the error - we should really propagate it here
232 pn_proactor_disconnect(proactor_, NULL);
233 return;
234 }
235
236 connection_context& cc = connection_context::get(pnc);
237 reconnect_context& rc = *cc.reconnect_context_.get();
238
239 connection_options& co = *cc.connection_options_;
240 co.apply_reconnect_urls(pnc);
241
242 // Figure out next connection url to try
243 // rc.current_url_ == -1 means try the url specified in connect, not a failover url
244 const proton::url url(rc.current_url_==-1 ? cc.reconnect_url_ : cc.failover_urls_[rc.current_url_]);
245
246 // XXXX Debug:
247 //std::cout << "Retries: " << rc.retries_ << " Delay: " << rc.delay_ << " Trying: " << url << "@" << rc.current_url_ << std::endl;
248
249 ++rc.current_url_;
250 // Did we go through all the urls?
251 if (rc.current_url_==int(cc.failover_urls_.size())) {
252 rc.current_url_ = -1;
253 ++rc.retries_;
254 }
255
256 connection_options opts;
257 opts.container_id(id_);
258 default_url_options(opts, url);
259 opts.update(co);
260 messaging_handler* mh = opts.handler();
261 cc.handler = mh;
262 cc.active_url_ = url;
263
264 make_wrapper(pnc).open(co);
265 start_connection(url, pnc);
266}
267
268namespace {
269duration random_between(duration min, duration max)

Callers 8

on_container_startMethod · 0.80
readyMethod · 0.80
readyMethod · 0.80
on_container_startMethod · 0.80
on_container_startMethod · 0.80
on_container_startMethod · 0.80
on_container_startMethod · 0.80
on_container_startMethod · 0.80

Calls 12

pn_connection_freeFunction · 0.85
default_url_optionsFunction · 0.85
make_wrapperFunction · 0.85
getFunction · 0.70
pn_proactor_disconnectFunction · 0.50
getMethod · 0.45
apply_reconnect_urlsMethod · 0.45
sizeMethod · 0.45
container_idMethod · 0.45
updateMethod · 0.45
handlerMethod · 0.45
openMethod · 0.45

Tested by 6

on_container_startMethod · 0.64
readyMethod · 0.64
readyMethod · 0.64
on_container_startMethod · 0.64
on_container_startMethod · 0.64
on_container_startMethod · 0.64