From 1d3b89b10bfd825e4ca73bb95b0ae489843dd9f1 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Fri, 30 Jan 2015 07:54:52 +0100 Subject: [PATCH] db_mysql: restore group ending character in db url - ] was set to \0 to use it for mysql options, but it will break matching the db url for connection pooling - reported by Juha Heinanen --- modules/db_mysql/km_my_con.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/db_mysql/km_my_con.c b/modules/db_mysql/km_my_con.c index d0338a48da1..deadd76976c 100644 --- a/modules/db_mysql/km_my_con.c +++ b/modules/db_mysql/km_my_con.c @@ -43,7 +43,7 @@ struct my_con* db_mysql_new_connection(const struct db_id* id) { struct my_con* ptr; - char *host, *grp; + char *host, *grp, *egrp; unsigned int connection_flag = 0; if (!id) { @@ -57,6 +57,7 @@ struct my_con* db_mysql_new_connection(const struct db_id* id) return 0; } + egrp = 0; memset(ptr, 0, sizeof(struct my_con)); ptr->ref = 1; @@ -68,9 +69,10 @@ struct my_con* db_mysql_new_connection(const struct db_id* id) mysql_init(ptr->con); - if (id->host[0] == '[' && (host = strchr(id->host, ']')) != NULL) { + if (id->host[0] == '[' && (egrp = strchr(id->host, ']')) != NULL) { grp = id->host + 1; - *host = '\0'; + *egrp = '\0'; + host = egrp; if (host != id->host + strlen(id->host)-1) { host += 1; // host found after closing bracket } @@ -129,11 +131,13 @@ struct my_con* db_mysql_new_connection(const struct db_id* id) ptr->timestamp = time(0); ptr->id = (struct db_id*)id; + if(egrp) *egrp = ']'; return ptr; err: if (ptr && ptr->con) pkg_free(ptr->con); if (ptr) pkg_free(ptr); + if(egrp) *egrp = ']'; return 0; }