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

Function msg_send_retry

modules/clusterer/clusterer.c:307–359  ·  view source on GitHub ↗

@return: * 0 : success, message sent * -1 : error, unable to send * -2 : dest down or probing */

Source from the content-addressed store, hash-verified

305 * -2 : dest down or probing
306 */
307static int msg_send_retry(bin_packet_t *packet, node_info_t *dest,
308 int change_dest, int *ev_actions_required)
309{
310 struct timeval now;
311 node_info_t *chosen_dest = dest;
312 str send_buffer;
313 int retr_send = 0;
314
315 do {
316 lock_get(chosen_dest->lock);
317
318 if (chosen_dest->link_state != LS_UP) {
319 lock_release(chosen_dest->lock);
320
321 chosen_dest = get_next_hop_2(dest);
322 if (!chosen_dest) {
323 if (retr_send)
324 return -1;
325 else
326 return -2;
327 }
328 } else
329 lock_release(chosen_dest->lock);
330
331 /* change destination node id */
332 if (change_dest || chosen_dest != dest) {
333 bin_remove_int_buffer_end(packet, 1);
334 bin_push_int(packet, dest->node_id);
335 }
336 bin_get_buffer(packet, &send_buffer);
337
338 if (msg_send(chosen_dest->cluster->send_sock, chosen_dest->proto,
339 &chosen_dest->addr, 0, send_buffer.s, send_buffer.len, 0) < 0) {
340 LM_ERR("msg_send() to node [%d] failed\n", chosen_dest->node_id);
341 retr_send = 1;
342
343 /* this node was supposed to be up, retry pinging */
344 set_link_w_neigh_adv(-1, LS_RESTART_PINGING, chosen_dest);
345
346 *ev_actions_required = 1;
347 } else {
348 LM_DBG("sent bin packet to node [%d]\n", chosen_dest->node_id);
349 retr_send = 0;
350 }
351 } while (retr_send);
352
353 gettimeofday(&now, NULL);
354
355 /* sent a TCP BIN packet directly to @dest -> delay next ping */
356 chosen_dest->last_sent = now;
357
358 return 0;
359}
360
361enum clusterer_send_ret clusterer_send_msg(bin_packet_t *packet,
362 int cluster_id, int dst_node_id, int check_cap, int locked)

Callers 4

clusterer_send_msgFunction · 0.85
clusterer_bcast_msgFunction · 0.85
bin_rcv_cl_extra_packetsFunction · 0.85
bin_rcv_mod_packetsFunction · 0.85

Calls 8

lock_getFunction · 0.85
lock_releaseFunction · 0.85
get_next_hop_2Function · 0.85
bin_push_intFunction · 0.85
bin_get_bufferFunction · 0.85
msg_sendFunction · 0.85
set_link_w_neigh_advFunction · 0.85

Tested by

no test coverage detected