chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
manager: use more stpcpy()
[elogind.git]
/
src
/
core
/
manager.c
diff --git
a/src/core/manager.c
b/src/core/manager.c
index d976581c96bfa897bbc4cb60fd6d83e27b37ada3..a3eeb4afc10c9837c238bc4e1c9d739e6b9cda25 100644
(file)
--- a/
src/core/manager.c
+++ b/
src/core/manager.c
@@
-148,6
+148,9
@@
static int manager_setup_notify(Manager *m) {
static int manager_jobs_in_progress_mod_timer(Manager *m) {
struct itimerspec its;
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;
zero(its);
its.it_value.tv_sec = JOBS_IN_PROGRESS_WAIT_SEC;
@@
-227,32
+230,26
@@
static void draw_cylon(char buffer[], size_t buflen, unsigned width, unsigned po
memset(p, ' ', pos-2);
p += pos-2;
}
memset(p, ' ', pos-2);
p += pos-2;
}
- memcpy(p, ANSI_RED_ON, strlen(ANSI_RED_ON));
- p += strlen(ANSI_RED_ON);
+ p = stpcpy(p, ANSI_RED_ON);
*p++ = '*';
}
if (pos > 0 && pos <= width) {
*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++ = '*';
}
*p++ = '*';
}
- memcpy(p, ANSI_HIGHLIGHT_OFF, strlen(ANSI_HIGHLIGHT_OFF));
- p += strlen(ANSI_HIGHLIGHT_OFF);
+ p = stpcpy(p, ANSI_HIGHLIGHT_OFF);
if (pos < width) {
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;
}
*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);
+ p = stpcpy(p, ANSI_HIGHLIGHT_OFF);
}
}
- *p = 0;
}
static void manager_print_jobs_in_progress(Manager *m) {
}
static void manager_print_jobs_in_progress(Manager *m) {
@@
-269,8
+266,9
@@
static void manager_print_jobs_in_progress(Manager *m) {
if (j->state == JOB_RUNNING && counter++ == print_nr)
break;
if (j->state == JOB_RUNNING && counter++ == print_nr)
break;
- if (!j)
- return;
+ /* 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 = m->jobs_in_progress_iteration % 14;
if (cylon_pos >= 8)
@@
-1143,7
+1141,7
@@
unsigned manager_dispatch_run_queue(Manager *m) {
m->dispatching_run_queue = false;
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;
manager_watch_jobs_in_progress(m);
return n;
@@
-1673,6
+1671,8
@@
static int process_event(Manager *m, struct epoll_event *ev) {
NULL);
/* Restart the watch */
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);
close_nointr_nofail(m->time_change_watch.fd);
watch_init(&m->time_change_watch);
manager_setup_time_change(m);
@@
-2367,6
+2367,9
@@
void manager_check_finished(Manager *m) {
assert(m);
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;
if (hashmap_size(m->jobs) > 0) {
manager_jobs_in_progress_mod_timer(m);
return;
@@
-2378,8
+2381,6
@@
void manager_check_finished(Manager *m) {
/* Turn off confirm spawn now */
m->confirm_spawn = false;
/* Turn off confirm spawn now */
m->confirm_spawn = false;
- manager_unwatch_jobs_in_progress(m);
-
if (dual_timestamp_is_set(&m->finish_timestamp))
return;
if (dual_timestamp_is_set(&m->finish_timestamp))
return;