mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 20:50:14 +01:00
extmod/modselect: Handle growing the pollfds allocation correctly.
The poll_obj_t instances have their pollfd field point into this allocation. So if re-allocating results in a move, we need to update the existing poll_obj_t's. Update the test to cover this case. Fixes issue #12887. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
committed by
Damien George
parent
e9bcd49b3e
commit
8b24aa36ba
@@ -34,11 +34,22 @@ poller.register(1, select.POLLIN)
|
||||
# Poll for input, should return an empty list.
|
||||
print(poller.poll(0))
|
||||
|
||||
# Test registering a very large number of file descriptors.
|
||||
# Test registering a very large number of file descriptors (will trigger
|
||||
# EINVAL due to more than OPEN_MAX fds).
|
||||
poller = select.poll()
|
||||
for fd in range(6000):
|
||||
poller.register(fd)
|
||||
try:
|
||||
poller.poll()
|
||||
assert False
|
||||
except OSError as er:
|
||||
print(er.errno == errno.EINVAL)
|
||||
|
||||
# Register stdout/stderr, plus many extra ones to trigger the fd vector
|
||||
# resizing. Then unregister the excess ones and verify poll still works.
|
||||
poller = select.poll()
|
||||
for fd in range(1, 1000):
|
||||
poller.register(fd)
|
||||
for i in range(3, 1000):
|
||||
poller.unregister(i)
|
||||
print(sorted(poller.poll()))
|
||||
|
||||
Reference in New Issue
Block a user