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

Function receive_sync_request

modules/cachedb_local/cachedb_local_replication.c:177–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177int receive_sync_request(int node_id)
178{
179 int i;
180 lcache_col_t *col;
181 lcache_entry_t *data;
182 bin_packet_t *sync_packet;
183 lcache_t* cache_htable;
184
185 for ( col=lcache_collection; col; col=col->next ) {
186 LM_DBG("Found collection %.*s\n", col->col_name.len, col->col_name.s);
187
188 if (!col->replicated)
189 continue;
190
191 cache_htable = col->col_htable->htable;
192
193 for (i =0; i < col->col_htable->size; i++) {
194 lock_get(&cache_htable[i].lock);
195 data = cache_htable[i].entries;
196 while(data) {
197 if (data->expires == 0 || data->expires > get_ticks()) {
198 sync_packet = clusterer_api.sync_chunk_start(&cache_repl_cap,
199 cluster_id, node_id, BIN_VERSION);
200 if (!sync_packet) {
201 LM_ERR("Can not create sync packet!\n");
202 lock_release(&cache_htable[i].lock);
203 return -1;
204 }
205 bin_push_str(sync_packet, &col->col_name);
206 bin_push_str(sync_packet, &data->attr);
207 bin_push_str(sync_packet, &data->value);
208 bin_push_int(sync_packet, data->expires ?
209 data->expires - get_ticks() : 0);
210 }
211 data = data->next;
212 }
213 lock_release(&cache_htable[i].lock);
214 }
215 }
216
217 return 0;
218}
219
220void receive_cluster_event(enum clusterer_event ev, int node_id)
221{

Callers 1

receive_cluster_eventFunction · 0.70

Calls 5

lock_getFunction · 0.85
get_ticksFunction · 0.85
lock_releaseFunction · 0.85
bin_push_strFunction · 0.85
bin_push_intFunction · 0.85

Tested by

no test coverage detected