From c52137d39101515cacb67a2bcd43b77bd06284e0 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 19 Apr 2008 16:42:41 +0000 Subject: [BZ #5209, BZ #5381] 2008-04-15 Ulrich Drepper [BZ #5209] * sysdeps/unix/sysv/linux/times.c: New file. [BZ #5381] * nscd/nscd.h: Define enum in_flight, mem_in_flight, and mem_in_flight_list variables. Add new parameter to mempool_alloc prototype. * nscd/mem.c (mempool_alloc): Take additional parameter. Initialize appropriate mem_in_flight element. (gc): Take allocations which have not yet been committed to the database into account. * nscd/cache.c (cache_add): Add new parameter to mempool_alloc call. Reset mem_in_flight before returning. * nscd/connections.c (nscd_run_worker): Initialize mem_in_flight and cue it up in mem_in_flight_list. * nscd/aicache.c: Adjust mempool_alloc call. * nscd/grpcache.c: Likewise. * nscd/hstcache.c: Likewise. * nscd/initgrcache.c: Likewise. * nscd/pwdcache.c: Likewise. * nscd/servicescache.c: Likewise. * nscd/Makefile (nscd-flags): Until ld is fixed, use -fpic instead of -fpie. * nscd/connections.c (handle_request): Provide better error message in case SELinux forbids the service. * version.h (VERSION): Bump to 2.8.90. --- nscd/cache.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'nscd/cache.c') diff --git a/nscd/cache.c b/nscd/cache.c index 12c4f01e40..b1dc2c5052 100644 --- a/nscd/cache.c +++ b/nscd/cache.c @@ -1,4 +1,4 @@ -/* Copyright (c) 1998, 1999, 2003-2006, 2007 Free Software Foundation, Inc. +/* Copyright (c) 1998, 1999, 2003-2007, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1998. @@ -155,11 +155,16 @@ cache_add (int type, const void *key, size_t len, struct datahead *packet, unsigned long int hash = __nis_hash (key, len) % table->head->module; struct hashentry *newp; - newp = mempool_alloc (table, sizeof (struct hashentry)); + newp = mempool_alloc (table, sizeof (struct hashentry), IDX_record_data); /* If we cannot allocate memory, just do not do anything. */ if (newp == NULL) { ++table->head->addfailed; + + /* Mark the in-flight memory as unused. */ + for (enum in_flight idx = 0; idx < IDX_record_data; ++idx) + mem_in_flight.block[idx].dbidx = -1; + return -1; } @@ -215,6 +220,10 @@ cache_add (int type, const void *key, size_t len, struct datahead *packet, else next_wakeup = table->wakeup_time; + /* Mark the in-flight memory as unused. */ + for (enum in_flight idx = 0; idx < IDX_last; ++idx) + mem_in_flight.block[idx].dbidx = -1; + return 0; } -- cgit v1.2.3