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

Function replicate_entity_create

modules/b2b_entities/b2be_clustering.c:122–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122void replicate_entity_create(b2b_dlg_t *dlg, int etype, unsigned int hash_index,
123 bin_packet_t *storage)
124{
125 int rc;
126 bin_packet_t packet;
127 b2b_table htable = (etype == B2B_SERVER) ? server_htable : client_htable;
128 str storage_cnt_buf;
129
130 B2BE_LOCK_GET(htable, hash_index);
131
132 if (dlg->replicated) {
133 B2BE_LOCK_RELEASE(htable, hash_index);
134 return;
135 } else
136 dlg->replicated = 1;
137
138 if (bin_init(&packet, &entities_repl_cap, REPL_ENTITY_CREATE,
139 B2BE_BIN_VERSION, 0) != 0) {
140 LM_ERR("Failed to init bin packet\n");
141 B2BE_LOCK_RELEASE(htable, hash_index);
142 return;
143 }
144
145 bin_pack_entity(&packet, dlg, etype);
146
147 if (storage->buffer.s) { /* the callback was called */
148 bin_get_content_start(storage, &storage_cnt_buf);
149 if (storage_cnt_buf.len > 0 && /* content has been pushed */
150 bin_append_buffer(&packet, &storage_cnt_buf) < 0) {
151 LM_ERR("Failed to push the entity storage content into the packet\n");
152 B2BE_LOCK_RELEASE(htable, hash_index);
153 goto end;
154 }
155 }
156
157 B2BE_LOCK_RELEASE(htable, hash_index);
158
159 rc = cl_api.send_all(&packet, b2be_cluster);
160 switch (rc) {
161 case CLUSTERER_CURR_DISABLED:
162 LM_INFO("Current node is disabled in cluster: %d\n", b2be_cluster);
163 goto end;
164 case CLUSTERER_DEST_DOWN:
165 LM_INFO("All destinations in cluster: %d are down or probing\n",
166 b2be_cluster);
167 goto end;
168 case CLUSTERER_SEND_ERR:
169 LM_ERR("Error sending in cluster: %d\n", b2be_cluster);
170 goto end;
171 }
172
173 LM_DBG("Replicated entity [%.*s] [%.*s]\n", dlg->tag[1].len, dlg->tag[1].s,
174 dlg->callid.len, dlg->callid.s);
175
176end:
177 bin_free_packet(&packet);
178 return;
179}

Callers 2

_b2b_send_replyFunction · 0.85
b2b_tm_cbackFunction · 0.85

Calls 4

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