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

Function rtpproxy_io_callback

modules/rtpproxy/notification_process.c:233–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233static int rtpproxy_io_callback(int fd, void *fs, int was_timeout)
234{
235 struct rtpp_notify *notify = (struct rtpp_notify *)fs;
236 char buffer[BUF_LEN+1];
237 int len, left, offset, total, entered = 0;
238 str command;
239 char *p, *start, *sp, *end;
240
241 profiling_proc_start( LEVEL_EXTRAPROCS, 1);
242
243 if (notify && notify->remaining) {
244 memcpy(buffer, notify->remaining, notify->remaining_len);
245 offset = notify->remaining_len;
246 pkg_free(notify->remaining);
247 notify->remaining_len = 0;
248 notify->remaining = NULL;
249 } else {
250 offset = 0;
251 }
252
253 for (;;) {
254 if (offset == BUF_LEN) {
255 LM_ERR("RTPProxy notification command too large [%.*s]\n",
256 offset, buffer);
257 free_rtpp_notify(fd, notify);
258 goto err1;
259 }
260
261 do
262 len = read(fd, buffer + offset, BUF_LEN - offset);
263 while (len == -1 && errno == EINTR);
264
265 if (len < 0) {
266 if (errno == EAGAIN || errno == EWOULDBLOCK)
267 break;
268
269 LM_ERR("reading from socket failed: %s\n",strerror(errno));
270 free_rtpp_notify(fd, notify);
271 goto err1;
272 }
273 if (len == 0) {
274 if (offset)
275 LM_WARN("dropping partial RTPProxy notification [%.*s]\n",
276 offset, buffer);
277 LM_DBG("closing rtpproxy notify socket\n");
278 free_rtpp_notify(fd, notify);
279 goto done;
280 }
281
282 total = len + offset;
283 buffer[total] = 0; // make it null terminated
284
285 LM_DBG("Notification(s) received: [%.*s]\n", total, buffer);
286 if (!entered) {
287 profiling_proc_enter( LEVEL_EXTRAPROCS,
288 ss_merge256("RTPP_CB ",buffer), 0 );
289 entered = 1;
290 }

Callers

nothing calls this directly

Calls 6

profiling_proc_startFunction · 0.85
free_rtpp_notifyFunction · 0.85
ss_merge256Function · 0.85
q_memchrFunction · 0.85
notification_handlerFunction · 0.85
profiling_proc_endFunction · 0.85

Tested by

no test coverage detected