]> git.ipfire.org Git - thirdparty/lxc.git/commit
Don't mess descr->ev
authorClement Calmels <clement.calmels@fr.ibm.com>
Wed, 13 Jan 2010 17:51:16 +0000 (18:51 +0100)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Wed, 13 Jan 2010 17:51:16 +0000 (18:51 +0100)
commit5df6b18f0e5f1ebb86167efa4c43436e01740e79
tree927e84d7307cb5abeebdf64f38d9461bffb7123f
parent3ce45e6458830932261091d70acb552fadd2da9c
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
src/lxc/mainloop.c