diff options
author | Ulrich Drepper <drepper@redhat.com> | 2007-11-25 21:08:01 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2007-11-25 21:08:01 +0000 |
commit | 30294ea4495e48e0103fee4d855737a281cc49fa (patch) | |
tree | 23a6e4b71c9fb7758596f212085e0ce8eaf7e4b9 /nscd/mem.c | |
parent | 609bb0712d522828bf52eb539d0b590ae153e55f (diff) | |
download | glibc-30294ea4495e48e0103fee4d855737a281cc49fa.zip glibc-30294ea4495e48e0103fee4d855737a281cc49fa.tar.gz glibc-30294ea4495e48e0103fee4d855737a281cc49fa.tar.bz2 |
* nscd/nscd.h (MAX_STACK_USE): Define.
* nscd/mem.c (MAX_STACK_USE): Remove definition here.
(gc): Initialize stack_used based on allocation in prune_cache.
* nscd/cache.c (prune_cache): Use heap for mark array if necessary.
Clear array bfore use.
* nscd/aicache.c (addhstaiX): Update statistics counter in case
memory allocate failed.
Diffstat (limited to 'nscd/mem.c')
-rw-r--r-- | nscd/mem.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -74,10 +74,6 @@ sort_he_data (const void *p1, const void *p2) #define ALLBITS ((((BITMAP_T) 1) << BITS) - 1) #define HIGHBIT (((BITMAP_T) 1) << (BITS - 1)) -/* Maximum size of stack frames we allow the thread to use. We use - 80% of the thread stack size. */ -#define MAX_STACK_USE ((8 * NSCD_THREAD_STACKSIZE) / 10) - static void markrange (BITMAP_T *mark, ref_t start, size_t len) @@ -129,7 +125,11 @@ gc (struct database_dyn *db) BITMAP_T *mark; bool mark_use_malloc; - size_t stack_used = 0; + /* In prune_cache we are also using a dynamically allocated array. + If the array in the caller is too large we have malloc'ed it. */ + size_t stack_used = sizeof (bool) * db->head->module; + if (__builtin_expect (stack_used > MAX_STACK_USE, 0)) + stack_used = 0; size_t memory_needed = ((db->head->first_free / BLOCK_ALIGN + BITS - 1) / BITS) * sizeof (BITMAP_T); if (memory_needed <= MAX_STACK_USE) |