diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-09-01 17:07:49 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-09-01 17:07:49 +0100 |
commit | 8654bd7f6670a55b53ad6a7d0f14fe446124d41a (patch) | |
tree | d4fc711e0dfc7c85bda0a84743ea772e3b08d9e9 | |
parent | 3f03cafcb5f1a5b5a23006ced78a4db5ff6659fb (diff) |
intel-virtual-output: Restore the lost POLLIN on the timerfd
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | tools/virtual.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/tools/virtual.c b/tools/virtual.c index a37f4ca3..8a886866 100644 --- a/tools/virtual.c +++ b/tools/virtual.c @@ -1529,6 +1529,8 @@ static int timerfd(int hz) static int context_init(struct context *ctx) { + struct pollfd *pfd; + memset(ctx, 0, sizeof(*ctx)); ctx->pfd = malloc(2*sizeof(struct pollfd)); @@ -1543,19 +1545,19 @@ static int context_init(struct context *ctx) if (ctx->display == NULL) return -ENOMEM; - ctx->pfd[0].fd = timerfd(60); - if (ctx->pfd[0].fd < 0) - return ctx->pfd[0].fd; - - ctx->pfd[0].events = 0; - ctx->pfd[0].revents = 0; - ctx->nfd++; + pfd = memset(&ctx->pfd[ctx->nfd++], 0, sizeof(struct pollfd)); + pfd->fd = timerfd(60); + if (pfd->fd < 0) + return pfd->fd; + pfd->events = POLLIN; return 0; } static int add_fd(struct context *ctx, int fd) { + struct pollfd *pfd; + if (fd < 0) return fd; @@ -1565,10 +1567,9 @@ static int add_fd(struct context *ctx, int fd) return -ENOMEM; } - ctx->pfd[ctx->nfd].fd = fd; - ctx->pfd[ctx->nfd].events = POLLIN; - ctx->pfd[ctx->nfd].revents = 0; - ctx->nfd++; + pfd = memset(&ctx->pfd[ctx->nfd++], 0, sizeof(struct pollfd)); + pfd->fd = fd; + pfd->events = POLLIN; return 0; } |