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

Function evs_init

modules/freeswitch/fs_api.c:161–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161static fs_evs *evs_init(const str *host, unsigned short port,
162 const str *user, const str *pass)
163{
164 fs_evs *sock;
165
166 if (!host || !host->s || host->len == 0) {
167 LM_ERR("host cannot be NULL!\n");
168 return NULL;
169 }
170
171 if (!pass || !pass->s || pass->len == 0) {
172 LM_ERR("the password part is mandatory for a new socket!\n");
173 return NULL;
174 }
175
176 sock = shm_malloc(sizeof *sock);
177 if (!sock) {
178 LM_ERR("oom\n");
179 return NULL;
180 }
181 memset(sock, 0, sizeof *sock);
182 INIT_LIST_HEAD(&sock->esl_replies);
183 INIT_LIST_HEAD(&sock->events);
184 INIT_LIST_HEAD(&sock->reconnect_list);
185 INIT_LIST_HEAD(&sock->esl_cmd_list);
186
187 sock->stats_lk = lock_init_rw();
188 if (!sock->stats_lk) {
189 LM_ERR("oom\n");
190 goto err_free;
191 }
192
193 sock->lists_lk = lock_init_rw();
194 if (!sock->lists_lk) {
195 LM_ERR("oom\n");
196 goto err_free;
197 }
198
199 if (shm_nt_str_dup(&sock->host, host) != 0) {
200 LM_ERR("oom\n");
201 goto err_free;
202 }
203
204 if (user && shm_nt_str_dup(&sock->user, user) != 0) {
205 LM_ERR("oom\n");
206 goto err_free;
207 }
208
209 if (pass && shm_nt_str_dup(&sock->pass, pass) != 0) {
210 LM_ERR("oom\n");
211 goto err_free;
212 }
213
214 sock->port = port;
215 sock->esl_reply_id = 1;
216
217 LM_DBG("new FS sock: host=%s, port=%d, user=%s, pass=%s\n",
218 sock->host.s, sock->port, sock->user.s, sock->pass.s);

Callers 1

get_evsFunction · 0.85

Calls 5

shm_mallocFunction · 0.85
INIT_LIST_HEADFunction · 0.85
lock_init_rwFunction · 0.85
shm_nt_str_dupFunction · 0.85
evs_freeFunction · 0.85

Tested by

no test coverage detected