| Name |
Last commit
|
Last update |
|---|---|---|
| config | ||
| doc | ||
| scripts | ||
| src | ||
| test | ||
| .cvsignore | ||
| .gitignore | ||
| AUTHORS | ||
| CONTRIBUTING | ||
| COPYING | ||
| INSTALL | ||
| MAINTAINERS | ||
| Makefile.am | ||
| NEWS | ||
| README | ||
| RELEASE-NOTES | ||
| TODO | ||
| autogen.sh | ||
| configure.ac | ||
| lxc.pc.in | ||
| lxc.spec.in |
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
| Name |
Last commit
|
Last update |
|---|---|---|
| config | Loading commit data... | |
| doc | Loading commit data... | |
| scripts | Loading commit data... | |
| src | Loading commit data... | |
| test | Loading commit data... | |
| .cvsignore | Loading commit data... | |
| .gitignore | Loading commit data... | |
| AUTHORS | Loading commit data... | |
| CONTRIBUTING | Loading commit data... | |
| COPYING | Loading commit data... | |
| INSTALL | Loading commit data... | |
| MAINTAINERS | Loading commit data... | |
| Makefile.am | Loading commit data... | |
| NEWS | Loading commit data... | |
| README | Loading commit data... | |
| RELEASE-NOTES | Loading commit data... | |
| TODO | Loading commit data... | |
| autogen.sh | Loading commit data... | |
| configure.ac | Loading commit data... | |
| lxc.pc.in | Loading commit data... | |
| lxc.spec.in | Loading commit data... |