mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-08-29 01:50:15 +03:00
process only one epoll event at a time
if we ask for more than one from the kernel we might need to check for the validity of the ptr element since event might be processed after its ptr was already destructed.
This commit is contained in:
18
manager.c
18
manager.c
@ -1084,12 +1084,12 @@ int manager_loop(Manager *m) {
|
||||
assert(m);
|
||||
|
||||
for (;;) {
|
||||
struct epoll_event events[32];
|
||||
int n, i;
|
||||
struct epoll_event event;
|
||||
int n;
|
||||
|
||||
manager_dispatch_run_queue(m);
|
||||
|
||||
if ((n = epoll_wait(m->epoll_fd, events, ELEMENTSOF(events), -1)) < 0) {
|
||||
if ((n = epoll_wait(m->epoll_fd, &event, 1, -1)) < 0) {
|
||||
|
||||
if (errno == -EINTR)
|
||||
continue;
|
||||
@ -1097,12 +1097,12 @@ int manager_loop(Manager *m) {
|
||||
return -errno;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if ((r = process_event(m, events + i, &quit)) < 0)
|
||||
return r;
|
||||
assert(n == 1);
|
||||
|
||||
if (quit)
|
||||
return 0;
|
||||
}
|
||||
if ((r = process_event(m, &event, &quit)) < 0)
|
||||
return r;
|
||||
|
||||
if (quit)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user