]>
git.ipfire.org Git - thirdparty/lxc.git/commit
Don't mess descr->ev
A simple test program to show up the issue:
-8<---
#include <stdio.h>
#include <unistd.h>
#include "mainloop.h"
struct lxc_epoll_descr loop;
int cb1(int fd, void *data, struct lxc_epoll_descr *descr)
{
fprintf(stderr, "cb1\n");
return 1;
}
int cb2(int fd, void *data, struct lxc_epoll_descr *descr)
{
fprintf(stderr, "cb2\n");
return 1;
}
int main(int argc, char *argv[])
{
int ret;
int fds[2];
ret = pipe(fds);
if (ret) {
perror("pipe:");
return -1;
}
ret = lxc_mainloop_open(&loop);
if (ret) {
fprintf(stderr, "lxc_mainloop_open: %d\n", ret);
return -1;
}
ret = lxc_mainloop_add_handler(&loop, fds[1], cb1, NULL);
if (ret) {
fprintf(stderr, "lxc_mainloop_add_handler(fds[1]): %d\n", ret);
return -1;
}
ret = lxc_mainloop_add_handler(&loop, fds[0], cb2, NULL);
if (ret) {
fprintf(stderr, "lxc_mainloop_add_handler(fds[0]): %d\n", ret);
return -1;
}
write(fds[1], &ret, sizeof(ret));
ret = lxc_mainloop(&loop);
if (ret) {
fprintf(stderr, "lxc_mainloop: %d\n", ret);
return -1;
}
ret = lxc_mainloop_close(&loop);
if (ret) {
fprintf(stderr, "lxc_mainloop_close: %d\n", ret);
return -1;
}
return 0;
}
Compile and run:
$ gcc test.c -o test -I ./src/lxc/ ./src/lxc/liblxc_so-mainloop.o && ./test
cb2