mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
Allow specifying a port number for the MySQL server.
This patch allows you to specify a port number for the MySQL server. It's useful if a MySQL server is running on a non-standard port. Even though this module is deprecated in favor of func_odbc, someone asked for this feature and it seems pretty harmless to add. It has been tested using a number of combinations of with/without a port number specified in the dialplan and changing the port number for mysqld. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370534 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
5
CHANGES
5
CHANGES
@@ -110,6 +110,11 @@ MixMonitor
|
|||||||
* Added 'm' option, which stores a copy of the recording as a voicemail in the
|
* Added 'm' option, which stores a copy of the recording as a voicemail in the
|
||||||
indicated mailboxes.
|
indicated mailboxes.
|
||||||
|
|
||||||
|
MySQL
|
||||||
|
-------------------
|
||||||
|
* The connect action in app_mysql now allows you to specify a port number to
|
||||||
|
connect to. This is useful if you run a MySQL server on a non-standard
|
||||||
|
port number.
|
||||||
|
|
||||||
OSP Applications
|
OSP Applications
|
||||||
-------------------
|
-------------------
|
||||||
|
@@ -59,7 +59,7 @@ static const char descrip[] =
|
|||||||
"Syntax:\n"
|
"Syntax:\n"
|
||||||
" MYSQL(Set timeout <num>)\n"
|
" MYSQL(Set timeout <num>)\n"
|
||||||
" Set the connection timeout, in seconds.\n"
|
" Set the connection timeout, in seconds.\n"
|
||||||
" MYSQL(Connect connid dhhost dbuser dbpass dbname [dbcharset])\n"
|
" MYSQL(Connect connid dhhost[:dbport] dbuser dbpass dbname [dbcharset])\n"
|
||||||
" Connects to a database. Arguments contain standard MySQL parameters\n"
|
" Connects to a database. Arguments contain standard MySQL parameters\n"
|
||||||
" passed to function mysql_real_connect. Optional parameter dbcharset\n"
|
" passed to function mysql_real_connect. Optional parameter dbcharset\n"
|
||||||
" defaults to 'latin1'. Connection identifer returned in ${connid}\n"
|
" defaults to 'latin1'. Connection identifer returned in ${connid}\n"
|
||||||
@@ -322,6 +322,8 @@ static int aMYSQL_connect(struct ast_channel *chan, char *data)
|
|||||||
MYSQL *mysql;
|
MYSQL *mysql;
|
||||||
int timeout;
|
int timeout;
|
||||||
const char *ctimeout;
|
const char *ctimeout;
|
||||||
|
unsigned int port = 0;
|
||||||
|
char *port_str;
|
||||||
|
|
||||||
AST_NONSTANDARD_APP_ARGS(args, data, ' ');
|
AST_NONSTANDARD_APP_ARGS(args, data, ' ');
|
||||||
|
|
||||||
@@ -348,7 +350,15 @@ static int aMYSQL_connect(struct ast_channel *chan, char *data)
|
|||||||
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, args.dbcharset);
|
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, args.dbcharset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! mysql_real_connect(mysql, args.dbhost, args.dbuser, args.dbpass, args.dbname, 0, NULL,
|
if ((port_str = strchr(args.dbhost, ':'))) {
|
||||||
|
*port_str++ = '\0';
|
||||||
|
if (sscanf(port_str, "%u", &port) != 1) {
|
||||||
|
ast_log(LOG_WARNING, "Invalid port: '%s'\n", port_str);
|
||||||
|
port = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mysql_real_connect(mysql, args.dbhost, args.dbuser, args.dbpass, args.dbname, port, NULL,
|
||||||
#ifdef CLIENT_MULTI_STATEMENTS
|
#ifdef CLIENT_MULTI_STATEMENTS
|
||||||
CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS
|
CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS
|
||||||
#elif defined(CLIENT_MULTI_QUERIES)
|
#elif defined(CLIENT_MULTI_QUERIES)
|
||||||
|
Reference in New Issue
Block a user