diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2010-11-21 17:31:00 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2010-11-21 17:31:00 +0300 |
commit | a09fdabf7939819581c6b7797b180a18c4f477fa (patch) | |
tree | 4cfaa02377ff7a660c53099c300de0890dff5d3f /accel-pptpd/triton/mempool.c | |
parent | ddad202eca1c0a1d95321bd396df0dda01620a2b (diff) | |
download | accel-ppp-xebd-a09fdabf7939819581c6b7797b180a18c4f477fa.tar.gz accel-ppp-xebd-a09fdabf7939819581c6b7797b180a18c4f477fa.zip |
bug fixes
Diffstat (limited to 'accel-pptpd/triton/mempool.c')
-rw-r--r-- | accel-pptpd/triton/mempool.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/accel-pptpd/triton/mempool.c b/accel-pptpd/triton/mempool.c index 0ba4ebe..51cde51 100644 --- a/accel-pptpd/triton/mempool.c +++ b/accel-pptpd/triton/mempool.c @@ -70,7 +70,7 @@ void __export *mempool_alloc(mempool_t *pool) list_del(&it->entry); spin_unlock(&p->lock); - __sync_fetch_and_sub(&triton_stat.mempool_available, size); + triton_stat.mempool_available -= size; it->magic1 = MAGIC1; @@ -88,7 +88,7 @@ void __export *mempool_alloc(mempool_t *pool) it->magic2 = p->magic; *(uint64_t*)(it->data + p->size) = it->magic2; - __sync_fetch_and_add(&triton_stat.mempool_allocated, size); + triton_stat.mempool_allocated += size; return it->ptr; } @@ -110,7 +110,7 @@ void __export *mempool_alloc_md(mempool_t *pool, const char *fname, int line) it->fname = fname; it->line = line; - __sync_fetch_and_sub(&triton_stat.mempool_available, size); + triton_stat.mempool_available -= size; it->magic1 = MAGIC1; @@ -134,7 +134,7 @@ void __export *mempool_alloc_md(mempool_t *pool, const char *fname, int line) list_add(&it->entry, &p->ditems); spin_unlock(&p->lock); - __sync_fetch_and_add(&triton_stat.mempool_allocated, size); + triton_stat.mempool_allocated += size; return it->ptr; } @@ -168,10 +168,16 @@ void __export mempool_free(void *ptr) #ifdef MEMDEBUG list_del(&it->entry); #endif +#ifndef MEMPOOL_DISABLE list_add_tail(&it->entry,&it->owner->items); +#endif spin_unlock(&it->owner->lock); - __sync_fetch_and_add(&triton_stat.mempool_available, size); +#ifdef MEMPOOL_DISABLE + _free(it); +#endif + + triton_stat.mempool_available += size; } void __export mempool_clean(mempool_t *pool) @@ -185,8 +191,8 @@ void __export mempool_clean(mempool_t *pool) it = list_entry(p->items.next, typeof(*it), entry); list_del(&it->entry); _free(it); - __sync_fetch_and_sub(&triton_stat.mempool_allocated, size); - __sync_fetch_and_sub(&triton_stat.mempool_available, size); + triton_stat.mempool_allocated -= size; + triton_stat.mempool_available -= size; } spin_unlock(&p->lock); } @@ -220,8 +226,8 @@ void sigclean(int num) it = list_entry(p->items.next, typeof(*it), entry); list_del(&it->entry); _free(it); - __sync_fetch_and_sub(&triton_stat.mempool_allocated, size); - __sync_fetch_and_sub(&triton_stat.mempool_available, size); + triton_stat.mempool_allocated -= size; + triton_stat.mempool_available -= size; } spin_unlock(&p->lock); } |