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

Function io_wait_loop_devpoll

io_wait_loop.h:500–546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

498
499#ifdef HAVE_DEVPOLL
500inline static int io_wait_loop_devpoll(io_wait_h* h, int t, int repeat)
501{
502 int n, r;
503 int ret;
504 struct dvpoll dpoll;
505 struct fd_map *e;
506 unsigned int curr_time;
507
508 dpoll.dp_timeout=t*1000;
509 dpoll.dp_nfds=h->fd_no;
510 dpoll.dp_fds=h->dp_changes;
511again:
512 ret=n=ioctl(h->dpoll_fd, DP_POLL, &dpoll);
513 if (n==-1){
514 if (errno==EINTR) goto again; /* signal, ignore it */
515 else{
516 LM_ERR("[%s] ioctl: %s [%d]\n",h->name, strerror(errno), errno);
517 goto error;
518 }
519 }
520
521 curr_time = get_ticks();
522
523 for (r=0; r< n; r++){
524 if (h->dp_changes[r].revents & (POLLNVAL|POLLERR)){
525 LM_ERR("[%s] pollinval returned for fd %d, revents=%x\n",
526 h->name,h->fd_array[r].fd, h->fd_array[r].revents);
527 }
528 /* POLLIN|POLLHUP just go through */
529 (get_fd_map(h, h->dp_changes[r].fd))->flags |=
530 IO_WATCH_PRV_TRIG_READ;
531 }
532 /* now do the actual running of IO handlers */
533 for(r=h->fd_no-1; (r>=0) ; r--) {
534 e = get_fd_map(h, h->fd_array[r].fd);
535 if ( e->flags & IO_WATCH_PRV_TRIG_READ ) {
536 e->flags &= ~IO_WATCH_PRV_TRIG_READ;
537 while((handle_io( e, r, IO_WATCH_READ)>0) && repeat);
538 } else if ( e->timeout!=0 && e->timeout<=curr_time ) {
539 e->timeout = 0;
540 handle_io( e, r, IO_WATCH_TIMEOUT);
541 }
542 }
543
544error:
545 return ret;
546}
547#endif
548
549

Callers

nothing calls this directly

Calls 2

get_ticksFunction · 0.85
handle_ioFunction · 0.70

Tested by

no test coverage detected