Merge pull request #995 from urbit/fix-libuv-max-allocation

Use smaller heap allocations on libuv i/o reads
This commit is contained in:
Joe Bryan 2018-12-11 21:04:37 -05:00 committed by GitHub
commit ccfe5888aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -30,8 +30,11 @@ _ames_alloc(uv_handle_t* had_u,
uv_buf_t* buf
)
{
void* ptr_v = c3_malloc(len_i);
*buf = uv_buf_init(ptr_v, len_i);
// we allocate 2K, which gives us plenty of space
// for a single ames packet (max size 1060 bytes)
//
void* ptr_v = c3_malloc(2048);
*buf = uv_buf_init(ptr_v, 2048);
}
/* _ames_free(): contrasting free.

View File

@ -41,14 +41,19 @@ _term_msc_out_host()
return 1000000ULL * tim_tv.tv_sec + tim_tv.tv_usec;
}
/* _term_alloc(): libuv buffer allocator.
*/
static void
_term_alloc(uv_handle_t* had_u,
size_t len_i,
uv_buf_t* buf
)
{
void* ptr_v = c3_malloc(len_i);
*buf = uv_buf_init(ptr_v, len_i);
// this read can range from a single byte to a paste buffer
// 32 bytes has been chosen heuristically
//
void* ptr_v = c3_malloc(32);
*buf = uv_buf_init(ptr_v, 32);
}