Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 564aeca9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "init: clean up exec command"

parents 01b25ab1 2d0fdaaa
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -265,10 +265,14 @@ static int do_exec(const std::vector<std::string>& args) {
    if (!svc) {
    if (!svc) {
        return -1;
        return -1;
    }
    }
    if (!start_waiting_for_exec()) {
        return -1;
    }
    if (!svc->Start()) {
    if (!svc->Start()) {
        stop_waiting_for_exec();
        ServiceManager::GetInstance().RemoveService(*svc);
        return -1;
        return -1;
    }
    }
    waiting_for_exec = true;
    return 0;
    return 0;
}
}


@@ -1018,7 +1022,7 @@ static int do_wait_for_prop(const std::vector<std::string>& args) {
                   << "\") failed: value too long";
                   << "\") failed: value too long";
        return -1;
        return -1;
    }
    }
    if (!wait_property(name, value)) {
    if (!start_waiting_for_property(name, value)) {
        LOG(ERROR) << "do_wait_for_prop(\"" << name << "\", \"" << value
        LOG(ERROR) << "do_wait_for_prop(\"" << name << "\", \"" << value
                   << "\") failed: init already in waiting";
                   << "\") failed: init already in waiting";
        return -1;
        return -1;
+21 −3
Original line number Original line Diff line number Diff line
@@ -82,7 +82,7 @@ static time_t process_needs_restart_at;


const char *ENV[32];
const char *ENV[32];


bool waiting_for_exec = false;
static std::unique_ptr<Timer> waiting_for_exec(nullptr);


static int epoll_fd = -1;
static int epoll_fd = -1;


@@ -131,7 +131,24 @@ int add_environment(const char *key, const char *val)
    return -1;
    return -1;
}
}


bool wait_property(const char *name, const char *value)
bool start_waiting_for_exec()
{
    if (waiting_for_exec) {
        return false;
    }
    waiting_for_exec.reset(new Timer());
    return true;
}

void stop_waiting_for_exec()
{
    if (waiting_for_exec) {
        LOG(INFO) << "Wait for exec took " << *waiting_for_exec;
        waiting_for_exec.reset();
    }
}

bool start_waiting_for_property(const char *name, const char *value)
{
{
    if (waiting_for_prop) {
    if (waiting_for_prop) {
        return false;
        return false;
@@ -142,7 +159,8 @@ bool wait_property(const char *name, const char *value)
        wait_prop_value = value;
        wait_prop_value = value;
        waiting_for_prop.reset(new Timer());
        waiting_for_prop.reset(new Timer());
    } else {
    } else {
        LOG(INFO) << "wait_property(\"" << name << "\", \"" << value << "\"): already set";
        LOG(INFO) << "start_waiting_for_property(\""
                  << name << "\", \"" << value << "\"): already set";
    }
    }
    return true;
    return true;
}
}
+5 −2
Original line number Original line Diff line number Diff line
@@ -23,7 +23,6 @@ class Action;
class Service;
class Service;


extern const char *ENV[32];
extern const char *ENV[32];
extern bool waiting_for_exec;
extern std::string default_console;
extern std::string default_console;
extern struct selabel_handle *sehandle;
extern struct selabel_handle *sehandle;
extern struct selabel_handle *sehandle_prop;
extern struct selabel_handle *sehandle_prop;
@@ -36,6 +35,10 @@ void register_epoll_handler(int fd, void (*fn)());


int add_environment(const char* key, const char* val);
int add_environment(const char* key, const char* val);


bool wait_property(const char *name, const char *value);
bool start_waiting_for_exec();

void stop_waiting_for_exec();

bool start_waiting_for_property(const char *name, const char *value);


#endif  /* _INIT_INIT_H */
#endif  /* _INIT_INIT_H */
+1 −1
Original line number Original line Diff line number Diff line
@@ -997,7 +997,7 @@ bool ServiceManager::ReapOneProcess() {
    }
    }


    if (svc->Reap()) {
    if (svc->Reap()) {
        waiting_for_exec = false;
        stop_waiting_for_exec();
        RemoveService(*svc);
        RemoveService(*svc);
    }
    }