diff options
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -411,12 +411,32 @@ static void setup_thread(LIBEVENT_THREAD *me) { fprintf(stderr, "Failed to create response cache\n"); exit(EXIT_FAILURE); } + // Note: we were cleanly passing in num_threads before, but this now + // relies on settings globals too much. + if (settings.resp_obj_mem_limit) { + int limit = settings.resp_obj_mem_limit / settings.num_threads; + if (limit < sizeof(mc_resp)) { + limit = 1; + } else { + limit = limit / sizeof(mc_resp); + } + cache_set_limit(me->resp_cache, limit); + } me->rbuf_cache = cache_create("rbuf", READ_BUFFER_SIZE, sizeof(char *), NULL, NULL); if (me->rbuf_cache == NULL) { fprintf(stderr, "Failed to create read buffer cache\n"); exit(EXIT_FAILURE); } + if (settings.read_buf_mem_limit) { + int limit = settings.read_buf_mem_limit / settings.num_threads; + if (limit < READ_BUFFER_SIZE) { + limit = 1; + } else { + limit = limit / READ_BUFFER_SIZE; + } + cache_set_limit(me->rbuf_cache, limit); + } #ifdef EXTSTORE me->io_cache = cache_create("io", sizeof(io_wrap), sizeof(char*), NULL, NULL); |