summaryrefslogtreecommitdiff
path: root/nscd/mem.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2005-08-24 07:23:32 +0000
committerJakub Jelinek <jakub@redhat.com>2005-08-24 07:23:32 +0000
commit8bf34d8a27ffed48c7a43b7c7347235d389b0946 (patch)
tree36a2efd2a73c3d642829770b47f753e0160dd411 /nscd/mem.c
parentd2b0f6344275bc3624e47a4d02b67a7e131f6f56 (diff)
Updated to fedora-glibc-20050824T0705
Diffstat (limited to 'nscd/mem.c')
-rw-r--r--nscd/mem.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/nscd/mem.c b/nscd/mem.c
index 823eda1019..96f0170c6c 100644
--- a/nscd/mem.c
+++ b/nscd/mem.c
@@ -481,18 +481,26 @@ mempool_alloc (struct database_dyn *db, size_t len)
if (! tried_resize)
{
/* Try to resize the database. Grow size of 1/8th. */
- size_t new_data_size = db->head->data_size + db->head->data_size / 8;
size_t oldtotal = (sizeof (struct database_pers_head)
+ db->head->module * sizeof (ref_t)
+ db->head->data_size);
+ size_t new_data_size = (db->head->data_size
+ + MAX (2 * len, db->head->data_size / 8));
size_t newtotal = (sizeof (struct database_pers_head)
+ db->head->module * sizeof (ref_t)
+ new_data_size);
+ if (newtotal > db->max_db_size)
+ {
+ new_data_size -= newtotal - db->max_db_size;
+ newtotal = db->max_db_size;
+ }
- if ((!db->mmap_used
- || posix_fallocate (db->wr_fd, oldtotal, newtotal) != 0)
- /* Try to resize the mapping. Note: no MREMAP_MAYMOVE. */
- && mremap (db->head, oldtotal, newtotal, 0) == 0)
+ if (db->mmap_used && newtotal > oldtotal
+ /* We only have to adjust the file size. The new pages
+ become magically available. */
+ && TEMP_FAILURE_RETRY_VAL (posix_fallocate (db->wr_fd, oldtotal,
+ newtotal
+ - oldtotal)) == 0)
{
db->head->data_size = new_data_size;
tried_resize = true;