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

Function replicate_entity_update

modules/b2b_entities/b2be_clustering.c:181–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181void replicate_entity_update(b2b_dlg_t *dlg, int etype, unsigned int hash_index,
182 str *b2bl_param, int event_type, bin_packet_t *storage)
183{
184 int rc;
185 bin_packet_t packet;
186 b2b_table htable = (etype == B2B_SERVER) ? server_htable : client_htable;
187 str storage_cnt_buf;
188 int pkt_type;
189
190 B2BE_LOCK_GET(htable, hash_index);
191
192 if (dlg->state < B2B_CONFIRMED) {
193 B2BE_LOCK_RELEASE(htable, hash_index);
194 return;
195 }
196
197 switch (event_type) {
198 case -1:
199 pkt_type = REPL_ENTITY_PARAM_UPDATE;
200 break;
201 case B2B_EVENT_ACK:
202 pkt_type = REPL_ENTITY_ACK;
203 break;
204 case B2B_EVENT_UPDATE:
205 pkt_type = REPL_ENTITY_UPDATE;
206 break;
207 default:
208 LM_ERR("Bad entity event %d\n", event_type);
209 B2BE_LOCK_RELEASE(htable, hash_index);
210 return;
211 }
212
213 if (bin_init(&packet, &entities_repl_cap, pkt_type, B2BE_BIN_VERSION, 0) < 0) {
214 LM_ERR("Failed to init bin packet\n");
215 B2BE_LOCK_RELEASE(htable, hash_index);
216 return;
217 }
218
219 if (pkt_type == REPL_ENTITY_PARAM_UPDATE) { /* replicate only the b2bl param update */
220 bin_pack_entity_coords(&packet, dlg, etype);
221 bin_push_str(&packet, b2bl_param);
222 } else {
223 bin_pack_entity(&packet, dlg, etype);
224
225 if (storage->buffer.s) {
226 bin_get_content_start(storage, &storage_cnt_buf);
227 if (storage_cnt_buf.len > 0 &&
228 bin_append_buffer(&packet, &storage_cnt_buf) < 0) {
229 LM_ERR("Failed to push the entity storage content into the packet\n");
230 B2BE_LOCK_RELEASE(htable, hash_index);
231 goto end;
232 }
233 }
234 }
235
236 B2BE_LOCK_RELEASE(htable, hash_index);
237
238 rc = cl_api.send_all(&packet, b2be_cluster);

Callers 5

b2b_update_b2bl_paramFunction · 0.85
b2b_prescript_fFunction · 0.85
_b2b_send_replyFunction · 0.85
_b2b_send_requestFunction · 0.85
b2b_tm_cbackFunction · 0.85

Calls 6

bin_pack_entity_coordsFunction · 0.85
bin_push_strFunction · 0.85
bin_pack_entityFunction · 0.85
bin_get_content_startFunction · 0.85
bin_append_bufferFunction · 0.85
bin_free_packetFunction · 0.85

Tested by

no test coverage detected