Skip to content

Commit

Permalink
cgroup.c: fix a iwatcher initializing issue
Browse files Browse the repository at this point in the history
iwatcher of cgroup needs to be initialized earlier before any
cgroup_add functions being called.

Signed-off-by: Ming Liu <liu.ming50@gmail.com>
  • Loading branch information
liuming50 committed Jan 27, 2022
1 parent f32e4d4 commit add474e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,13 @@ void cgroup_init(uev_ctx_t *ctx)
if (fnwrite(controllers, FINIT_CGPATH "/cgroup.subtree_control"))
_pe("Failed enabling %s for %s", controllers, FINIT_CGPATH "/cgroup.subtree_control");

/* prepare cgroup.events watcher */
fd = iwatch_init(&iw_cgroup);
if (uev_io_init(ctx, &cgw, cgroup_events_cb, NULL, fd, UEV_READ)) {
_pe("Failed setting up cgroup.events watcher");
close(fd);
}

/* Default (protected) groups, PID 1, services, and user/login processes */
cgroup_add("init", "cpu.weight:100", 1);
cgroup_add("system", "cpu.weight:9800", 1);
Expand All @@ -507,13 +514,6 @@ void cgroup_init(uev_ctx_t *ctx)
/* Move ourselves to init (best effort, otherwise run in 'root' group */
if (fnwrite("1", FINIT_CGPATH "/init/cgroup.procs"))
_pe("Failed moving PID 1 to cgroup ", FINIT_CGPATH "/init");

/* prepare cgroup.events watcher */
fd = iwatch_init(&iw_cgroup);
if (uev_io_init(ctx, &cgw, cgroup_events_cb, NULL, fd, UEV_READ)) {
_pe("Failed setting up cgroup.events watcher");
close(fd);
}
}

/**
Expand Down

0 comments on commit add474e

Please sign in to comment.