[Tarantool-patches] [PATCH 14/16] sio: increase SERVICE_NAME_MAXLEN size

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Mar 23 01:32:14 MSK 2021


Hi! Thanks for the review!

On 21.03.2021 22:58, Cyrill Gorcunov wrote:
> On Sat, Mar 20, 2021 at 01:42:36AM +0100, Vladislav Shpilevoy wrote:
>>  
>> -enum { SERVICE_NAME_MAXLEN = 32 };
>> +enum {
>> +	/**
>> +	 * - Unix socket path is 108 bytes max;
>> +	 * - IP(v4, v6) max string len is 45;
> 
> Actually IPv6 may include a scope as well. Currently at least
> libc indeed does limit it to 45 symbols plus eos mark so we're
> safe. Still 200 seems to be much over the top, maybe 128 instead?

I decided to be paranoid and made it 200 deliberately. Anyway it is
not used in any swarm allocations. 128 seems right on the edge. You
can have 108 bytes of Unix socket path, + strlen("unix/:"). It is
already 114.

Also it is used for sio_socketname(), where you have addr str (114)
+ strlen(", aka ")(6) + strlen(", peer of ")(10), which is already
130 total.

> Also pow2 gonna be easier to manage by any memory manager.

It would matter if the buffer would be ever allocated on its own.
But it is always either on the stack, or inside of another structure,
where total size is not a power of 2 anyway, most likely.

> I don't insist though just a thought and this could be tuned up
> on top.


More information about the Tarantool-patches mailing list