src/rdkafka_broker.c
static void
rd_kafka_broker_update_reconnect_backoff (rd_kafka_broker_t *rkb,
                                          const rd_kafka_conf_t *conf,
                                          rd_ts_t now) {
        int backoff;

        /* If last connection attempt was more than reconnect.backoff.max.ms
         * ago, reset the reconnect backoff to the initial
         * reconnect.backoff.ms value. */
        if (rkb->rkb_ts_reconnect + (conf->reconnect_backoff_max_ms * 1000) <
            now)
                rkb->rkb_reconnect_backoff_ms = conf->reconnect_backoff_ms;

        /* Apply -25%...+50% jitter to next backoff. */
        backoff = rd_jitter((int)((float)rkb->rkb_reconnect_backoff_ms * 0.75),
                            (int)((float)rkb->rkb_reconnect_backoff_ms * 1.5));

         /* Cap to reconnect.backoff.max.ms. */
        backoff = RD_MIN(backoff, conf->reconnect_backoff_max_ms);

        /* Set time of next reconnect */
        rkb->rkb_ts_reconnect = now + (backoff * 1000);
        rkb->rkb_reconnect_backoff_ms =
                RD_MIN(rkb->rkb_reconnect_backoff_ms* 2,
                       conf->reconnect_backoff_max_ms);
}
/**
 * @brief Update the reconnect backoff.
 *        Should be called when a connection is made.
 *
 * @locality broker thread
 * @locks none
 */
@brief Update the reconnect backoff.
Should be called when a connection is made.

@locality broker thread
@locks none
@brief Update the reconnect backoff . Should be called when a connection is made . @locality broker thread @locks none
static void
rd_kafka_broker_update_reconnect_backoff (rd_kafka_broker_t *rkb,
                                          const rd_kafka_conf_t *conf,
                                          rd_ts_t now) {
        int backoff;
        if (rkb->rkb_ts_reconnect + (conf->reconnect_backoff_max_ms * 1000) <
            now)
                rkb->rkb_reconnect_backoff_ms = conf->reconnect_backoff_ms;
        backoff = rd_jitter((int)((float)rkb->rkb_reconnect_backoff_ms * 0.75),
                            (int)((float)rkb->rkb_reconnect_backoff_ms * 1.5));
        backoff = RD_MIN(backoff, conf->reconnect_backoff_max_ms);
        rkb->rkb_ts_reconnect = now + (backoff * 1000);
        rkb->rkb_reconnect_backoff_ms =
                RD_MIN(rkb->rkb_reconnect_backoff_ms* 2,
                       conf->reconnect_backoff_max_ms);
}
static void rd_kafka_broker_update_reconnect_backoff ( rd_kafka_broker_t * rkb , const rd_kafka_conf_t * conf , rd_ts_t now ) { int backoff ; if ( rkb -> rkb_ts_reconnect + ( conf -> reconnect_backoff_max_ms * 1000 ) < now ) rkb -> rkb_reconnect_backoff_ms = conf -> reconnect_backoff_ms ; backoff = rd_jitter ( ( int ) ( ( float ) rkb -> rkb_reconnect_backoff_ms * 0.75 ) , ( int ) ( ( float ) rkb -> rkb_reconnect_backoff_ms * 1.5 ) ) ; backoff = RD_MIN ( backoff , conf -> reconnect_backoff_max_ms ) ; rkb -> rkb_ts_reconnect = now + ( backoff * 1000 ) ; rkb -> rkb_reconnect_backoff_ms = RD_MIN ( rkb -> rkb_reconnect_backoff_ms * 2 , conf -> reconnect_backoff_max_ms ) ; }
@brief Update the reconnect backoff.
@brief Update the reconnect backoff .
/* If last connection attempt was more than reconnect.backoff.max.ms
         * ago, reset the reconnect backoff to the initial
         * reconnect.backoff.ms value. */ /* Apply -25%...+50% jitter to next backoff. */ /* Cap to reconnect.backoff.max.ms. */ /* Set time of next reconnect */