MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / heartbeats_timer

Function heartbeats_timer

modules/clusterer/topology.c:185–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183}
184
185void heartbeats_timer(void)
186{
187 struct timeval now;
188 time_t last_ping_int, last_sent_int, ping_reply_int;
189 cluster_info_t *clusters_it;
190 node_info_t *node;
191 int ev_actions_required[MAX_NO_CLUSTERS] = {0};
192 int no_clusters = 0;
193 int prev_ls, new_ls;
194
195 lock_start_read(cl_list_lock);
196
197 for (clusters_it = *cluster_list; clusters_it; clusters_it = clusters_it->next) {
198 lock_get(clusters_it->current_node->lock);
199 if (!(clusters_it->current_node->flags & NODE_STATE_ENABLED)) {
200 lock_release(clusters_it->current_node->lock);
201 continue;
202 }
203 lock_release(clusters_it->current_node->lock);
204
205 for(node = clusters_it->node_list; node; node = node->next) {
206 lock_get(node->lock);
207
208 if (!(node->flags & NODE_STATE_ENABLED)) {
209 lock_release(node->lock);
210 continue;
211 }
212
213 gettimeofday(&now, NULL);
214 ping_reply_int = PING_REPLY_INTERVAL(node);
215 last_ping_int = TIME_DIFF(node->last_ping, now);
216 last_sent_int = TIME_DIFF(node->last_sent, now);
217
218 prev_ls = -1;
219 new_ls = -1;
220
221 if (node->link_state == LS_RESTART_PINGING) {
222 prev_ls = node->link_state;
223 lock_release(node->lock);
224 CL_DBG("case 0: RESTART_PINGING\n");
225
226 /* restart pinging sequence */
227 do_action_trans_0(node, &new_ls);
228 } else if (node->link_state == LS_RETRY_SEND_FAIL &&
229 last_ping_int >= (time_t)ping_timeout_us) {
230 CL_DBG("case 1: RETRY_SEND_FAIL and timeout\n");
231 prev_ls = node->link_state;
232 lock_release(node->lock);
233
234 /* failed to send previous ping, retry */
235 do_action_trans_1(node, &new_ls);
236 } else if ((node->link_state == LS_UP || node->link_state == LS_RESTARTED) &&
237 /* have yet to receive a ping reply, or it was unacceptably slow */
238 (ping_reply_int <= 0 || ping_reply_int >= (time_t)ping_timeout_us) &&
239 /* ... and we're pinging or haven't sent a recent BIN packet */
240 (node->link_state == LS_RESTARTED
241 || last_sent_int >= (time_t)ping_timeout_us) &&
242 /* ... and a new ping packet is due */

Callers 2

heartbeats_timer_handlerFunction · 0.85

Calls 10

lock_getFunction · 0.85
lock_releaseFunction · 0.85
do_action_trans_0Function · 0.85
do_action_trans_1Function · 0.85
do_action_trans_2Function · 0.85
do_action_trans_3Function · 0.85
do_action_trans_4Function · 0.85
do_action_trans_5Function · 0.85
set_link_w_neigh_advFunction · 0.85
do_actions_node_evFunction · 0.85

Tested by

no test coverage detected