Hi Sergey,
Sergey Vojtovich, 25.03.2008 09:48:
...
> ChangeSet@stripped, 2008-03-25 12:47:57+04:00, svoj@stripped +2 -0
> BUG#35509 - Federated leaks memory when connecting to
> localhost/default port
>
> When creating federated table that points to unspecified host or
> localhost on unspecified port or port is 0, small memory leak occurs.
>
> This happens because we make a copy of unix socket path, which is
> never freed.
>
> With this fix we do not make a copy of unix socket path, instead
> share->socket points to MYSQL_UNIX_ADDR constant directly.
>
> This fix is covered by a test case for BUG34788.
>
> Affects 5.0 only.
>
...
> +++ b/sql/ha_federated.cc 2008-03-25 12:47:55 +04:00
> @@ -656,7 +656,7 @@ static int parse_url(FEDERATED_SHARE *sh
...
> - share->socket= my_strdup(MYSQL_UNIX_ADDR, MYF(0));
> + share->socket= (char*) MYSQL_UNIX_ADDR;
...
> @@ -1342,7 +1342,6 @@ static int free_share(FEDERATED_SHARE *s
...
> - my_free((gptr) share->socket, MYF(MY_ALLOW_ZERO_PTR));
Hu? Here it is freed. So what was the problem?
Ramil said that parse_url() was called twice.
So an alternative would be:
In parse_url():
if (share->socket)
my_free((gptr) share->socket, MYF(0));
share->socket= my_strdup(MYSQL_UNIX_ADDR, MYF(0));
In the current implementation it is ok to use MYSQL_UNIX_ADDR directly
as you do. However if the connection string syntax would allow to
specify an alternative socket one day, it would break.
OTOH you write that the fix is for 5.0 only. We won't change the URL
syntax in 5.0 any more.
So OK to push from me.
Regards
Ingo
--
Ingo Strüwing, Senior Software Developer
MySQL GmbH, Dachauer Str. 37, D-80335 München
Geschäftsführer: Kaj Arnö - HRB München 162140