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

Function async_sleep

modules/cfgutils/cfgutils.c:532–564  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

530
531
532static int async_sleep(struct sip_msg* msg, async_ctx *ctx, int *seconds)
533{
534 struct itimerspec its;
535 int fd;
536
537 LM_DBG("sleep %d seconds\n", *(unsigned int*)seconds);
538
539 /* create the timer fd */
540 if ( (fd=timerfd_create( CLOCK_REALTIME, 0))<0 ) {
541 LM_ERR("failed to create new timer FD (%d) <%s>\n",
542 errno, strerror(errno));
543 return -1;
544 }
545
546 /* set the time */
547 its.it_value.tv_sec = *(unsigned int*)seconds;
548 its.it_value.tv_nsec = 0;
549 its.it_interval.tv_sec = 0;
550 its.it_interval.tv_nsec = 0;
551 if (timerfd_settime( fd, 0, &its, NULL)<0) {
552 LM_ERR("failed to set timer FD (%d) <%s>\n",
553 errno, strerror(errno));
554 return -1;
555 }
556
557 /* start the async wait */
558 ctx->resume_param = (void*)(unsigned long)
559 (((unsigned long)-1) & (get_uticks()+1000000*(*(unsigned int*)seconds)));
560 ASYNC_SET_RESUME_F(ctx, resume_async_sleep);
561 async_status = fd;
562
563 return 1;
564}
565
566
567static int async_usleep(struct sip_msg* msg, async_ctx *ctx, int *useconds)

Callers

nothing calls this directly

Calls 1

get_uticksFunction · 0.85

Tested by

no test coverage detected