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

Method can_reconnect

cpp/src/proactor_container_impl.cpp:309–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

307}
308
309bool container::impl::can_reconnect(pn_connection_t* pnc) {
310 reconnect_context* rc = get_reconnect_context(pnc);
311
312 // If reconnect not enabled just fail
313 if (!rc) return false;
314
315 // Don't reconnect if we are locally closed, the application will
316 // not expect a connection it closed to re-open.
317 if (rc->stop_reconnect_) return false;
318
319 // If container stopping don't try to reconnect
320 // - we pretend to have set up a reconnect attempt so
321 // that the proactor disconnect will finish and we will exit
322 // the run loop without error.
323 {
324 GUARD(lock_);
325 if (stopping_) return true;
326 }
327
328 const reconnect_options_base& roi = rc->reconnect_options_;
329
330 pn_transport_t* t = pn_connection_transport(pnc);
331 pn_condition_t* condition = pn_transport_condition(t);
332
333 // If we failed to authenticate then don't reconnect any more and just fail
334 if ( !strcmp(pn_condition_get_name(condition), "amqp:unauthorized-access") ) return false;
335
336 // If too many reconnect attempts just fail
337 if ( roi.max_attempts != 0 && rc->retries_ >= roi.max_attempts) {
338 pn_condition_format(condition, "proton:io", "Too many reconnect attempts (%d)", rc->retries_);
339 return false;
340 }
341 return true;
342}
343
344void container::impl::setup_reconnect(pn_connection_t* pnc) {
345 connection_context& cc = connection_context::get(pnc);

Callers

nothing calls this directly

Calls 5

get_reconnect_contextFunction · 0.85
pn_connection_transportFunction · 0.85
pn_transport_conditionFunction · 0.85
pn_condition_formatFunction · 0.85
pn_condition_get_nameFunction · 0.50

Tested by

no test coverage detected