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

Function get_evs

modules/freeswitch/fs_api.c:264–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262}
263
264static fs_evs* get_evs(const str *host, unsigned short port,
265 const str *user, const str *pass)
266{
267 struct list_head *_;
268 fs_evs *sock = NULL;
269
270 if (!host || !host->s || host->len == 0) {
271 LM_ERR("cannot locate a socket without a host!\n");
272 return NULL;
273 }
274
275 if (port == 0)
276 port = FS_DEFAULT_EVS_PORT;
277
278 LM_DBG("fetching %.*s:%d, user='%.*s', pass='%.*s'\n",
279 host->len, host->s, port,
280 user ? user->len : 0, user ? user->s : NULL,
281 pass ? pass->len : 0, pass ? pass->s : NULL);
282
283 lock_start_write(sockets_lock);
284
285 list_for_each(_, fs_sockets) {
286 sock = list_entry(_, fs_evs, list);
287 if (str_strcmp(host, &sock->host) == 0 && port == sock->port)
288 break;
289
290 sock = NULL;
291 }
292
293 if (!sock) {
294 sock = evs_init(host, port, user, pass);
295 if (!sock) {
296 lock_stop_write(sockets_lock);
297 LM_ERR("failed to create FS event socket!\n");
298 return NULL;
299 }
300
301 list_add(&sock->list, fs_sockets);
302
303 lock_start_write(sockets_down_lock);
304 list_add(&sock->reconnect_list, fs_sockets_down);
305 lock_stop_write(sockets_down_lock);
306 } else {
307 /* avoid interfering with the auth of DB-provisioned sockets */
308 if (!(sock->flags & FS_EVS_FL_DB))
309 evs_update(sock, user, pass);
310
311 LM_DBG("found & updated FS sock: host=%s, port=%d, user=%s, pass=%s\n",
312 sock->host.s, sock->port, sock->user.s, sock->pass.s);
313 }
314
315 sock->ref++;
316
317 lock_stop_write(sockets_lock);
318 return sock;
319}
320
321static fs_evs *get_evs_by_url(const str *_fs_url)

Callers 1

get_evs_by_urlFunction · 0.85

Calls 4

evs_initFunction · 0.85
list_addFunction · 0.85
evs_updateFunction · 0.85
list_entryClass · 0.50

Tested by

no test coverage detected