[asterisk-commits] rmudgett: branch rmudgett/misdn_facility r158187 - in /team/rmudgett/misdn_fa...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Nov 20 13:18:58 CST 2008


Author: rmudgett
Date: Thu Nov 20 13:18:57 2008
New Revision: 158187

URL: http://svn.digium.com/view/asterisk?view=rev&rev=158187
Log:
Merged revisions 158081,158142 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/team/group/issue8824

................
  r158081 | root | 2008-11-20 11:54:29 -0600 (Thu, 20 Nov 2008) | 54 lines
  
  Merged revisions 158061-158062,158066,158070,158072,158078 via svnmerge from 
  file:///srv/subversion/repos/asterisk/trunk
  
  ................
  r158061 | qwell | 2008-11-20 11:37:05 -0600 (Thu, 20 Nov 2008) | 1 line
  
  Whitespace fix
  ................
  r158062 | jpeeler | 2008-11-20 11:37:31 -0600 (Thu, 20 Nov 2008) | 6 lines
  
  (closes issue #12929)
  Reported by: snyfer
  
  This handles the case for a zero length file to attempt to be streamed. Instead of failing from not playing any data, go ahead and return success as ast_streamfile should consider playing nothing a success when there is nothing to play.
  
  
  ................
  r158066 | mmichelson | 2008-11-20 11:39:06 -0600 (Thu, 20 Nov 2008) | 20 lines
  
  Merged revisions 158053 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
  r158053 | mmichelson | 2008-11-20 11:33:06 -0600 (Thu, 20 Nov 2008) | 12 lines
  
  Make sure to set the hangup cause on the calling channel in the case
  that ast_call() fails. For incoming SIP channels, this was causing
  us to send a 603 instead of a 486 when the call-limit was reached on
  the destination channel.
  
  (closes issue #13867)
  Reported by: still_nsk
  Patches:
        13867.diff uploaded by putnopvut (license 60)
  Tested by: blitzrage
  
  
  ........
  
  ................
  r158070 | rbrindley | 2008-11-20 11:46:56 -0600 (Thu, 20 Nov 2008) | 1 line
  
  formatting changes :: one line for loops and if statements should have {}
  ................
  r158072 | twilson | 2008-11-20 11:48:58 -0600 (Thu, 20 Nov 2008) | 2 lines
  
  Begin on a crusade to end trailing whitespace!
  
  ................
  r158078 | rbrindley | 2008-11-20 11:53:42 -0600 (Thu, 20 Nov 2008) | 1 line
  
  more formatting corrections :: one line for loops and if statements still need {}
  ................
................
  r158142 | root | 2008-11-20 12:54:56 -0600 (Thu, 20 Nov 2008) | 45 lines
  
  Merged revisions 158082,158133 via svnmerge from 
  file:///srv/subversion/repos/asterisk/trunk
  
  ................
  r158082 | mmichelson | 2008-11-20 11:54:31 -0600 (Thu, 20 Nov 2008) | 24 lines
  
  Merged revisions 158071 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
  r158071 | mmichelson | 2008-11-20 11:48:42 -0600 (Thu, 20 Nov 2008) | 16 lines
  
  We don't handle 4XX responses to BYE well. According to
  section 15 of RFC 3261, we should terminate a dialog if we
  receive a 481 or 408 in response to our BYE. Since I am aware
  of at least one phone manufacturer who may sometimes send a 
  404 as well, I am being liberal and saying that any 4XX response
  to a BYE should result in a terminated dialog.
  
  
  (closes issue #12994)
  Reported by: pabelanger
  Patches:
        12994.patch uploaded by putnopvut (license 60)
  
  Closes AST-129
  
  
  ........
  
  ................
  r158133 | mmichelson | 2008-11-20 12:20:00 -0600 (Thu, 20 Nov 2008) | 10 lines
  
  Merged revisions 158072 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/trunk
  
  ........
  r158072 | twilson | 2008-11-20 11:48:58 -0600 (Thu, 20 Nov 2008) | 2 lines
  
  Begin on a crusade to end trailing whitespace!
  
  ........
  
  ................
................

Modified:
    team/rmudgett/misdn_facility/   (props changed)
    team/rmudgett/misdn_facility/README
    team/rmudgett/misdn_facility/apps/app_dial.c
    team/rmudgett/misdn_facility/cdr/Makefile
    team/rmudgett/misdn_facility/cdr/cdr_adaptive_odbc.c
    team/rmudgett/misdn_facility/cdr/cdr_csv.c
    team/rmudgett/misdn_facility/cdr/cdr_custom.c
    team/rmudgett/misdn_facility/cdr/cdr_manager.c
    team/rmudgett/misdn_facility/cdr/cdr_odbc.c
    team/rmudgett/misdn_facility/cdr/cdr_pgsql.c
    team/rmudgett/misdn_facility/cdr/cdr_radius.c
    team/rmudgett/misdn_facility/cdr/cdr_sqlite.c
    team/rmudgett/misdn_facility/cdr/cdr_sqlite3_custom.c
    team/rmudgett/misdn_facility/channels/chan_sip.c
    team/rmudgett/misdn_facility/include/asterisk/file.h
    team/rmudgett/misdn_facility/include/asterisk/frame.h
    team/rmudgett/misdn_facility/main/config.c
    team/rmudgett/misdn_facility/main/file.c
    team/rmudgett/misdn_facility/main/frame.c

Propchange: team/rmudgett/misdn_facility/
------------------------------------------------------------------------------
--- misdn-facility (original)
+++ misdn-facility Thu Nov 20 13:18:57 2008
@@ -1,1 +1,1 @@
-/team/group/issue8824:1-158034
+/team/group/issue8824:1-158186

Propchange: team/rmudgett/misdn_facility/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Nov 20 13:18:57 2008
@@ -1,1 +1,1 @@
-/trunk:1-157983
+/trunk:1-158141

Modified: team/rmudgett/misdn_facility/README
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/README?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/README (original)
+++ team/rmudgett/misdn_facility/README Thu Nov 20 13:18:57 2008
@@ -276,7 +276,7 @@
   If this release of Asterisk was downloaded from a tarball, then some
 additional documentation should have been included.
      * doc/tex/asterisk.pdf --- PDF version of the documentation
-	 * doc/tex/asterisk/index.html --- HTML version of the documentation
+     * doc/tex/asterisk/index.html --- HTML version of the documentation
 
   Finally, you may wish to visit the web site and join the mailing list if
 you're interested in getting more information.

Modified: team/rmudgett/misdn_facility/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/apps/app_dial.c?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/apps/app_dial.c (original)
+++ team/rmudgett/misdn_facility/apps/app_dial.c Thu Nov 20 13:18:57 2008
@@ -1887,6 +1887,9 @@
 			/* Again, keep going even if there's an error */
 			ast_debug(1, "ast call on peer returned %d\n", res);
 			ast_verb(3, "Couldn't call %s\n", numsubst);
+			if (tc->hangupcause) {
+				chan->hangupcause = tc->hangupcause;
+			}
 			ast_hangup(tc);
 			tc = NULL;
 			ast_free(tmp);

Modified: team/rmudgett/misdn_facility/cdr/Makefile
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/cdr/Makefile?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/cdr/Makefile (original)
+++ team/rmudgett/misdn_facility/cdr/Makefile Thu Nov 20 13:18:57 2008
@@ -1,6 +1,6 @@
 #
 # Asterisk -- A telephony toolkit for Linux.
-# 
+#
 # Makefile for CDR backends
 #
 # Copyright (C) 1999-2006, Digium, Inc.

Modified: team/rmudgett/misdn_facility/cdr/cdr_adaptive_odbc.c
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/cdr/cdr_adaptive_odbc.c?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/cdr/cdr_adaptive_odbc.c (original)
+++ team/rmudgett/misdn_facility/cdr/cdr_adaptive_odbc.c Thu Nov 20 13:18:57 2008
@@ -19,7 +19,7 @@
 /*! \file
  *
  * \brief Adaptive ODBC CDR backend
- * 
+ *
  * \author Tilghman Lesher <cdr_adaptive_odbc__v1 at the-tilghman.com>
  * \ingroup cdr_drivers
  */

Modified: team/rmudgett/misdn_facility/cdr/cdr_csv.c
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/cdr/cdr_csv.c?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/cdr/cdr_csv.c (original)
+++ team/rmudgett/misdn_facility/cdr/cdr_csv.c Thu Nov 20 13:18:57 2008
@@ -23,7 +23,7 @@
  * \brief Comma Separated Value CDR records.
  *
  * \author Mark Spencer <markster at digium.com>
- * 
+ *
  * \arg See also \ref AstCDR
  * \ingroup cdr_drivers
  */
@@ -62,26 +62,26 @@
 
   "accountcode", 	accountcode is the account name of detail records, Master.csv contains all records *
   			Detail records are configured on a channel basis, IAX and SIP are determined by user *
-			DAHDI is determined by channel in dahdi.conf 
+			DAHDI is determined by channel in dahdi.conf
   "source",
   "destination",
-  "destination context", 
+  "destination context",
   "callerid",
   "channel",
   "destination channel",	(if applicable)
-  "last application",	Last application run on the channel 
-  "last app argument",	argument to the last channel 
-  "start time", 
-  "answer time", 
-  "end time", 
-  duration,   		Duration is the whole length that the entire call lasted. ie. call rx'd to hangup  
-  			"end time" minus "start time" 
-  billable seconds, 	the duration that a call was up after other end answered which will be <= to duration  
-  			"end time" minus "answer time" 
-  "disposition",    	ANSWERED, NO ANSWER, BUSY 
-  "amaflags",       	DOCUMENTATION, BILL, IGNORE etc, specified on a per channel basis like accountcode. 
-  "uniqueid",           unique call identifier 
-  "userfield"		user field set via SetCDRUserField 
+  "last application",	Last application run on the channel
+  "last app argument",	argument to the last channel
+  "start time",
+  "answer time",
+  "end time",
+  duration,   		Duration is the whole length that the entire call lasted. ie. call rx'd to hangup
+  			"end time" minus "start time"
+  billable seconds, 	the duration that a call was up after other end answered which will be <= to duration
+  			"end time" minus "answer time"
+  "disposition",    	ANSWERED, NO ANSWER, BUSY
+  "amaflags",       	DOCUMENTATION, BILL, IGNORE etc, specified on a per channel basis like accountcode.
+  "uniqueid",           unique call identifier
+  "userfield"		user field set via SetCDRUserField
 ----------------------------------------------------------*/
 
 static char *name = "csv";
@@ -110,7 +110,7 @@
 		ast_config_destroy(cfg);
 		return 0;
 	}
-	
+
 	if ((tmp = ast_variable_retrieve(cfg, "csv", "usegmtime"))) {
 		usegmtime = ast_true(tmp);
 		if (usegmtime)
@@ -238,7 +238,7 @@
 		append_string(buf, cdr->uniqueid, bufsize);
 	/* append the user field */
 	if(loguserfield)
-		append_string(buf, cdr->userfield,bufsize);	
+		append_string(buf, cdr->userfield,bufsize);
 	/* If we hit the end of our buffer, log an error */
 	if (strlen(buf) < bufsize - 5) {
 		/* Trim off trailing comma */
@@ -290,7 +290,7 @@
 		ast_log(LOG_WARNING, "Unable to create CSV record in %d bytes.  CDR not recorded!\n", (int)sizeof(buf));
 		return 0;
 	}
-	
+
 	/* because of the absolutely unconditional need for the
 	   highest reliability possible in writing billing records,
 	   we open write and close the log file each time */
@@ -305,7 +305,7 @@
 		ast_mutex_unlock(&mf_lock);
 		ast_log(LOG_ERROR, "Unable to re-open master file %s : %s\n", csvmaster, strerror(errno));
 	}
-	
+
 	if (!ast_strlen_zero(cdr->accountcode)) {
 		if (writefile(buf, cdr->accountcode))
 			ast_log(LOG_WARNING, "Unable to write CSV record to account file '%s' : %s\n", cdr->accountcode, strerror(errno));
@@ -324,7 +324,7 @@
 static int load_module(void)
 {
 	int res;
-	
+
 	if(!load_config(0))
 		return AST_MODULE_LOAD_DECLINE;
 

Modified: team/rmudgett/misdn_facility/cdr/cdr_custom.c
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/cdr/cdr_custom.c?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/cdr/cdr_custom.c (original)
+++ team/rmudgett/misdn_facility/cdr/cdr_custom.c Thu Nov 20 13:18:57 2008
@@ -57,7 +57,7 @@
 static char master[PATH_MAX];
 static char format[1024]="";
 
-static int load_config(int reload) 
+static int load_config(int reload)
 {
 	struct ast_config *cfg;
 	struct ast_variable *var;
@@ -85,7 +85,7 @@
 				strcat(format,"\n");
 				snprintf(master, sizeof(master),"%s/%s/%s", ast_config_AST_LOG_DIR, name, var->name);
 				if (var->next) {
-					ast_log(LOG_NOTICE, "Sorry, only one mapping is supported at this time, mapping '%s' will be ignored at line %d.\n", var->next->name, var->next->lineno); 
+					ast_log(LOG_NOTICE, "Sorry, only one mapping is supported at this time, mapping '%s' will be ignored at line %d.\n", var->next->name, var->next->lineno);
 					break;
 				}
 			} else
@@ -101,7 +101,7 @@
 			ast_log(LOG_WARNING, "Failed to load configuration file. Module not activated.\n");
 	}
 	ast_mutex_unlock(&lock);
-	
+
 	return res;
 }
 
@@ -158,7 +158,7 @@
 		if (res)
 			ast_log(LOG_ERROR, "Unable to register custom CDR handling\n");
 		return res;
-	} else 
+	} else
 		return AST_MODULE_LOAD_DECLINE;
 }
 

Modified: team/rmudgett/misdn_facility/cdr/cdr_manager.c
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/cdr/cdr_manager.c?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/cdr/cdr_manager.c (original)
+++ team/rmudgett/misdn_facility/cdr/cdr_manager.c Thu Nov 20 13:18:57 2008
@@ -17,7 +17,7 @@
 /*! \file
  *
  * \brief Asterisk Call Manager CDR records.
- * 
+ *
  * See also
  * \arg \ref AstCDR
  * \arg \ref AstAMI
@@ -80,14 +80,14 @@
 		enablecdr = 0;
 		return 0;
 	}
-	
+
 	while ( (cat = ast_category_browse(cfg, cat)) ) {
 		if (!strcasecmp(cat, "general")) {
 			v = ast_variable_browse(cfg, cat);
 			while (v) {
 				if (!strcasecmp(v->name, "enabled"))
 					newenablecdr = ast_true(v->value);
-				
+
 				v = v->next;
 			}
 		} else if (!strcasecmp(cat, "mappings")) {
@@ -102,13 +102,13 @@
 						ast_log(LOG_WARNING, "No more buffer space to add other custom fields\n");
 						break;
 					}
-					
+
 				}
 				v = v->next;
 			}
 		}
 	}
-	
+
 	ast_config_destroy(cfg);
 
 	if (enablecdr && !newenablecdr)
@@ -134,7 +134,7 @@
 
 	ast_localtime(&cdr->start, &timeresult, NULL);
 	ast_strftime(strStartTime, sizeof(strStartTime), DATE_FORMAT, &timeresult);
-	
+
 	if (cdr->answer.tv_sec)	{
 		ast_localtime(&cdr->answer, &timeresult, NULL);
 		ast_strftime(strAnswerTime, sizeof(strAnswerTime), DATE_FORMAT, &timeresult);

Modified: team/rmudgett/misdn_facility/cdr/cdr_odbc.c
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/cdr/cdr_odbc.c?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/cdr/cdr_odbc.c (original)
+++ team/rmudgett/misdn_facility/cdr/cdr_odbc.c Thu Nov 20 13:18:57 2008
@@ -19,7 +19,7 @@
 /*! \file
  *
  * \brief ODBC CDR Backend
- * 
+ *
  * \author Brian K. West <brian at bkw.org>
  *
  * See also:
@@ -115,7 +115,7 @@
 	}
 
 	ODBC_res = SQLExecDirect(stmt, (unsigned char *)sqlcmd, SQL_NTS);
-	
+
 	if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) {
 		ast_verb(11, "cdr_odbc: Error in ExecDirect: %d\n", ODBC_res);
 		SQLFreeHandle(SQL_HANDLE_STMT, stmt);
@@ -167,7 +167,7 @@
 			break;
 		} else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
 			break;
-	
+
 		var = ast_variable_browse(cfg, "global");
 		if (!var) {
 			/* nothing configured */

Modified: team/rmudgett/misdn_facility/cdr/cdr_pgsql.c
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/cdr/cdr_pgsql.c?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/cdr/cdr_pgsql.c (original)
+++ team/rmudgett/misdn_facility/cdr/cdr_pgsql.c Thu Nov 20 13:18:57 2008
@@ -3,8 +3,8 @@
  *
  * Copyright (C) 2003 - 2006
  *
- * Matthew D. Hardeman <mhardemn at papersoft.com> 
- * Adapted from the MySQL CDR logger originally by James Sharp 
+ * Matthew D. Hardeman <mhardemn at papersoft.com>
+ * Adapted from the MySQL CDR logger originally by James Sharp
  *
  * Modified September 2003
  * Matthew D. Hardeman <mhardemn at papersoft.com>
@@ -22,9 +22,9 @@
 
 /*! \file
  *
- * \brief PostgreSQL CDR logger 
- * 
- * \author Matthew D. Hardeman <mhardemn at papersoft.com> 
+ * \brief PostgreSQL CDR logger
+ *
+ * \author Matthew D. Hardeman <mhardemn at papersoft.com>
  * \extref PostgreSQL http://www.postgresql.org/
  *
  * See also
@@ -125,7 +125,7 @@
 		struct columns *cur;
 		struct ast_str *sql = ast_str_create(maxsize), *sql2 = ast_str_create(maxsize2);
 		char buf[257], escapebuf[513], *value;
-  
+
 		if (!sql || !sql2) {
 			if (sql) {
 				ast_free(sql);
@@ -138,7 +138,7 @@
 
 		ast_str_set(&sql, 0, "INSERT INTO %s (", table);
 		ast_str_set(&sql2, 0, " VALUES (");
-  
+
 		AST_RWLIST_RDLOCK(&psql_columns);
 		AST_RWLIST_TRAVERSE(&psql_columns, cur, list) {
 			/* For fields not set, simply skip them */
@@ -156,7 +156,7 @@
 				}
 				continue;
 			}
-			
+
 			LENGTHEN_BUF1(strlen(cur->name) + 2);
 			ast_str_append(&sql, 0, "\"%s\",", cur->name);
 

Modified: team/rmudgett/misdn_facility/cdr/cdr_radius.c
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/cdr/cdr_radius.c?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/cdr/cdr_radius.c (original)
+++ team/rmudgett/misdn_facility/cdr/cdr_radius.c Thu Nov 20 13:18:57 2008
@@ -21,7 +21,7 @@
  * \brief RADIUS CDR Support
  * \author Philippe Sultan
  * \extref The Radius Client Library - http://developer.berlios.de/projects/radiusclient-ng/
- * 
+ *
  * \arg See also \ref AstCDR
  * \ingroup cdr_drivers
  */
@@ -135,27 +135,27 @@
 
 
 	/* Start Time */
-	ast_strftime(timestr, sizeof(timestr), DATE_FORMAT, 
+	ast_strftime(timestr, sizeof(timestr), DATE_FORMAT,
 		ast_localtime(&cdr->start, &tm,
 			ast_test_flag(&global_flags, RADIUS_FLAG_USEGMTIME) ? "GMT" : NULL));
 	if (!rc_avpair_add(rh, tosend, PW_AST_START_TIME, timestr, strlen(timestr), VENDOR_CODE))
 		return -1;
 
 	/* Answer Time */
-	ast_strftime(timestr, sizeof(timestr), DATE_FORMAT, 
+	ast_strftime(timestr, sizeof(timestr), DATE_FORMAT,
 		ast_localtime(&cdr->answer, &tm,
 			ast_test_flag(&global_flags, RADIUS_FLAG_USEGMTIME) ? "GMT" : NULL));
 	if (!rc_avpair_add(rh, tosend, PW_AST_ANSWER_TIME, timestr, strlen(timestr), VENDOR_CODE))
 		return -1;
 
 	/* End Time */
-	ast_strftime(timestr, sizeof(timestr), DATE_FORMAT, 
+	ast_strftime(timestr, sizeof(timestr), DATE_FORMAT,
 		ast_localtime(&cdr->end, &tm,
 			ast_test_flag(&global_flags, RADIUS_FLAG_USEGMTIME) ? "GMT" : NULL));
 	if (!rc_avpair_add(rh, tosend, PW_AST_END_TIME, timestr, strlen(timestr), VENDOR_CODE))
 		return -1;
 
- 	/* Duration */ 
+ 	/* Duration */
 	if (!rc_avpair_add(rh, tosend, PW_AST_DURATION, &cdr->duration, 0, VENDOR_CODE))
 		return -1;
 
@@ -186,7 +186,7 @@
 	}
 
 	/* Setting Acct-Session-Id & User-Name attributes for proper generation
-	   of Acct-Unique-Session-Id on server side */ 
+	   of Acct-Unique-Session-Id on server side */
 	/* Channel */
 	if (!rc_avpair_add(rh, tosend, PW_USER_NAME, &cdr->channel, strlen(cdr->channel), 0))
 		return -1;
@@ -207,7 +207,7 @@
 		ast_debug(1, "Unable to create RADIUS record. CDR not recorded!\n");
 		return result;
 	}
-	
+
 	result = rc_acct(rh, 0, tosend);
 	if (result != OK_RC)
 		ast_log(LOG_ERROR, "Failed to record Radius CDR record!\n");
@@ -235,9 +235,9 @@
 		if ((tmp = ast_variable_retrieve(cfg, "radius", "radiuscfg")))
 			ast_copy_string(radiuscfg, tmp, sizeof(radiuscfg));
 		ast_config_destroy(cfg);
-	} else 
+	} else
 		return AST_MODULE_LOAD_DECLINE;
-	
+
 	/* start logging */
 	rc_openlog("asterisk");
 
@@ -252,7 +252,7 @@
 		ast_log(LOG_NOTICE, "Cannot load radiusclient-ng dictionary file.\n");
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	
+
 	res = ast_cdr_register(name, desc, radius_log);
 	return AST_MODULE_LOAD_SUCCESS;
 }

Modified: team/rmudgett/misdn_facility/cdr/cdr_sqlite.c
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/cdr/cdr_sqlite.c?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/cdr/cdr_sqlite.c (original)
+++ team/rmudgett/misdn_facility/cdr/cdr_sqlite.c Thu Nov 20 13:18:57 2008
@@ -20,14 +20,14 @@
 /*! \file
  *
  * \brief Store CDR records in a SQLite database.
- * 
+ *
  * \author Holger Schurig <hs4233 at mail.mn-solutions.de>
  * \extref SQLite http://www.sqlite.org/
  *
  * See also
  * \arg \ref Config_cdr
  * \arg http://www.sqlite.org/
- * 
+ *
  * Creates the database and table on-the-fly
  * \ingroup cdr_drivers
  *
@@ -151,7 +151,7 @@
 			break;
 		usleep(200);
 	}
-	
+
 	if (zErr) {
 		ast_log(LOG_ERROR, "cdr_sqlite: %s\n", zErr);
 		ast_free(zErr);
@@ -199,7 +199,7 @@
 
 		/* TODO: here we should probably create an index */
 	}
-	
+
 	res = ast_cdr_register(name, ast_module_info->description, sqlite_log);
 	if (res) {
 		ast_log(LOG_ERROR, "Unable to register SQLite CDR handling\n");

Modified: team/rmudgett/misdn_facility/cdr/cdr_sqlite3_custom.c
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/cdr/cdr_sqlite3_custom.c?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/cdr/cdr_sqlite3_custom.c (original)
+++ team/rmudgett/misdn_facility/cdr/cdr_sqlite3_custom.c Thu Nov 20 13:18:57 2008
@@ -21,10 +21,10 @@
  * \brief Custom SQLite3 CDR records.
  *
  * \author Adapted by Alejandro Rios <alejandro.rios at avatar.com.co> and
- *  Russell Bryant <russell at digium.com> from 
+ *  Russell Bryant <russell at digium.com> from
  *  cdr_mysql_custom by Edward Eastman <ed at dm3.co.uk>,
  *	and cdr_sqlite by Holger Schurig <hs4233 at mail.mn-solutions.de>
- *	
+ *
  *
  * \arg See also \ref AstCDR
  *
@@ -178,7 +178,7 @@
 		ast_config_destroy(cfg);
 		return 0;
 	}
-	
+
 	/* Mapping must have a table name */
 	tmp = ast_variable_retrieve(cfg, "master", "table");
 	if (!ast_strlen_zero(tmp))

Modified: team/rmudgett/misdn_facility/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/channels/chan_sip.c?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/channels/chan_sip.c (original)
+++ team/rmudgett/misdn_facility/channels/chan_sip.c Thu Nov 20 13:18:57 2008
@@ -4925,8 +4925,11 @@
 
 	res = update_call_counter(p, INC_CALL_RINGING);
 
-	if (res == -1)
+	if (res == -1) {
 		return res;
+	} else {
+		ast->hangupcause = AST_CAUSE_USER_BUSY;
+	}
 
 	p->callingpres = ast->cid.cid_pres;
 	p->jointcapability = ast_translate_available_formats(p->capability, p->prefcodec);
@@ -17276,6 +17279,20 @@
 	   Fix assigned to Rizzo :-)
 	*/
 	/* check_via_response(p, req); */
+
+	/* RFC 3261 Section 15 specifies that if we receive a 408 or 481
+	 * in response to a BYE, then we should end the current dialog
+	 * and session. There is no mention in the spec of other 4XX responses,
+	 * but it is known that at least one phone manufacturer potentially
+	 * will send a 404 in response to a BYE, so we'll be liberal in what
+	 * we accept and end the dialog and session if we receive any 4XX 
+	 * response to a BYE.
+	 */
+	if (resp >= 400 && resp < 500 && sipmethod == SIP_BYE) {
+		pvt_set_needdestroy(p, "received 4XX response to a BYE");
+		return;
+	}
+
 	if (p->relatedpeer && p->method == SIP_OPTIONS) {
 		/* We don't really care what the response is, just that it replied back. 
 		   Well, as long as it's not a 100 response...  since we might

Modified: team/rmudgett/misdn_facility/include/asterisk/file.h
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/include/asterisk/file.h?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/include/asterisk/file.h (original)
+++ team/rmudgett/misdn_facility/include/asterisk/file.h Thu Nov 20 13:18:57 2008
@@ -315,6 +315,31 @@
  */ 
 struct ast_frame *ast_readframe(struct ast_filestream *s);
 
+/*!\brief destroy a filestream using an ast_frame as input
+ *
+ * This is a hack that is used also by the ast_trans_pvt and
+ * ast_dsp structures. When a structure contains an ast_frame
+ * pointer as one of its fields. It may be that the frame is
+ * still used after the outer structure is freed. This leads to
+ * invalid memory accesses. This function allows for us to hold
+ * off on destroying the ast_filestream until we are done using
+ * the ast_frame pointer that is part of it
+ *
+ * \param fr The ast_frame that is part of an ast_filestream we wish
+ * to free.
+ */
+void ast_filestream_frame_freed(struct ast_frame *fr);
+
+/*! Initialize file stuff */
+/*!
+ * Initializes all the various file stuff.  Basically just registers the cli stuff
+ * Returns 0 all the time
+ */
+int ast_file_init(void);
+
+
+#define AST_RESERVED_POINTERS 20
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: team/rmudgett/misdn_facility/include/asterisk/frame.h
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/include/asterisk/frame.h?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/include/asterisk/frame.h (original)
+++ team/rmudgett/misdn_facility/include/asterisk/frame.h Thu Nov 20 13:18:57 2008
@@ -136,6 +136,10 @@
 	 *  The dsp cannot be free'd if the frame inside of it still has
 	 *  this flag set. */
 	AST_FRFLAG_FROM_DSP = (1 << 2),
+	/*! This frame came from a filestream and is still the original frame.
+	 *  The filestream cannot be free'd if the frame inside of it still has
+	 *  this flag set. */
+	AST_FRFLAG_FROM_FILESTREAM = (1 << 3),
 };
 
 /*! \brief Data structure associated with a single frame of data

Modified: team/rmudgett/misdn_facility/main/config.c
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/main/config.c?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/main/config.c (original)
+++ team/rmudgett/misdn_facility/main/config.c Thu Nov 20 13:18:57 2008
@@ -359,16 +359,18 @@
 	int lineno;
 	int insertline;
 
-	if (!variable || sscanf(line, "%d", &insertline) != 1)
+	if (!variable || sscanf(line, "%d", &insertline) != 1) {
 		return;
+	}
 	if (!insertline) {
 		variable->next = category->root;
 		category->root = variable;
 	} else {
 		for (lineno = 1; lineno < insertline; lineno++) {
 			cur = cur->next;
-			if (!cur->next)
+			if (!cur->next) {
 				break;
+			}
 		}
 		variable->next = cur->next;
 		cur->next = variable;
@@ -390,10 +392,11 @@
 {
 	struct ast_category *cat = NULL;
 
-	if (category && config->last_browse && (config->last_browse->name == category))
+	if (category && config->last_browse && (config->last_browse->name == category)) {
 		cat = config->last_browse;
-	else
+	} else {
 		cat = ast_category_get(config, category);
+	}
 
 	return (cat) ? cat->root : NULL;
 }
@@ -402,8 +405,9 @@
 {
 	const char *tmp;
 	tmp = ast_variable_retrieve(cfg, cat, var);
-	if (!tmp)
+	if (!tmp) {
 		tmp = ast_variable_retrieve(cfg, "general", var);
+	}
 	return tmp;
 }
 
@@ -414,16 +418,20 @@
 
 	if (category) {
 		for (v = ast_variable_browse(config, category); v; v = v->next) {
-			if (!strcasecmp(variable, v->name))
+			if (!strcasecmp(variable, v->name)) {
 				return v->value;
+			}
 		}
 	} else {
 		struct ast_category *cat;
 
-		for (cat = config->root; cat; cat = cat->next)
-			for (v = cat->root; v; v = v->next)
-				if (!strcasecmp(variable, v->name))
+		for (cat = config->root; cat; cat = cat->next) {
+			for (v = cat->root; v; v = v->next) {
+				if (!strcasecmp(variable, v->name)) {
 					return v->value;
+				}
+			}
+		}
 	}
 
 	return NULL;

Modified: team/rmudgett/misdn_facility/main/file.c
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/main/file.c?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/main/file.c (original)
+++ team/rmudgett/misdn_facility/main/file.c Thu Nov 20 13:18:57 2008
@@ -44,6 +44,7 @@
 #include "asterisk/pbx.h"
 #include "asterisk/linkedlists.h"
 #include "asterisk/module.h"
+#include "asterisk/astobj2.h"
 
 /*
  * The following variable controls the layout of localized sound files.
@@ -280,12 +281,57 @@
 	return 0;
 }
 
+static void filestream_destructor(void *arg)
+{
+	char *cmd = NULL;
+	size_t size = 0;
+	struct ast_filestream *f = arg;
+
+	/* Stop a running stream if there is one */
+	if (f->owner) {
+		if (f->fmt->format < AST_FORMAT_AUDIO_MASK) {
+			f->owner->stream = NULL;
+			AST_SCHED_DEL(f->owner->sched, f->owner->streamid);
+#ifdef HAVE_DAHDI
+			ast_settimeout(f->owner, 0, NULL, NULL);
+#endif			
+		} else {
+			f->owner->vstream = NULL;
+			AST_SCHED_DEL(f->owner->sched, f->owner->vstreamid);
+		}
+	}
+	/* destroy the translator on exit */
+	if (f->trans)
+		ast_translator_free_path(f->trans);
+
+	if (f->realfilename && f->filename) {
+			size = strlen(f->filename) + strlen(f->realfilename) + 15;
+			cmd = alloca(size);
+			memset(cmd,0,size);
+			snprintf(cmd,size,"/bin/mv -f %s %s",f->filename,f->realfilename);
+			ast_safe_system(cmd);
+	}
+
+	if (f->filename)
+		free(f->filename);
+	if (f->realfilename)
+		free(f->realfilename);
+	if (f->fmt->close)
+		f->fmt->close(f);
+	fclose(f->f);
+	if (f->vfs)
+		ast_closestream(f->vfs);
+	if (f->orig_chan_name)
+		free((void *) f->orig_chan_name);
+	ast_module_unref(f->fmt->module);
+}
+
 static struct ast_filestream *get_filestream(struct ast_format *fmt, FILE *bfile)
 {
 	struct ast_filestream *s;
 
 	int l = sizeof(*s) + fmt->buf_size + fmt->desc_size;	/* total allocation size */
-	if ( (s = ast_calloc(1, l)) == NULL)
+	if ( (s = ao2_alloc(l, filestream_destructor)) == NULL)
 		return NULL;
 	s->fmt = fmt;
 	s->f = bfile;
@@ -407,6 +453,9 @@
 					ast_free(s);
 					continue;	/* cannot run open on file */
 				}
+				if (st.st_size == 0) {
+					ast_log(LOG_WARNING, "File %s detected to have zero size.\n", fn);
+				}
 				/* ok this is good for OPEN */
 				res = 1;	/* found */
 				s->lasttimeout = -1;
@@ -639,6 +688,10 @@
 	int whennext = 0;	
 	if (s && s->fmt)
 		f = s->fmt->read(s, &whennext);
+	if (f) {
+		ast_set_flag(f, AST_FRFLAG_FROM_FILESTREAM);
+		ao2_ref(s, +1);
+	}
 	return f;
 }
 
@@ -788,49 +841,21 @@
 
 int ast_closestream(struct ast_filestream *f)
 {
-	char *cmd = NULL;
-	size_t size = 0;
-	/* Stop a running stream if there is one */
-	if (f->owner) {
-		if (f->fmt->format & AST_FORMAT_AUDIO_MASK) {
-			f->owner->stream = NULL;
-			AST_SCHED_DEL(f->owner->sched, f->owner->streamid);
-			ast_settimeout(f->owner, 0, NULL, NULL);
-		} else {
-			f->owner->vstream = NULL;
-			AST_SCHED_DEL(f->owner->sched, f->owner->vstreamid);
-		}
-	}
-	/* destroy the translator on exit */
-	if (f->trans)
-		ast_translator_free_path(f->trans);
-
-	if (f->realfilename && f->filename) {
-			size = strlen(f->filename) + strlen(f->realfilename) + 15;
-			cmd = alloca(size);
-			memset(cmd, 0, size);
-			snprintf(cmd, size, "/bin/mv -f %s %s", f->filename, f->realfilename);
-			ast_safe_system(cmd);
-	}
-
-	if (f->fmt->close) {
-		f->fmt->close(f);
-	}
-	if (f->filename)
-		ast_free(f->filename);
-	if (f->realfilename)
-		ast_free(f->realfilename);
-	fclose(f->f);
-	if (f->vfs)
-		ast_closestream(f->vfs);
-	if (f->orig_chan_name)
-		free((void *) f->orig_chan_name);
-	if (f->write_buffer) {
-		ast_free(f->write_buffer);
-	}
-
-	ast_module_unref(f->fmt->module);
-	ast_free(f);
+	if (ast_test_flag(&f->fr, AST_FRFLAG_FROM_FILESTREAM)) {
+		/* If this flag is still set, it essentially means that the reference
+		 * count of f is non-zero. We can't destroy this filestream until
+		 * whatever is using the filestream's frame has finished.
+		 *
+		 * Since this was called, however, we need to remove the reference from
+		 * when this filestream was first allocated. That way, when the embedded
+		 * frame is freed, the refcount will reach 0 and we can finish destroying
+		 * this filestream properly.
+		 */
+		ao2_ref(f, -1);
+		return 0;
+	}
+	
+	ao2_ref(f, -1);
 	return 0;
 }
 
@@ -872,8 +897,19 @@
 	struct ast_filestream *fs;
 	struct ast_filestream *vfs=NULL;
 	char fmt[256];
+	int seekattempt;
 
 	fs = ast_openstream(chan, filename, preflang);
+
+	/* check to see if there is any data present (not a zero length file),
+	 * done this way because there is no where for ast_openstream_full to
+	 * return the file had no data. */
+	seekattempt = fseek(fs->f, -1, SEEK_END);
+	if (!seekattempt)
+		fseek(fs->f, 0, SEEK_SET);
+	else
+		return 0;
+
 	if (fs)
 		vfs = ast_openvstream(chan, filename, preflang);
 	if (vfs) {
@@ -1241,6 +1277,17 @@
 		-1, -1, context);
 }
 
+void ast_filestream_frame_freed(struct ast_frame *fr)
+{
+	struct ast_filestream *fs;
+
+	ast_clear_flag(fr, AST_FRFLAG_FROM_FILESTREAM);
+
+	fs = (struct ast_filestream *) (((char *) fr) - offsetof(struct ast_filestream, fr));
+
+	ao2_ref(fs, -1);
+}
+
 /*
  * if the file name is non-empty, try to play it.
  * Return 0 if success, -1 if error, digit if interrupted by a digit.

Modified: team/rmudgett/misdn_facility/main/frame.c
URL: http://svn.digium.com/view/asterisk/team/rmudgett/misdn_facility/main/frame.c?view=diff&rev=158187&r1=158186&r2=158187
==============================================================================
--- team/rmudgett/misdn_facility/main/frame.c (original)
+++ team/rmudgett/misdn_facility/main/frame.c Thu Nov 20 13:18:57 2008
@@ -38,6 +38,7 @@
 #include "asterisk/linkedlists.h"
 #include "asterisk/translate.h"
 #include "asterisk/dsp.h"
+#include "asterisk/file.h"
 
 #ifdef TRACE_FRAMES
 static int headers;
@@ -307,10 +308,13 @@
 
 void ast_frame_free(struct ast_frame *fr, int cache)
 {
-	if (ast_test_flag(fr, AST_FRFLAG_FROM_TRANSLATOR))
+	if (ast_test_flag(fr, AST_FRFLAG_FROM_TRANSLATOR)) {
 		ast_translate_frame_freed(fr);
-	else if (ast_test_flag(fr, AST_FRFLAG_FROM_DSP))
+	} else if (ast_test_flag(fr, AST_FRFLAG_FROM_DSP)) {
 		ast_dsp_frame_freed(fr);
+	} else if (ast_test_flag(fr, AST_FRFLAG_FROM_FILESTREAM)) {
+		ast_filestream_frame_freed(fr);
+	}
 
 	if (!fr->mallocd)
 		return;




More information about the asterisk-commits mailing list