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

Function cl_sync_chunk_iter

modules/clusterer/sync.c:284–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282char *next_data_chunk;
283
284int cl_sync_chunk_iter(bin_packet_t *packet)
285{
286 str bin_buffer;
287 int next_chunk_sz, start_marker;
288 int rc;
289
290 if (!packet) {
291 LM_ERR("No sync packet\n");
292 return 0;
293 }
294
295 if (next_data_chunk) {
296 bin_get_buffer(packet, &bin_buffer);
297 if (next_data_chunk < bin_buffer.s ||
298 next_data_chunk >= bin_buffer.s + bin_buffer.len) {
299 next_data_chunk = NULL; /* no more chunks */
300 return 0;
301 }
302
303 packet->front_pointer = next_data_chunk;
304 }
305
306 rc = bin_pop_int(packet, &next_chunk_sz);
307 if (rc < 0) {
308 LM_ERR("error retrieving next sync chunk size\n");
309 return 0;
310 } else if (rc > 0) {
311 /* no more chunks in this packet */
312 return 0;
313 }
314
315 rc = bin_pop_int(packet, &start_marker);
316 if (rc < 0) {
317 LM_ERR("Error retrieving sync chunk start marker\n");
318 return 0;
319 } else if (rc > 0) {
320 LM_ERR("no more data: failed to read sync chunk start marker\n");
321 return 0;
322 } else if (start_marker != SYNC_CHUNK_START_MARKER) {
323 LM_ERR("Bad sync chunk start marker\n");
324 return 0;
325 }
326
327 no_sync_chunks_iter++;
328
329 next_data_chunk = packet->front_pointer + next_chunk_sz;
330 return 1;
331}
332
333void send_sync_repl(int sender, void *param)
334{

Callers

nothing calls this directly

Calls 2

bin_get_bufferFunction · 0.85
bin_pop_intFunction · 0.85

Tested by

no test coverage detected