summaryrefslogtreecommitdiff
path: root/sysdep/unix
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2022-04-13 11:28:15 +0200
committerMaria Matejka <mq@ucw.cz>2022-04-13 11:36:54 +0200
commit9eec503b251c3388579032b300d32640403d8612 (patch)
treebdfdab75fadbb23a7261a887e8ac8a3ac757982e /sysdep/unix
parent692055e3df6cc9f0d428d3b0dd8cdd8e825eb6f4 (diff)
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.
Diffstat (limited to 'sysdep/unix')
-rw-r--r--sysdep/unix/alloc.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/sysdep/unix/alloc.c b/sysdep/unix/alloc.c
index 0e944d57..90453f7b 100644
--- a/sysdep/unix/alloc.c
+++ b/sysdep/unix/alloc.c
@@ -11,6 +11,7 @@
#include "lib/lists.h"
#include "lib/event.h"
+#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
@@ -116,10 +117,8 @@ cleanup_pages(void *data UNUSED)
rem_node(ptr);
if (munmap(ptr, get_page_size()) == 0)
pages_kept--;
-#ifdef ENOMEM
else if (errno == ENOMEM)
add_tail(&pages_list, ptr);
-#endif
else
bug("munmap(%p) failed: %m", ptr);
}