[asterisk-commits] dvossel: branch dvossel/gtalk_fixup r290972 - in /team/dvossel/gtalk_fixup: ....
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Oct 8 15:39:04 CDT 2010
Author: dvossel
Date: Fri Oct 8 15:39:01 2010
New Revision: 290972
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=290972
Log:
svnmerge merge update
Modified:
team/dvossel/gtalk_fixup/ (props changed)
team/dvossel/gtalk_fixup/addons/app_mysql.c
team/dvossel/gtalk_fixup/addons/res_config_mysql.c
team/dvossel/gtalk_fixup/channels/chan_gtalk.c
team/dvossel/gtalk_fixup/configs/res_config_mysql.conf.sample
team/dvossel/gtalk_fixup/main/asterisk.c
Propchange: team/dvossel/gtalk_fixup/
------------------------------------------------------------------------------
Binary property 'branch-1.6.2-merged' - no diff available.
Propchange: team/dvossel/gtalk_fixup/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Oct 8 15:39:01 2010
@@ -1,1 +1,1 @@
-/branches/1.8:1-290820
+/branches/1.8:1-290971
Modified: team/dvossel/gtalk_fixup/addons/app_mysql.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/gtalk_fixup/addons/app_mysql.c?view=diff&rev=290972&r1=290971&r2=290972
==============================================================================
--- team/dvossel/gtalk_fixup/addons/app_mysql.c (original)
+++ team/dvossel/gtalk_fixup/addons/app_mysql.c Fri Oct 8 15:39:01 2010
@@ -57,10 +57,10 @@
"Syntax:\n"
" MYSQL(Set timeout <num>)\n"
" Set the connection timeout, in seconds.\n"
-" MYSQL(Connect connid dhhost dbuser dbpass dbname)\n"
+" MYSQL(Connect connid dhhost dbuser dbpass dbname [dbcharset])\n"
" Connects to a database. Arguments contain standard MySQL parameters\n"
-" passed to function mysql_real_connect. Connection identifer returned\n"
-" in ${connid}\n"
+" passed to function mysql_real_connect. Optional parameter dbcharset\n"
+" defaults to 'latin1'. Connection identifer returned in ${connid}\n"
" MYSQL(Query resultid ${connid} query-string)\n"
" Executes standard MySQL query contained in query-string using established\n"
" connection identified by ${connid}. Result of query is stored in ${resultid}.\n"
@@ -80,7 +80,7 @@
/*
EXAMPLES OF USE :
-exten => s,2,MYSQL(Connect connid localhost asterisk mypass credit)
+exten => s,2,MYSQL(Connect connid localhost asterisk mypass credit utf8)
exten => s,3,MYSQL(Query resultid ${connid} SELECT username,credit FROM credit WHERE callerid=${CALLERIDNUM})
exten => s,4,MYSQL(Fetch fetchid ${resultid} datavar1 datavar2)
exten => s,5,GotoIf(${fetchid}?6:8)
@@ -315,6 +315,7 @@
AST_APP_ARG(dbuser);
AST_APP_ARG(dbpass);
AST_APP_ARG(dbname);
+ AST_APP_ARG(dbcharset);
);
MYSQL *mysql;
int timeout;
@@ -322,7 +323,7 @@
AST_NONSTANDARD_APP_ARGS(args, data, ' ');
- if (args.argc != 6) {
+ if (args.argc < 6) {
ast_log(LOG_WARNING, "MYSQL_connect is missing some arguments\n");
return -1;
}
@@ -335,6 +336,14 @@
ctimeout = pbx_builtin_getvar_helper(chan, "MYSQL_TIMEOUT");
if (ctimeout && sscanf(ctimeout, "%30d", &timeout) == 1) {
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (void *)&timeout);
+ }
+ if(args.dbcharset && strlen(args.dbcharset) > 2){
+ char set_names[255];
+ char statement[512];
+ snprintf(set_names, sizeof(set_names), "SET NAMES %s", args.dbcharset);
+ mysql_real_escape_string(mysql, statement, set_names, sizeof(set_names));
+ mysql_options(mysql, MYSQL_INIT_COMMAND, set_names);
+ mysql_options(mysql, MYSQL_SET_CHARSET_NAME, args.dbcharset);
}
if (! mysql_real_connect(mysql, args.dbhost, args.dbuser, args.dbpass, args.dbname, 0, NULL,
Modified: team/dvossel/gtalk_fixup/addons/res_config_mysql.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/gtalk_fixup/addons/res_config_mysql.c?view=diff&rev=290972&r1=290971&r2=290972
==============================================================================
--- team/dvossel/gtalk_fixup/addons/res_config_mysql.c (original)
+++ team/dvossel/gtalk_fixup/addons/res_config_mysql.c Fri Oct 8 15:39:01 2010
@@ -91,6 +91,7 @@
char user[50];
char pass[50];
char sock[50];
+ char charset[50];
int port;
int connected;
time_t connect_time;
@@ -1527,6 +1528,10 @@
} else
ast_copy_string(conn->sock, s, sizeof(conn->sock));
+ if ((s = ast_variable_retrieve(config, category, "dbcharset"))) {
+ ast_copy_string(conn->charset, s, sizeof(conn->charset));
+ }
+
if (!(s = ast_variable_retrieve(config, category, "requirements"))) {
ast_log(LOG_WARNING, "MySQL realtime: no requirements setting found, using 'warn' as default.\n");
conn->requirements = RQ_WARN;
@@ -1549,6 +1554,8 @@
ast_debug(1, "MySQL RealTime database name: %s\n", conn->name);
ast_debug(1, "MySQL RealTime user: %s\n", conn->user);
ast_debug(1, "MySQL RealTime password: %s\n", conn->pass);
+ if(conn->charset)
+ ast_debug(1, "MySQL RealTime charset: %s\n", conn->charset);
return 1;
}
@@ -1568,6 +1575,15 @@
conn->connected = 0;
return 0;
}
+ if(conn->charset && strlen(conn->charset) > 2){
+ char set_names[255];
+ char statement[512];
+ snprintf(set_names, sizeof(set_names), "SET NAMES %s", conn->charset);
+ mysql_real_escape_string(&conn->handle, statement, set_names, sizeof(set_names));
+ mysql_options(&conn->handle, MYSQL_INIT_COMMAND, set_names);
+ mysql_options(&conn->handle, MYSQL_SET_CHARSET_NAME, conn->charset);
+ }
+
if (mysql_real_connect(&conn->handle, conn->host, conn->user, conn->pass, conn->name, conn->port, conn->sock, 0)) {
#ifdef MYSQL_OPT_RECONNECT
/* The default is no longer to automatically reconnect on failure,
Modified: team/dvossel/gtalk_fixup/channels/chan_gtalk.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/gtalk_fixup/channels/chan_gtalk.c?view=diff&rev=290972&r1=290971&r2=290972
==============================================================================
--- team/dvossel/gtalk_fixup/channels/chan_gtalk.c (original)
+++ team/dvossel/gtalk_fixup/channels/chan_gtalk.c Fri Oct 8 15:39:01 2010
@@ -4,6 +4,7 @@
* Copyright (C) 1999 - 2005, Digium, Inc.
*
* Matt O'Gorman <mogorman at digium.com>
+ * Philippe Sultan <philippe.sultan at gmail.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
@@ -19,6 +20,7 @@
/*! \file
*
* \author Matt O'Gorman <mogorman at digium.com>
+ * \author Philippe Sultan <philippe.sultan at gmail.com>
*
* \brief Gtalk Channel Driver, until google/libjingle works with jingle spec
*
Modified: team/dvossel/gtalk_fixup/configs/res_config_mysql.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/gtalk_fixup/configs/res_config_mysql.conf.sample?view=diff&rev=290972&r1=290971&r2=290972
==============================================================================
--- team/dvossel/gtalk_fixup/configs/res_config_mysql.conf.sample (original)
+++ team/dvossel/gtalk_fixup/configs/res_config_mysql.conf.sample Fri Oct 8 15:39:01 2010
@@ -4,7 +4,9 @@
; The value of dbhost may be either a hostname or an IP address.
; If dbhost is commented out or the string "localhost", a connection
; to the local host is assumed and dbsock is used instead of TCP/IP
-; to connect to the server.
+; to connect to the server. If no dbcharset is specified, the connection
+; is made with no extra charset configurations sent to MySQL, leaving all
+; configured MySQL charset options and defaults untouched.
;
; Multiple database contexts may be configured, with the caveat that
; all context names should be unique and must not contain the slash ('/')
@@ -37,4 +39,5 @@
;dbpass = mypass
;dbport = 3306
;dbsock = /tmp/mysql.sock
+;dbcharset = latin1
;requirements=warn ; or createclose or createchar
Modified: team/dvossel/gtalk_fixup/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/gtalk_fixup/main/asterisk.c?view=diff&rev=290972&r1=290971&r2=290972
==============================================================================
--- team/dvossel/gtalk_fixup/main/asterisk.c (original)
+++ team/dvossel/gtalk_fixup/main/asterisk.c Fri Oct 8 15:39:01 2010
@@ -278,6 +278,7 @@
static int shuttingdown;
static int restartnow;
static pthread_t consolethread = AST_PTHREADT_NULL;
+static pthread_t mon_sig_flags;
static int canary_pid = 0;
static char canary_filename[128];
@@ -1637,14 +1638,15 @@
ast_module_shutdown();
}
if (ast_opt_console || (ast_opt_remote && !ast_opt_exec)) {
+ pthread_t thisthread = pthread_self();
if (getenv("HOME")) {
snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME"));
}
if (!ast_strlen_zero(filename)) {
ast_el_write_history(filename);
}
- if (consolethread == AST_PTHREADT_NULL || consolethread == pthread_self()) {
- /* Only end if we are the consolethread, otherwise there's a race with that thread. */
+ if (consolethread == AST_PTHREADT_NULL || consolethread == thisthread || mon_sig_flags == thisthread) {
+ /* Only end if we are the consolethread or signal handler, otherwise there's a race with that thread. */
if (el != NULL) {
el_end(el);
}
@@ -3835,9 +3837,8 @@
/* Console stuff now... */
/* Register our quit function */
char title[256];
- pthread_t dont_care;
-
- ast_pthread_create_detached(&dont_care, NULL, monitor_sig_flags, NULL);
+
+ ast_pthread_create_detached(&mon_sig_flags, NULL, monitor_sig_flags, NULL);
set_icon("Asterisk");
snprintf(title, sizeof(title), "Asterisk Console on '%s' (pid %ld)", hostname, (long)ast_mainpid);
More information about the asterisk-commits
mailing list