diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2014-09-20 12:18:49 +0400 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-09-20 12:18:49 +0400 |
commit | 62e89248160d3592c2d754fcaa15e37586a5b091 (patch) | |
tree | a6513cfd1e8ef6c6079ea2436e8573b122cc1ec6 /accel-pppd/triton | |
parent | 0a58c20b44136c1fba996becea18696b3f67a1f9 (diff) | |
download | accel-ppp-62e89248160d3592c2d754fcaa15e37586a5b091.tar.gz accel-ppp-62e89248160d3592c2d754fcaa15e37586a5b091.zip |
rewrite of authentication/accounting procedures
This patch gets rid of synchronuos style of authentication/accounting.
Synchronous style of authentication/accounting produced sleeping threads
which becomes a problem when lots of sessions started/stopped and all they want authorization/accounting.
Diffstat (limited to 'accel-pppd/triton')
-rw-r--r-- | accel-pppd/triton/mempool.c | 80 | ||||
-rw-r--r-- | accel-pppd/triton/mempool.h | 7 | ||||
-rw-r--r-- | accel-pppd/triton/triton.c | 4 |
3 files changed, 19 insertions, 72 deletions
diff --git a/accel-pppd/triton/mempool.c b/accel-pppd/triton/mempool.c index 4a3ec8b0..7e5a4ce2 100644 --- a/accel-pppd/triton/mempool.c +++ b/accel-pppd/triton/mempool.c @@ -15,7 +15,7 @@ #define DELAY 5 #endif -//#define MEMPOOL_DISABLE +#define MEMPOOL_DISABLE #define MAGIC1 0x2233445566778899llu #define PAGE_ORDER 5 @@ -136,72 +136,6 @@ void __export *mempool_alloc(mempool_t *pool) return it->ptr; } -#else - -void __export *mempool_alloc_md(mempool_t *pool, const char *fname, int line) -{ - struct _mempool_t *p = (struct _mempool_t *)pool; - struct _item_t *it; - uint32_t size = sizeof(*it) + p->size + 8; - - spin_lock(&p->lock); - if (!list_empty(&p->items)) { - it = list_entry(p->items.next, typeof(*it), entry); -#ifdef VALGRIND - if (it->timestamp + DELAY < time(NULL)) { - VALGRIND_MAKE_MEM_DEFINED(&it->owner, size - sizeof(it->entry) - sizeof(it->timestamp)); - VALGRIND_MAKE_MEM_UNDEFINED(it->ptr, p->size); -#endif - list_del(&it->entry); - list_add(&it->entry, &p->ditems); - spin_unlock(&p->lock); - - it->fname = fname; - it->line = line; - - --p->objects; - __sync_sub_and_fetch(&triton_stat.mempool_available, size); - - it->magic1 = MAGIC1; - - return it->ptr; -#ifdef VALGRIND - } -#endif - } - spin_unlock(&p->lock); - - if (p->mmap) { - spin_lock(&mmap_lock); - if (mmap_ptr + size >= mmap_endptr) - mmap_grow(); - it = (struct _item_t *)mmap_ptr; - mmap_ptr += size; - spin_unlock(&mmap_lock); - __sync_sub_and_fetch(&triton_stat.mempool_available, size); - } else { - it = md_malloc(size, fname, line); - __sync_add_and_fetch(&triton_stat.mempool_allocated, size); - } - - if (!it) { - triton_log_error("mempool: out of memory"); - return NULL; - } - it->owner = p; - it->magic2 = p->magic; - it->magic1 = MAGIC1; - it->fname = fname; - it->line = line; - *(uint64_t*)(it->ptr + p->size) = it->magic2; - - spin_lock(&p->lock); - list_add(&it->entry, &p->ditems); - spin_unlock(&p->lock); - - return it->ptr; -} -#endif void __export mempool_free(void *ptr) { @@ -258,6 +192,18 @@ void __export mempool_free(void *ptr) } + +#else + +void __export *md_mempool_alloc(mempool_t *pool, const char *fname, int line) +{ + struct _mempool_t *p = (struct _mempool_t *)pool; + + return md_malloc(p->size, fname, line); +} +#endif + + #ifdef MEMDEBUG void __export mempool_show(mempool_t *pool) { diff --git a/accel-pppd/triton/mempool.h b/accel-pppd/triton/mempool.h index bdb3e712..53eebfb7 100644 --- a/accel-pppd/triton/mempool.h +++ b/accel-pppd/triton/mempool.h @@ -12,14 +12,15 @@ struct mempool_stat_t typedef void * mempool_t; mempool_t *mempool_create(int size); mempool_t *mempool_create2(int size); -void mempool_free(void*); struct mempool_stat_t mempool_get_stat(void); #ifdef MEMDEBUG -void *mempool_alloc_md(mempool_t*, const char *fname, int line); -#define mempool_alloc(pool) mempool_alloc_md(pool, __FILE__, __LINE__) +void *md_mempool_alloc(mempool_t*, const char *fname, int line); +#define mempool_alloc(pool) md_mempool_alloc(pool, __FILE__, __LINE__) +#define mempool_free(ptr) md_free(ptr, __FILE__, __LINE__) #else void *mempool_alloc(mempool_t*); +void mempool_free(void*); #endif #endif diff --git a/accel-pppd/triton/triton.c b/accel-pppd/triton/triton.c index 3c4de31d..5d6f31d1 100644 --- a/accel-pppd/triton/triton.c +++ b/accel-pppd/triton/triton.c @@ -569,7 +569,7 @@ static void ru_update(struct triton_timer_t *t) void __export triton_register_init(int order, void (*func)(void)) { - struct _triton_init_t *i1, *i = _malloc(sizeof(*i)); + struct _triton_init_t *i1, *i = malloc(sizeof(*i)); struct list_head *p = init_list.next; @@ -624,7 +624,7 @@ int __export triton_load_modules(const char *mod_sect) i = list_entry(init_list.next, typeof(*i), entry); i->func(); list_del(&i->entry); - _free(i); + free(i); } return 0; |