Beispiel #1
0
gboolean
cometd_impl_should_backoff(const cometd_advice* advice, long attempt)
{
  g_assert(advice != NULL);

  return !cometd_advice_is_none(advice) &&
         advice->interval == 0 && attempt > 1;
}
Beispiel #2
0
long
cometd_get_backoff(const cometd* h, long attempt)
{
  cometd_config* config = h->config;
  cometd_advice* advice = h->conn->advice;

  long backoff = config->backoff_increment;

  if (advice == NULL)
    backoff = cometd_impl_compute_backoff(config, attempt);
  else if (cometd_impl_should_backoff(advice, attempt))
    backoff = cometd_impl_compute_backoff(config, attempt-1); // offset attempt
  else if (cometd_advice_is_handshake(advice) || cometd_advice_is_retry(advice))
    backoff = advice->interval;
  else if (cometd_advice_is_none(advice))
    backoff = -1;

  return backoff;
}