コード例 #1
0
ファイル: busname.c プロジェクト: achanda/systemd
static void busname_done(Unit *u) {
        BusName *n = BUSNAME(u);

        assert(n);

        n->name = mfree(n->name);

        busname_free_policy(n);
        busname_unwatch_control_pid(n);
        busname_close_fd(n);

        unit_ref_unset(&n->service);

        n->timer_event_source = sd_event_source_unref(n->timer_event_source);
}
コード例 #2
0
static void busname_enter_making(BusName *n) {
        int r;

        assert(n);

        r = busname_open_fd(n);
        if (r < 0)
                goto fail;

        if (n->policy) {
                /* If there is a policy, we need to resolve user/group
                 * names, which we can't do from PID1, hence let's
                 * fork. */
                busname_unwatch_control_pid(n);

                r = busname_make_starter(n, &n->control_pid);
                if (r < 0) {
                        log_unit_warning_errno(UNIT(n)->id, r, "%s failed to fork 'making' task: %m", UNIT(n)->id);
                        goto fail;
                }

                busname_set_state(n, BUSNAME_MAKING);
        } else {
                /* If there is no policy, we can do everything
                 * directly from PID 1, hence do so. */

                r = bus_kernel_make_starter(n->starter_fd, n->name, n->activating, n->accept_fd, NULL, n->policy_world);
                if (r < 0) {
                        log_unit_warning_errno(UNIT(n)->id, r, "%s failed to make starter: %m", UNIT(n)->id);
                        goto fail;
                }

                busname_enter_listening(n);
        }

        return;

fail:
        busname_enter_dead(n, BUSNAME_FAILURE_RESOURCES);
}
コード例 #3
0
ファイル: busname.c プロジェクト: achanda/systemd
static void busname_set_state(BusName *n, BusNameState state) {
        BusNameState old_state;
        assert(n);

        old_state = n->state;
        n->state = state;

        if (!IN_SET(state, BUSNAME_MAKING, BUSNAME_SIGTERM, BUSNAME_SIGKILL)) {
                n->timer_event_source = sd_event_source_unref(n->timer_event_source);
                busname_unwatch_control_pid(n);
        }

        if (state != BUSNAME_LISTENING)
                busname_unwatch_fd(n);

        if (!IN_SET(state, BUSNAME_LISTENING, BUSNAME_MAKING, BUSNAME_REGISTERED, BUSNAME_RUNNING))
                busname_close_fd(n);

        if (state != old_state)
                log_unit_debug(UNIT(n), "Changed %s -> %s", busname_state_to_string(old_state), busname_state_to_string(state));

        unit_notify(UNIT(n), state_translation_table[old_state], state_translation_table[state], true);
}