Ensure that marking a child for removal works even when the child is still in the queue to be added
Fixes #5895
This commit is contained in:
parent
2d846f53a1
commit
68a006444e
@ -506,17 +506,30 @@ parse_input(ChildMonitor *self) {
|
|||||||
return input_read;
|
return input_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static bool
|
||||||
mark_child_for_close(ChildMonitor *self, id_type window_id) {
|
mark_child_for_close(ChildMonitor *self, id_type window_id) {
|
||||||
|
bool found = false;
|
||||||
children_mutex(lock);
|
children_mutex(lock);
|
||||||
for (size_t i = 0; i < self->count; i++) {
|
for (size_t i = 0; i < self->count; i++) {
|
||||||
if (children[i].id == window_id) {
|
if (children[i].id == window_id) {
|
||||||
children[i].needs_removal = true;
|
children[i].needs_removal = true;
|
||||||
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!found) {
|
||||||
|
for (size_t i = 0; i < add_queue_count; i++) {
|
||||||
|
if (add_queue[i].id == window_id) {
|
||||||
|
add_queue[i].needs_removal = true;
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
children_mutex(unlock);
|
children_mutex(unlock);
|
||||||
wakeup_io_loop(self, false);
|
wakeup_io_loop(self, false);
|
||||||
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -525,8 +538,8 @@ mark_for_close(ChildMonitor *self, PyObject *args) {
|
|||||||
#define mark_for_close_doc "Mark a child to be removed from the child monitor"
|
#define mark_for_close_doc "Mark a child to be removed from the child monitor"
|
||||||
id_type window_id;
|
id_type window_id;
|
||||||
if (!PyArg_ParseTuple(args, "K", &window_id)) return NULL;
|
if (!PyArg_ParseTuple(args, "K", &window_id)) return NULL;
|
||||||
mark_child_for_close(self, window_id);
|
if (mark_child_for_close(self, window_id)) { Py_RETURN_TRUE; }
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|||||||
@ -1247,7 +1247,7 @@ class ChildMonitor:
|
|||||||
def add_child(self, id: int, pid: int, fd: int, screen: Screen) -> None:
|
def add_child(self, id: int, pid: int, fd: int, screen: Screen) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def mark_for_close(self, window_id: int) -> None:
|
def mark_for_close(self, window_id: int) -> bool:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def start(self) -> None:
|
def start(self) -> None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user