The flag allows to suppress "ngx_slab_alloc() failed: no memory" messages
from a slab allocator, e.g., if an LRU expiration is used by a consumer
and allocation failures aren't fatal.
The flag is now used in the SSL session cache code, and in the limit_req
module.
pool->pages->slab = pages;
}
+ pool->log_nomem = 1;
pool->log_ctx = &pool->zero;
pool->zero = '\0';
}
}
}
- ngx_slab_error(pool, NGX_LOG_CRIT, "ngx_slab_alloc() failed: no memory");
+ if (pool->log_nomem) {
+ ngx_slab_error(pool, NGX_LOG_CRIT,
+ "ngx_slab_alloc() failed: no memory");
+ }
return NULL;
}
u_char *log_ctx;
u_char zero;
+ unsigned log_nomem:1;
+
void *data;
void *addr;
} ngx_slab_pool_t;
ngx_sprintf(shpool->log_ctx, " in SSL session shared cache \"%V\"%Z",
&shm_zone->shm.name);
+ shpool->log_nomem = 0;
+
return NGX_OK;
}
ngx_shmtx_unlock(&shpool->mutex);
ngx_log_error(NGX_LOG_ALERT, c->log, 0,
- "could not add new SSL session to the session cache");
+ "could not allocate new session%s", shpool->log_ctx);
return 0;
}
node = ngx_slab_alloc_locked(ctx->shpool, size);
if (node == NULL) {
+ ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,
+ "could not allocate node%s", ctx->shpool->log_ctx);
return NGX_ERROR;
}
}
ngx_sprintf(ctx->shpool->log_ctx, " in limit_req zone \"%V\"%Z",
&shm_zone->shm.name);
+ ctx->shpool->log_nomem = 0;
+
return NGX_OK;
}