0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 17:51:53 +00:00

Fixed a munmap abort bug

When BIRD was munmapping too many pages, it sometimes aborted, saying
that munmap failed with "Not enough memory" as the address space was
getting more and more fragmented.

There is a workaround in place, simply keeping that page for future use,
yet it has never been compiled in because I somehow forgot to include
errno.h. And because I also thought that somebody may have ENOMEM not
defined (why?!), there was a check which quietly omitted that
workaround.

Anyway, ENOMEM is POSIX. It's an utter nonsense to check for its
existence. If it doesn't exist, something is broken.
This commit is contained in:
Maria Matejka 2022-04-13 11:28:15 +02:00
parent 692055e3df
commit 9eec503b25

View File

@ -11,6 +11,7 @@
#include "lib/lists.h" #include "lib/lists.h"
#include "lib/event.h" #include "lib/event.h"
#include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
@ -116,10 +117,8 @@ cleanup_pages(void *data UNUSED)
rem_node(ptr); rem_node(ptr);
if (munmap(ptr, get_page_size()) == 0) if (munmap(ptr, get_page_size()) == 0)
pages_kept--; pages_kept--;
#ifdef ENOMEM
else if (errno == ENOMEM) else if (errno == ENOMEM)
add_tail(&pages_list, ptr); add_tail(&pages_list, ptr);
#endif
else else
bug("munmap(%p) failed: %m", ptr); bug("munmap(%p) failed: %m", ptr);
} }