OSDN Git Service

don't create aio queue/map structures for invalid file descriptors
authorRich Felker <dalias@aerifal.cx>
Tue, 11 Dec 2018 21:41:09 +0000 (16:41 -0500)
committerRich Felker <dalias@aerifal.cx>
Tue, 11 Dec 2018 21:41:09 +0000 (16:41 -0500)
commita9a9882fbe089a0a9f562d8ecd4c96e52b3548f1
tree266162faa3efd53a5ed42ce3502e3de2e531142c
parent8511511c583cf44ed3aa0bbcaab9168956dce493
don't create aio queue/map structures for invalid file descriptors

the map structures in particular are permanent once created, and thus
a large number of aio function calls with invalid file descriptors
could exhaust memory, whereas, assuming normal resource limits, only a
very small number of entries ever need to be allocated. check validity
of the fd before allocating anything new, so that allocation of large
amounts of memory is only possible when resource limits have been
increased and a large number of files are actually open.

this change also improves error reporting for bad file descriptors to
happen at the time the aio submission call is made, as opposed to
asynchronously.
src/aio/aio.c