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

Function sync_check_timer

modules/clusterer/clusterer.c:73–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71};
72
73void sync_check_timer(utime_t ticks, void *param)
74{
75 cluster_info_t *cl;
76 struct local_cap *cap;
77 struct timeval now;
78
79 if (sr_get_core_status() != STATE_RUNNING) {
80 LM_DBG("opensips is not operational (state: %d), nothing "
81 "to check for now\n", sr_get_core_status());
82 return;
83 }
84
85 gettimeofday(&now, NULL);
86
87 lock_start_read(cl_list_lock);
88
89 for (cl = *cluster_list; cl; cl = cl->next) {
90 lock_get(cl->current_node->lock);
91 if (!(cl->current_node->flags & NODE_STATE_ENABLED)) {
92 lock_release(cl->current_node->lock);
93 continue;
94 }
95 lock_release(cl->current_node->lock);
96
97 for (cap = cl->capabilities; cap; cap = cap->next) {
98 lock_get(cl->lock);
99
100 if ((cap->flags & CAP_STATE_ENABLED) &&
101 !(cap->flags & CAP_STATE_OK)) {
102 if ((cap->flags & CAP_SYNC_PENDING) &&
103 (cl->current_node->flags & NODE_IS_SEED) &&
104 (TIME_DIFF(cap->sync_req_time, now) >=
105 ((cap->flags&CAP_SYNC_STARTUP ? ready_delay:0)
106 + seed_fb_interval) * 1000000)) {
107
108 cap->flags |= CAP_STATE_OK;
109 cap->flags &= ~(CAP_SYNC_PENDING|CAP_SYNC_STARTUP);
110 sr_set_status(cl_srg, STR2CI(cap->reg.sr_id), CAP_SR_SYNCED,
111 STR2CI(CAP_SR_STATUS_STR(CAP_SR_SYNCED)), 0);
112 sr_add_report_fmt(cl_srg, STR2CI(cap->reg.sr_id), 0,
113 "ERROR: Sync request aborted! (no donor found in due time)"
114 " => fallback to synced state");
115 LM_ERR("Sync request aborted! (no donor found in due time)"
116 ", falling back to synced state\n");
117 /* send update about the state of this capability */
118 send_single_cap_update(cl, cap, 1);
119
120 } else if ((cap->flags & CAP_SYNC_IN_PROGRESS) &&
121 (get_ticks() - cap->last_sync_pkt >= sync_timeout)) {
122
123 handle_sync_end(cl, cap, 0, 0, 1);
124
125 sr_set_status(cl_srg, STR2CI(cap->reg.sr_id), CAP_SR_NOT_SYNCED,
126 STR2CI(CAP_SR_STATUS_STR(CAP_SR_NOT_SYNCED)), 0);
127 sr_add_report_fmt(cl_srg, STR2CI(cap->reg.sr_id), 0,
128 "Sync timed out, received [%d] chunks",
129 cap->sync_cur_chunks_cnt);
130 LM_INFO("Sync timeout for capability [%.*s], reverting to "

Callers

nothing calls this directly

Calls 8

sr_get_core_statusFunction · 0.85
lock_getFunction · 0.85
lock_releaseFunction · 0.85
sr_set_statusFunction · 0.85
sr_add_report_fmtFunction · 0.85
send_single_cap_updateFunction · 0.85
get_ticksFunction · 0.85
handle_sync_endFunction · 0.85

Tested by

no test coverage detected