Skip to content

Commit

Permalink
* nscd/mem.c (mempool_alloc): Use posix_fallocate instead of ftruncate.
Browse files Browse the repository at this point in the history
	* nscd/connections.c (nscd_init): Likewise.
  • Loading branch information
Ulrich Drepper committed Aug 8, 2005
1 parent e62995c commit f54a329
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2005-08-08 Ulrich Drepper <drepper@redhat.com>

* nscd/mem.c (mempool_alloc): Use posix_fallocate instead of ftruncate.
* nscd/connections.c (nscd_init): Likewise.

2005-08-08 Jakub Jelinek <jakub@redhat.com>

* stdio-common/fxprintf.c: Include libioP.h.
Expand Down
2 changes: 1 addition & 1 deletion nscd/connections.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ cannot create read-only descriptor for \"%s\"; no mmap"),

if ((TEMP_FAILURE_RETRY (write (fd, &head, sizeof (head)))
!= sizeof (head))
|| ftruncate (fd, total) != 0
|| posix_fallocate (fd, 0, total) != 0
|| (mem = mmap (NULL, total, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0)) == MAP_FAILED)
{
Expand Down
4 changes: 3 additions & 1 deletion nscd/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <assert.h>
#include <errno.h>
#include <error.h>
#include <fcntl.h>
#include <inttypes.h>
#include <libintl.h>
#include <limits.h>
Expand Down Expand Up @@ -488,7 +489,8 @@ mempool_alloc (struct database_dyn *db, size_t len)
+ db->head->module * sizeof (ref_t)
+ new_data_size);

if ((!db->mmap_used || ftruncate (db->wr_fd, newtotal) != 0)
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)
{
Expand Down

0 comments on commit f54a329

Please sign in to comment.