[sr-dev] git:master:1d3b89b1: db_mysql: restore group ending character in db url

Daniel-Constantin Mierla miconda at gmail.com
Fri Jan 30 10:31:19 CET 2015


Module: kamailio
Branch: master
Commit: 1d3b89b10bfd825e4ca73bb95b0ae489843dd9f1
URL: https://github.com/kamailio/kamailio/commit/1d3b89b10bfd825e4ca73bb95b0ae489843dd9f1

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-01-30T10:30:16+01:00

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

---

Modified: modules/db_mysql/km_my_con.c

---

Diff:  https://github.com/kamailio/kamailio/commit/1d3b89b10bfd825e4ca73bb95b0ae489843dd9f1.diff
Patch: https://github.com/kamailio/kamailio/commit/1d3b89b10bfd825e4ca73bb95b0ae489843dd9f1.patch

---

diff --git a/modules/db_mysql/km_my_con.c b/modules/db_mysql/km_my_con.c
index d0338a4..deadd76 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;
 }
 




More information about the sr-dev mailing list