mirror of
https://github.com/nginx/nginx.git
synced 2025-01-05 21:53:01 -06:00
Linux/SPARC malloc() returns an address aligned to 8. This conflicts with
our SPARC 16-byte alignment and some allocations may be done out of pool. ngx_memalign(ngx_pagesize) fixes this issue.
This commit is contained in:
parent
689064b91a
commit
687b0e99ea
@ -280,6 +280,9 @@ main(int argc, char *const *argv)
|
||||
init_cycle.log = log;
|
||||
ngx_cycle = &init_cycle;
|
||||
|
||||
/* dummy pagesize to create aligned pool */
|
||||
ngx_pagesize = 1024;
|
||||
|
||||
init_cycle.pool = ngx_create_pool(1024, log);
|
||||
if (init_cycle.pool == NULL) {
|
||||
return 1;
|
||||
|
@ -17,7 +17,7 @@ ngx_create_pool(size_t size, ngx_log_t *log)
|
||||
{
|
||||
ngx_pool_t *p;
|
||||
|
||||
p = ngx_alloc(size, log);
|
||||
p = ngx_memalign(ngx_pagesize, size, log);
|
||||
if (p == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@ -181,7 +181,7 @@ ngx_palloc_block(ngx_pool_t *pool, size_t size)
|
||||
|
||||
psize = (size_t) (pool->d.end - (u_char *) pool);
|
||||
|
||||
m = ngx_alloc(psize, pool->log);
|
||||
m = ngx_memalign(ngx_pagesize, psize, pool->log);
|
||||
if (m == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@ -219,7 +219,7 @@ ngx_palloc_large(ngx_pool_t *pool, size_t size)
|
||||
ngx_uint_t n;
|
||||
ngx_pool_large_t *large;
|
||||
|
||||
p = ngx_alloc(size, pool->log);
|
||||
p = ngx_memalign(ngx_pagesize, size, pool->log);
|
||||
if (p == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user