FreeBSD Bugzilla – Attachment 221726 Details for
Bug 252820
Linuxulator: linux_timerfd_settime don't set expirations count to zero
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
timerfd+epoll+LT
timerfd.c (text/plain), 1.40 KB, created by
shu
on 2021-01-19 06:44:19 UTC
(
hide
)
Description:
timerfd+epoll+LT
Filename:
MIME Type:
Creator:
shu
Created:
2021-01-19 06:44:19 UTC
Size:
1.40 KB
patch
obsolete
>#include <stdio.h> >#include <string.h> >#include <time.h> >#include <unistd.h> > >#include <sys/epoll.h> >#include <sys/timerfd.h> > >void >main() >{ > struct epoll_event ev; > struct epoll_event evs[16]; > struct itimerspec its; > struct timespec t; > unsigned long long v; > int efd, tfd, n, i, interval = 5; > > tfd = timerfd_create(CLOCK_MONOTONIC, 0); > if (tfd < 0){ > perror("timerfd_create() error"); > return; > } > > if (clock_gettime(CLOCK_MONOTONIC, &t) != 0){ > perror("clock_gettime() error"); > return; > } > > its.it_value.tv_sec = t.tv_sec + interval; > its.it_value.tv_nsec = 0; > its.it_interval.tv_sec = interval; > its.it_interval.tv_nsec = 0; > > if (timerfd_settime(tfd, TFD_TIMER_ABSTIME, &its, NULL) != 0) { > perror("timerfd_settime() error"); > return; > } > > efd = epoll_create1(0); > if (efd < 0){ > perror("epoll_create1() error"); > return; > } > > ev.events = EPOLLIN; > if (epoll_ctl(efd, EPOLL_CTL_ADD, tfd, &ev) != 0){ > perror("epoll_ctl() error"); > return; > } > > while(1) { > n = epoll_wait(efd, evs, 16, -1); > if (n == -1){ > perror("epoll_wait() error"); > break; > } else if(n == 0){ > break; > } > for (i = 0; i < n; i++){ > printf("get timer\n"); > memset(&its, 0, sizeof(its)); > timerfd_settime(tfd, TFD_TIMER_ABSTIME, &its, NULL); > } > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 252820
: 221726