diff mbox

[PATCHv2,2/2] Initialize tunable list with the GLIBC_TUNABLES environment variable

Message ID 20160119135006.GN3334@devel.intra.reserved-bit.com
State New
Headers show

Commit Message

Siddhesh Poyarekar Jan. 19, 2016, 1:50 p.m. UTC
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 mbox

Patch

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;