示例#1
0
static int curl_glue_on_io(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
        CurlGlue *g = userdata;
        int action, k = 0, translated_fd;

        assert(s);
        assert(g);

        translated_fd = PTR_TO_FD(hashmap_get(g->translate_fds, FD_TO_PTR(fd)));

        if ((revents & (EPOLLIN|EPOLLOUT)) == (EPOLLIN|EPOLLOUT))
                action = CURL_POLL_INOUT;
        else if (revents & EPOLLIN)
                action = CURL_POLL_IN;
        else if (revents & EPOLLOUT)
                action = CURL_POLL_OUT;
        else
                action = 0;

        if (curl_multi_socket_action(g->curl, translated_fd, action, &k) < 0) {
                log_debug("Failed to propagate IO event.");
                return -EINVAL;
        }

        curl_glue_check_finished(g);
        return 0;
}
示例#2
0
文件: fdset.c 项目: DStape/systemd
int fdset_iterate(FDSet *s, Iterator *i) {
        void *p;

        if (!set_iterate(MAKE_SET(s), i, &p))
                return -ENOENT;

        return PTR_TO_FD(p);
}
示例#3
0
文件: fdset.c 项目: DStape/systemd
int fdset_steal_first(FDSet *fds) {
        void *p;

        p = set_steal_first(MAKE_SET(fds));
        if (!p)
                return -ENOENT;

        return PTR_TO_FD(p);
}
示例#4
0
文件: fdset.c 项目: pwaller/systemd
void fdset_free(FDSet *s) {
        void *p;

        while ((p = set_steal_first(MAKE_SET(s)))) {
                /* Valgrind's fd might have ended up in this set here,
                 * due to fdset_new_fill(). We'll ignore all failures
                 * here, so that the EBADFD that valgrind will return
                 * us on close() doesn't influence us */

                /* When reloading duplicates of the private bus
                 * connection fds and suchlike are closed here, which
                 * has no effect at all, since they are only
                 * duplicates. So don't be surprised about these log
                 * messages. */

                log_debug("Closing left-over fd %i", PTR_TO_FD(p));
                close_nointr(PTR_TO_FD(p));
        }

        set_free(MAKE_SET(s));
}
示例#5
0
文件: fdset.c 项目: AOSC-Dev/systemd
int fdset_cloexec(FDSet *fds, bool b) {
        Iterator i;
        void *p;
        int r;

        assert(fds);

        SET_FOREACH(p, MAKE_SET(fds), i) {
                r = fd_cloexec(PTR_TO_FD(p), b);
                if (r < 0)
                        return r;
        }
示例#6
0
文件: fdset.c 项目: pwaller/systemd
int fdset_close_others(FDSet *fds) {
        void *e;
        Iterator i;
        int *a;
        unsigned j, m;

        j = 0, m = fdset_size(fds);
        a = alloca(sizeof(int) * m);
        SET_FOREACH(e, MAKE_SET(fds), i)
                a[j++] = PTR_TO_FD(e);

        assert(j == m);

        return close_all_fds(a, j);
}
示例#7
0
文件: async.c 项目: arthur-c/systemd
static void *close_thread(void *p) {
        assert_se(close_nointr(PTR_TO_FD(p)) != -EBADF);
        return NULL;
}
示例#8
0
文件: async.c 项目: coreos/systemd
static void *close_thread(void *p) {
        (void) pthread_setname_np(pthread_self(), "close");

        assert_se(close_nointr(PTR_TO_FD(p)) != -EBADF);
        return NULL;
}