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

Function async_usleep

modules/cfgutils/cfgutils.c:567–599  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

565
566
567static int async_usleep(struct sip_msg* msg, async_ctx *ctx, int *useconds)
568{
569 struct itimerspec its;
570 int fd;
571
572 LM_DBG("sleep %d useconds\n", *(unsigned int *)useconds);
573
574 /* create the timer fd */
575 if ( (fd=timerfd_create( CLOCK_REALTIME, 0))<0 ) {
576 LM_ERR("failed to create new timer FD (%d) <%s>\n",
577 errno, strerror(errno));
578 return -1;
579 }
580
581 /* set the time */
582 its.it_value.tv_sec = (*(unsigned int *)useconds / 1000000);
583 its.it_value.tv_nsec = (*(unsigned int *)useconds % 1000000) * 1000;
584 its.it_interval.tv_sec = 0;
585 its.it_interval.tv_nsec = 0;
586 if (timerfd_settime( fd, 0, &its, NULL)<0) {
587 LM_ERR("failed to set timer FD (%d) <%s>\n",
588 errno, strerror(errno));
589 return -1;
590 }
591
592 /* start the async wait */
593 ctx->resume_param = (void*)(unsigned long)
594 (((unsigned long)-1) & (get_uticks()+*(unsigned int *)useconds));
595 ASYNC_SET_RESUME_F(ctx, resume_async_sleep);
596 async_status = fd;
597
598 return 1;
599}
600#endif
601
602

Callers

nothing calls this directly

Calls 1

get_uticksFunction · 0.85

Tested by

no test coverage detected