static int manager_jobs_in_progress_mod_timer(Manager *m) {
struct itimerspec its;
+ if (m->jobs_in_progress_watch.type != WATCH_JOBS_IN_PROGRESS)
+ return 0;
+
zero(its);
its.it_value.tv_sec = JOBS_IN_PROGRESS_WAIT_SEC;
assert(pos <= width+1); /* 0 or width+1 mean that the center light is behind the corner */
if (pos > 1) {
- if (pos > 2) {
- memset(p, ' ', pos-2);
- p += pos-2;
- }
- memcpy(p, ANSI_RED_ON, strlen(ANSI_RED_ON));
- p += strlen(ANSI_RED_ON);
+ if (pos > 2)
+ p = mempset(p, ' ', pos-2);
+ p = stpcpy(p, ANSI_RED_ON);
*p++ = '*';
}
if (pos > 0 && pos <= width) {
- memcpy(p, ANSI_HIGHLIGHT_RED_ON, strlen(ANSI_HIGHLIGHT_RED_ON));
- p += strlen(ANSI_HIGHLIGHT_RED_ON);
+ p = stpcpy(p, ANSI_HIGHLIGHT_RED_ON);
*p++ = '*';
}
- memcpy(p, ANSI_HIGHLIGHT_OFF, strlen(ANSI_HIGHLIGHT_OFF));
- p += strlen(ANSI_HIGHLIGHT_OFF);
+ p = stpcpy(p, ANSI_HIGHLIGHT_OFF);
if (pos < width) {
- memcpy(p, ANSI_RED_ON, strlen(ANSI_RED_ON));
- p += strlen(ANSI_RED_ON);
+ p = stpcpy(p, ANSI_RED_ON);
*p++ = '*';
- if (pos < width-1) {
- memset(p, ' ', width-1-pos);
- p += width-1-pos;
- }
- memcpy(p, ANSI_HIGHLIGHT_OFF, strlen(ANSI_HIGHLIGHT_OFF));
- p += strlen(ANSI_HIGHLIGHT_OFF);
+ if (pos < width-1)
+ p = mempset(p, ' ', width-1-pos);
+ p = stpcpy(p, ANSI_HIGHLIGHT_OFF);
}
- *p = 0;
}
static void manager_print_jobs_in_progress(Manager *m) {
if (j->state == JOB_RUNNING && counter++ == print_nr)
break;
+ /* m->n_running_jobs must be consistent with the contents of m->jobs,
+ * so the above loop must have succeeded in finding j. */
+ assert(counter == print_nr + 1);
+
cylon_pos = m->jobs_in_progress_iteration % 14;
if (cylon_pos >= 8)
cylon_pos = 14 - cylon_pos;
assert(hashmap_isempty(m->jobs));
assert(hashmap_isempty(m->units));
+
+ m->n_on_console = 0;
+ m->n_running_jobs = 0;
}
void manager_free(Manager *m) {
m->dispatching_run_queue = false;
- if (hashmap_size(m->jobs) > 0)
+ if (m->n_running_jobs > 0)
manager_watch_jobs_in_progress(m);
return n;
NULL);
/* Restart the watch */
+ epoll_ctl(m->epoll_fd, EPOLL_CTL_DEL, m->time_change_watch.fd,
+ NULL);
close_nointr_nofail(m->time_change_watch.fd);
watch_init(&m->time_change_watch);
manager_setup_time_change(m);
return false;
}
+bool manager_is_reloading_or_reexecuting(Manager *m) {
+ assert(m);
+
+ return m->n_reloading != 0;
+}
+
void manager_reset_failed(Manager *m) {
Unit *u;
Iterator i;
assert(m);
+ if (m->n_running_jobs == 0)
+ manager_unwatch_jobs_in_progress(m);
+
if (hashmap_size(m->jobs) > 0) {
manager_jobs_in_progress_mod_timer(m);
return;
/* Turn off confirm spawn now */
m->confirm_spawn = false;
- manager_unwatch_jobs_in_progress(m);
-
if (dual_timestamp_is_set(&m->finish_timestamp))
return;
return log_oom();
if (!mkdtemp(p)) {
- free(p);
log_error("Failed to create generator directory %s: %m",
p);
+ free(p);
return -errno;
}
}