예제 #1
0
파일: md.c 프로젝트: china-east-soft/CSSV
static void *md_thread(void *arg)
{
    int i,n,r;
    struct _triton_md_handler_t *h;
    sigset_t set;

    sigfillset(&set);
    sigdelset(&set, SIGKILL);
    sigdelset(&set, SIGSTOP);
    pthread_sigmask(SIG_BLOCK, &set, NULL);

    while(1) {
        n = epoll_wait(epoll_fd, epoll_events, max_events, -1);
        if (n < 0) {
            if (errno == EINTR)
                continue;
            triton_log_error("md:epoll_wait: %s", strerror(errno));
            _exit(-1);
        }

        for(i = 0; i < n; i++) {
            h = (struct _triton_md_handler_t *)epoll_events[i].data.ptr;
            if (!h->ud)
                continue;
            spin_lock(&h->ctx->lock);
            if (h->ud) {
                h->trig_epoll_events |= epoll_events[i].events;
                if (!h->pending) {
                    list_add_tail(&h->entry2, &h->ctx->pending_handlers);
                    h->pending = 1;
                    __sync_add_and_fetch(&triton_stat.md_handler_pending, 1);
                    r = triton_queue_ctx(h->ctx);
                } else
                    r = 0;
            } else
                r = 0;
            spin_unlock(&h->ctx->lock);
            if (r)
                triton_thread_wakeup(h->ctx->thread);
        }

        while (!list_empty(&freed_list2)) {
            h = list_entry(freed_list2.next, typeof(*h), entry);
            list_del(&h->entry);
            mempool_free(h);
        }

        pthread_mutex_lock(&freed_list_lock);
        while (!list_empty(&freed_list)) {
            h = list_entry(freed_list.next, typeof(*h), entry);
            list_del(&h->entry);
            list_add(&h->entry, &freed_list2);
        }
        pthread_mutex_unlock(&freed_list_lock);
    }

    return NULL;
}
예제 #2
0
파일: triton.c 프로젝트: themiron/accel-ppp
static void __config_reload(void (*notify)(int))
{
	struct _triton_thread_t *t;
	int r;

	log_debug2("config_reload: enter\n");
	r = conf_reload(NULL);
	notify(r);

	spin_lock(&threads_lock);
	need_config_reload = 0;
	list_for_each_entry(t, &threads, entry)
		triton_thread_wakeup(t);
	spin_unlock(&threads_lock);
	log_debug2("config_reload: exit\n");
}