From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 1/1] fiber: extend max fiber name length to 255
Date: Sat, 14 Mar 2020 19:34:32 +0300 [thread overview]
Message-ID: <20200314163432.GW27301@uranus> (raw)
In-Reply-To: <3d2907a0285c640ea09eec86c8922e43c5844953.1584198310.git.v.shpilevoy@tarantool.org>
On Sat, Mar 14, 2020 at 04:16:35PM +0100, Vladislav Shpilevoy wrote:
> Users keep complaining about too short fiber name. New limit is
> 255, should be enough for any sane name.
>
> Closes #4394
>
> fiber_set_name(struct fiber *fiber, const char *name)
> {
> - assert(name != NULL);
> - snprintf(fiber->name, sizeof(fiber->name), "%s", name);
> + size_t len = MIN(strlen(name), FIBER_NAME_MAX);
> + char *new_name = realloc(fiber->name, len + 1);
I don't like it completely. The fiber cache has been made
not just to eliminate new memory allocation but also to
reduce memory fragmentation and now we give a user a hand
to shuffle memory in easy path :(
If 32 bytes is really not enough lest make it 64 (or 128)
and allocate together with fiber cache.
> + if (new_name == NULL)
> + panic("fiber_set_name() can't fail");
> + fiber->name = new_name;
> + memcpy(new_name, name, len);
> + new_name[len] = 0;
next prev parent reply other threads:[~2020-03-14 16:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-14 15:16 Vladislav Shpilevoy
2020-03-14 16:34 ` Cyrill Gorcunov [this message]
2020-03-14 17:25 ` Vladislav Shpilevoy
2020-03-14 17:32 ` Vladislav Shpilevoy
2020-03-14 19:48 ` Cyrill Gorcunov
2020-03-15 15:13 ` Vladislav Shpilevoy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200314163432.GW27301@uranus \
--to=gorcunov@gmail.com \
--cc=tarantool-patches@dev.tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 1/1] fiber: extend max fiber name length to 255' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox