Welcome! Log In Create A New Profile

Advanced

function ngx_memcmp: ограничение по памяти.

October 14, 2014 05:42AM
Привет всем.
Использую модуль nginx_push_stream_module для реализации push-механизма server -> browser.
В определенный момент, когда очередной клиент пытается встать на канал, начинает возвращаться ошибка: unable to allocate shared memory for channel

Вот кусок кода в модуле где он [nginx_push_stream_module] пытается выделить канал:

channel = ngx_http_push_stream_find_channel(cur->id, r->connection->log, mcf);
if (channel == NULL) {
// channel not found
ngx_shmtx_unlock(&shpool->mutex);
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "push stream module: unable to allocate shared memory for channel %s", cur->id->data);
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
Как видим, если ngx_http_push_stream_find_channel вернул NULL то вылетает эта ошибка.

В свою очередь ngx_http_push_stream_find_channel использует nginx функцию ngx_memn2cmp:

rc = ngx_memn2cmp(id->data, channel->id.data, id->len, channel->id.len);
if (rc == 0) {
return channel;
}
Та в свою очередь использует уже ngx_memcmp в самом nginx:

ngx_memn2cmp(u_char *s1, u_char *s2, size_t n1, size_t n2)
{
size_t n;
ngx_int_t m, z;

if (n1 <= n2) {
n = n1;
z = -1;

} else {
n = n2;
z = 1;
}

m = ngx_memcmp(s1, s2, n);

if (m || n1 == n2) {
return m;
}

return z;
}

Вопросы:
- в каком случае может не хватить памяти для ngx_memcmp?
- что она точно делает? как я понял, это сравнение памяти.
- сейчас каждый воркер потребляет 30 мб всего 16 воркеров.
- как настроить систему, nginx или и то и то, чтобы ошибка больше не проявлялалась

В системе еще 6 гб свободно памяти.

Ссылки на код модуля:

https://github.com/wandenberg/nginx-push-stream-module/blob/e802241cad3d5d1c1e63828f5f55a6f8a2f1be1e/src/ngx_http_push_stream_module_subscriber.c#L188

https://github.com/wandenberg/nginx-push-stream-module/blob/e802241cad3d5d1c1e63828f5f55a6f8a2f1be1e/src/ngx_http_push_stream_rbtree_util.c#L37
Subject Author Posted

function ngx_memcmp: ограничение по памяти.

JohnBat26 October 14, 2014 05:42AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 146
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready