Welcome! Log In Create A New Profile

Advanced

make ngx_pool clear2

All files from this thread

File Name File Size   Posted by Date  
diff.patch 4.2 KB open | download liuyujun 06/04/2019 Read message
liuyujun
June 04, 2019 04:40AM
hello. everybody here?

example before:
for (p = pool; p; p = p->d.next) {
p->d.last = (u_char *) p + sizeof(ngx_pool_t);
p->d.failed = 0;
}




after:
for (p = &pool->d; p; p = p->next) {
if (p == &pool->d) {
p->last = (u_char *) p + sizeof(ngx_pool_t);
} else {
p->last = (u_char *) p + sizeof(ngx_pool_data_t);
}
p->failed = 0;
}




example2 before:
static void *
ngx_palloc_block(ngx_pool_t *pool, size_t size)
{
u_char *m;
size_t psize;
ngx_pool_t *p, *new;

psize = (size_t) (pool->d.end - (u_char *) pool);

m = ngx_memalign(NGX_POOL_ALIGNMENT, psize, pool->log);
if (m == NULL) {
return NULL;
}

new = (ngx_pool_t *) m;

new->d.end = m + psize;
new->d.next = NULL;
new->d.failed = 0;

m += sizeof(ngx_pool_data_t);
m = ngx_align_ptr(m, NGX_ALIGNMENT);
new->d.last = m + size;

for (p = pool->current; p->d.next; p = p->d.next) {
if (p->d.failed++ > 4) {
pool->current = p->d.next;
}
}

p->d.next = new;

return m;
}


after:
static void *
ngx_palloc_block(ngx_pool_t *pool, size_t size)
{
u_char *m;
size_t psize;
ngx_pool_data_t *p, *new;

psize = (size_t) (pool->d.end - (u_char *) pool);

m = ngx_memalign(NGX_POOL_ALIGNMENT, psize, pool->log);
if (m == NULL) {
return NULL;
}

new = (ngx_pool_data_t *) m;

new->end = m + psize;
new->next = NULL;
new->failed = 0;

m += sizeof(ngx_pool_data_t);
m = ngx_align_ptr(m, NGX_ALIGNMENT);
new->last = m + size;

for (p = pool->current; p->next; p = p->next) {
if (p->failed++ > 4) {
pool->current = p->next;
}
}

p->next = new;

return m;
}_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Attachments:
open | download - diff.patch (4.2 KB)
Subject Author Posted

make ngx_pool clear2 Attachments

liuyujun June 04, 2019 04:40AM

Re: make ngx_pool clear2

Maxim Dounin June 04, 2019 06:20AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 238
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready