This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCHv2 2/2] Initialize tunable list with the GLIBC_TUNABLES environment variable
- From: Siddhesh Poyarekar <sid at reserved-bit dot com>
- To: "Paul E. Murphy" <murphyp at linux dot vnet dot ibm dot com>
- Cc: libc-alpha at sourceware dot org, roland at hack dot frob dot com, carlos at redhat dot com, Andi Kleen <andi at firstfloor dot org>, tuliom at linux dot vnet dot ibm dot com, munroesj at linux dot vnet dot ibm dot com
- Date: Tue, 19 Jan 2016 19:20:06 +0530
- Subject: Re: [PATCHv2 2/2] Initialize tunable list with the GLIBC_TUNABLES environment variable
- Authentication-results: sourceware.org; auth=none
- References: <20160116185617 dot GA17783 at devel dot intra dot reserved-bit dot com> <569D646A dot 4000100 at linux dot vnet dot ibm dot com>
On Mon, Jan 18, 2016 at 04:17:14PM -0600, Paul E. Murphy wrote:
> While this does work as expected with trivial inputs, it does
> have some quirks:
>
> I.e this will set the desired tunable:
> GLIBC_TUNABLES="glibc.pthread.elision_enable=1"
> GLIBC_TUNABLES="glibc.pthread.elision_enable=1:"
> GLIBC_TUNABLES="foo=:glibc.pthread.elision_enable=1"
>
> But the following does not:
> GLIBC_TUNABLES=":glibc.pthread.elision_enable=1"
> GLIBC_TUNABLES="foo:glibc.pthread.elision_enable=1"
> GLIBC_TUNABLES="val=foo:bar:glibc.pthread.elision_enable=1"
Thanks for testing, this patch on top of 2/2 should fix this.
Siddhesh
diff --git a/tunables/tunables.c b/tunables/tunables.c
index d5090fd..b942c10 100644
--- a/tunables/tunables.c
+++ b/tunables/tunables.c
@@ -157,7 +157,7 @@ __tunables_init (char **envp)
size_t len = 0;
/* First, find where the name ends. */
- while (p[len] != '=' && p[len] != '\0')
+ while (p[len] != '=' && p[len] != ':' && p[len] != '\0')
len++;
/* If we reach the end of the string before getting a valid name-value
@@ -165,6 +165,14 @@ __tunables_init (char **envp)
if (p[len] == '\0')
goto out;
+ /* We did not find a valid name-value pair before encountering the
+ colon. */
+ if (p[len]== ':')
+ {
+ p += len + 1;
+ continue;
+ }
+
p[len] = '\0';
p += len + 1;