[asterisk-commits] branch bweschke/bug_5374 r9202 - in /team/bweschke/bug_5374: ./ agi/ apps/ cd...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Feb 7 12:35:32 MST 2006


Author: bweschke
Date: Tue Feb  7 13:33:24 2006
New Revision: 9202

URL: http://svn.digium.com/view/asterisk?rev=9202&view=rev
Log:
 Bringing this branch up to date with /trunk


Added:
    team/bweschke/bug_5374/configs/muted.conf.sample
      - copied unchanged from r9194, trunk/configs/muted.conf.sample
    team/bweschke/bug_5374/doc/00README.1st
      - copied unchanged from r9194, trunk/doc/00README.1st
    team/bweschke/bug_5374/doc/ael.txt
      - copied unchanged from r9194, trunk/doc/ael.txt
    team/bweschke/bug_5374/doc/app-sms.txt
      - copied unchanged from r9194, trunk/doc/app-sms.txt
    team/bweschke/bug_5374/doc/asterisk-conf.txt
      - copied unchanged from r9194, trunk/doc/asterisk-conf.txt
    team/bweschke/bug_5374/doc/backtrace.txt
      - copied unchanged from r9194, trunk/doc/backtrace.txt
    team/bweschke/bug_5374/doc/billing.txt
      - copied unchanged from r9194, trunk/doc/billing.txt
    team/bweschke/bug_5374/doc/callingpres.txt
      - copied unchanged from r9194, trunk/doc/callingpres.txt
    team/bweschke/bug_5374/doc/cdrdriver.txt
      - copied unchanged from r9194, trunk/doc/cdrdriver.txt
    team/bweschke/bug_5374/doc/chaniax.txt
      - copied unchanged from r9194, trunk/doc/chaniax.txt
    team/bweschke/bug_5374/doc/channels.txt
      - copied unchanged from r9194, trunk/doc/channels.txt
    team/bweschke/bug_5374/doc/channelvariables.txt
      - copied unchanged from r9194, trunk/doc/channelvariables.txt
    team/bweschke/bug_5374/doc/cliprompt.txt
      - copied unchanged from r9194, trunk/doc/cliprompt.txt
    team/bweschke/bug_5374/doc/configuration.txt
      - copied unchanged from r9194, trunk/doc/configuration.txt
    team/bweschke/bug_5374/doc/cygwin.txt
      - copied unchanged from r9194, trunk/doc/cygwin.txt
    team/bweschke/bug_5374/doc/dundi.txt
      - copied unchanged from r9194, trunk/doc/dundi.txt
    team/bweschke/bug_5374/doc/enum.txt
      - copied unchanged from r9194, trunk/doc/enum.txt
    team/bweschke/bug_5374/doc/extconfig.txt
      - copied unchanged from r9194, trunk/doc/extconfig.txt
    team/bweschke/bug_5374/doc/externalivr.txt
      - copied unchanged from r9194, trunk/doc/externalivr.txt
    team/bweschke/bug_5374/doc/freetds.txt
      - copied unchanged from r9194, trunk/doc/freetds.txt
    team/bweschke/bug_5374/doc/h323.txt
      - copied unchanged from r9194, trunk/doc/h323.txt
    team/bweschke/bug_5374/doc/hardware.txt
      - copied unchanged from r9194, trunk/doc/hardware.txt
    team/bweschke/bug_5374/doc/ices.txt
      - copied unchanged from r9194, trunk/doc/ices.txt
    team/bweschke/bug_5374/doc/jitterbuffer.txt
      - copied unchanged from r9194, trunk/doc/jitterbuffer.txt
    team/bweschke/bug_5374/doc/linkedlists.txt
      - copied unchanged from r9194, trunk/doc/linkedlists.txt
    team/bweschke/bug_5374/doc/math.txt
      - copied unchanged from r9194, trunk/doc/math.txt
    team/bweschke/bug_5374/doc/misdn.txt
      - copied unchanged from r9194, trunk/doc/misdn.txt
    team/bweschke/bug_5374/doc/mp3.txt
      - copied unchanged from r9194, trunk/doc/mp3.txt
    team/bweschke/bug_5374/doc/musiconhold-fpm.txt
      - copied unchanged from r9194, trunk/doc/musiconhold-fpm.txt
    team/bweschke/bug_5374/doc/mysql.txt
      - copied unchanged from r9194, trunk/doc/mysql.txt
    team/bweschke/bug_5374/doc/odbcstorage.txt
      - copied unchanged from r9194, trunk/doc/odbcstorage.txt
    team/bweschke/bug_5374/doc/privacy.txt
      - copied unchanged from r9194, trunk/doc/privacy.txt
    team/bweschke/bug_5374/doc/realtime.txt
      - copied unchanged from r9194, trunk/doc/realtime.txt
    team/bweschke/bug_5374/doc/security.txt
      - copied unchanged from r9194, trunk/doc/security.txt
    team/bweschke/bug_5374/doc/sms.txt
      - copied unchanged from r9194, trunk/doc/sms.txt
    team/bweschke/bug_5374/funcs/func_sha1.c
      - copied unchanged from r9194, trunk/funcs/func_sha1.c
    team/bweschke/bug_5374/include/asterisk/sha1.h
      - copied unchanged from r9194, trunk/include/asterisk/sha1.h
    team/bweschke/bug_5374/sha1.c
      - copied unchanged from r9194, trunk/sha1.c
Removed:
    team/bweschke/bug_5374/HARDWARE
    team/bweschke/bug_5374/README.fpm
    team/bweschke/bug_5374/SECURITY
    team/bweschke/bug_5374/apps/app_intercom.c
    team/bweschke/bug_5374/apps/app_sql_postgres.c
    team/bweschke/bug_5374/doc/README.ael
    team/bweschke/bug_5374/doc/README.app_sms
    team/bweschke/bug_5374/doc/README.asterisk.conf
    team/bweschke/bug_5374/doc/README.backtrace
    team/bweschke/bug_5374/doc/README.callingpres
    team/bweschke/bug_5374/doc/README.cdr
    team/bweschke/bug_5374/doc/README.channels
    team/bweschke/bug_5374/doc/README.cliprompt
    team/bweschke/bug_5374/doc/README.configuration
    team/bweschke/bug_5374/doc/README.cygwin
    team/bweschke/bug_5374/doc/README.dundi
    team/bweschke/bug_5374/doc/README.enum
    team/bweschke/bug_5374/doc/README.extconfig
    team/bweschke/bug_5374/doc/README.externalivr
    team/bweschke/bug_5374/doc/README.h323
    team/bweschke/bug_5374/doc/README.iax
    team/bweschke/bug_5374/doc/README.ices
    team/bweschke/bug_5374/doc/README.jitterbuffer
    team/bweschke/bug_5374/doc/README.linkedlists
    team/bweschke/bug_5374/doc/README.math
    team/bweschke/bug_5374/doc/README.misdn
    team/bweschke/bug_5374/doc/README.mp3
    team/bweschke/bug_5374/doc/README.mysql
    team/bweschke/bug_5374/doc/README.odbcstorage
    team/bweschke/bug_5374/doc/README.privacy
    team/bweschke/bug_5374/doc/README.realtime
    team/bweschke/bug_5374/doc/README.sms
    team/bweschke/bug_5374/doc/README.tds
    team/bweschke/bug_5374/doc/README.variables
    team/bweschke/bug_5374/doc/cdr.txt
    team/bweschke/bug_5374/muted.conf.sample
Modified:
    team/bweschke/bug_5374/   (props changed)
    team/bweschke/bug_5374/.cleancount
    team/bweschke/bug_5374/Makefile
    team/bweschke/bug_5374/UPGRADE.txt
    team/bweschke/bug_5374/agi/Makefile
    team/bweschke/bug_5374/apps/Makefile
    team/bweschke/bug_5374/apps/app_dial.c
    team/bweschke/bug_5374/apps/app_disa.c
    team/bweschke/bug_5374/apps/app_dumpchan.c
    team/bweschke/bug_5374/apps/app_flash.c
    team/bweschke/bug_5374/apps/app_macro.c
    team/bweschke/bug_5374/apps/app_meetme.c
    team/bweschke/bug_5374/apps/app_queue.c
    team/bweschke/bug_5374/apps/app_softhangup.c
    team/bweschke/bug_5374/apps/app_transfer.c
    team/bweschke/bug_5374/apps/app_voicemail.c
    team/bweschke/bug_5374/apps/app_zapbarge.c
    team/bweschke/bug_5374/apps/app_zapras.c
    team/bweschke/bug_5374/apps/app_zapscan.c
    team/bweschke/bug_5374/cdr.c
    team/bweschke/bug_5374/cdr/Makefile
    team/bweschke/bug_5374/channel.c
    team/bweschke/bug_5374/channels/Makefile
    team/bweschke/bug_5374/channels/chan_agent.c
    team/bweschke/bug_5374/channels/chan_alsa.c
    team/bweschke/bug_5374/channels/chan_features.c
    team/bweschke/bug_5374/channels/chan_h323.c
    team/bweschke/bug_5374/channels/chan_iax2.c
    team/bweschke/bug_5374/channels/chan_local.c
    team/bweschke/bug_5374/channels/chan_mgcp.c
    team/bweschke/bug_5374/channels/chan_misdn.c
    team/bweschke/bug_5374/channels/chan_misdn_config.c
    team/bweschke/bug_5374/channels/chan_nbs.c
    team/bweschke/bug_5374/channels/chan_oss.c
    team/bweschke/bug_5374/channels/chan_phone.c
    team/bweschke/bug_5374/channels/chan_sip.c
    team/bweschke/bug_5374/channels/chan_skinny.c
    team/bweschke/bug_5374/channels/chan_vpb.c
    team/bweschke/bug_5374/channels/chan_zap.c
    team/bweschke/bug_5374/channels/iax2-parser.c
    team/bweschke/bug_5374/channels/iax2-parser.h
    team/bweschke/bug_5374/channels/misdn/Makefile
    team/bweschke/bug_5374/channels/misdn/chan_misdn_config.h
    team/bweschke/bug_5374/channels/misdn/isdn_lib.c
    team/bweschke/bug_5374/channels/misdn/isdn_lib.h
    team/bweschke/bug_5374/channels/misdn/isdn_msg_parser.c
    team/bweschke/bug_5374/cli.c
    team/bweschke/bug_5374/codecs/Makefile
    team/bweschke/bug_5374/configs/misdn.conf.sample
    team/bweschke/bug_5374/configs/sip.conf.sample
    team/bweschke/bug_5374/formats/Makefile
    team/bweschke/bug_5374/frame.c
    team/bweschke/bug_5374/funcs/Makefile
    team/bweschke/bug_5374/funcs/func_language.c
    team/bweschke/bug_5374/funcs/func_md5.c
    team/bweschke/bug_5374/funcs/func_moh.c
    team/bweschke/bug_5374/image.c
    team/bweschke/bug_5374/include/asterisk/cdr.h
    team/bweschke/bug_5374/include/asterisk/channel.h
    team/bweschke/bug_5374/include/asterisk/frame.h
    team/bweschke/bug_5374/include/asterisk/image.h
    team/bweschke/bug_5374/include/asterisk/musiconhold.h
    team/bweschke/bug_5374/include/asterisk/stringfields.h
    team/bweschke/bug_5374/include/asterisk/utils.h
    team/bweschke/bug_5374/pbx.c
    team/bweschke/bug_5374/pbx/Makefile
    team/bweschke/bug_5374/res/Makefile
    team/bweschke/bug_5374/res/res_agi.c
    team/bweschke/bug_5374/res/res_clioriginate.c
    team/bweschke/bug_5374/res/res_features.c
    team/bweschke/bug_5374/res/res_musiconhold.c
    team/bweschke/bug_5374/res/res_odbc.c
    team/bweschke/bug_5374/rtp.c
    team/bweschke/bug_5374/stdtime/Makefile
    team/bweschke/bug_5374/udptl.c
    team/bweschke/bug_5374/utils.c
    team/bweschke/bug_5374/utils/Makefile

Propchange: team/bweschke/bug_5374/
------------------------------------------------------------------------------
--- branch-1.2-blocked (added)
+++ branch-1.2-blocked Tue Feb  7 13:33:24 2006
@@ -1,0 +1,1 @@
+/branches/1.2:7490,7497,7517,7529,7546,7550,7552,7557,7580,7586,7595,7605,7641,7663,7706,7738,7771,7792,7812,7870-7871,7898-7900,7915,7960,7965,7970,7976,8047,8112,8124,8134,8394,8412,8414,8418,8429,8433,8445,8562,8573,8600,8619,8666,8808,9073

Propchange: team/bweschke/bug_5374/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/bweschke/bug_5374/
            ('svnmerge-blocked' removed)

Propchange: team/bweschke/bug_5374/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Feb  7 13:33:24 2006
@@ -1,1 +1,1 @@
-/trunk:1-8837
+/trunk:1-9198

Modified: team/bweschke/bug_5374/.cleancount
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/.cleancount?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/.cleancount (original)
+++ team/bweschke/bug_5374/.cleancount Tue Feb  7 13:33:24 2006
@@ -1,1 +1,1 @@
-8
+10

Modified: team/bweschke/bug_5374/Makefile
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/Makefile?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/Makefile (original)
+++ team/bweschke/bug_5374/Makefile Tue Feb  7 13:33:24 2006
@@ -3,7 +3,7 @@
 # 
 # Top level Makefile
 #
-# Copyright (C) 1999-2005, Mark Spencer
+# Copyright (C) 1999-2006, Digium, Inc.
 #
 # Mark Spencer <markster at digium.com>
 #
@@ -327,8 +327,6 @@
   ifneq ($(wildcard .svn),)
     ASTERISKVERSIONNUM=999999
     ASTERISKVERSION=SVN-$(shell build_tools/make_svn_branch_name)
-  else
-    ASTERISKVERSIONNUM=000000
   endif
 endif
 
@@ -351,7 +349,7 @@
 	astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
 	utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
 	netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
-	cryptostub.o
+	cryptostub.o sha1.o
 
 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/sys/poll.h),)
   OBJS+= poll.o
@@ -914,3 +912,37 @@
 	if cmp -s .cleancount .lastclean ; then echo ; else \
 		$(MAKE) clean; cp -f .cleancount .lastclean;\
 	fi
+
+_uninstall:
+	rm -f $(DESTDIR)$(MODULES_DIR)/*
+	rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
+	rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
+	rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
+	rm -rf $(DESTDIR)$(ASTHEADERDIR)
+	rm -rf $(DESTDIR)$(ASTVARLIBDIR)/sounds
+	rm -rf $(DESTDIR)$(ASTVARLIBDIR)/firmware
+	rm -rf $(DESTDIR)$(ASTMANDIR)/man8
+	for x in $(SUBDIRS); do $(MAKE) -C $$x uninstall || exit 1 ; done
+
+uninstall: _uninstall
+	@echo " +--------- Asterisk Uninstall Complete -----+"  
+	@echo " + Asterisk binaries, sounds, man pages,     +"  
+	@echo " + headers, modules, and firmware builds,    +"  
+	@echo " + have all been uninstalled.                +"  
+	@echo " +                                           +"
+	@echo " + To remove ALL traces of Asterisk,         +"
+	@echo " + including configuration, spool            +"
+	@echo " + directories, and logs, run the following  +"
+	@echo " + command:                                  +"
+	@echo " +                                           +"
+	@echo " +            $(MAKE) uninstall-all             +"  
+	@echo " +-------------------------------------------+"  
+
+
+uninstall-all: _uninstall
+	rm -rf $(DESTDIR)$(ASTLIBDIR)
+	rm -rf $(DESTDIR)$(ASTVARLIBDIR)
+	rm -rf $(DESTDIR)$(ASTSPOOLDIR)
+	rm -rf $(DESTDIR)$(ASTETCDIR)
+	rm -rf $(DESTDIR)$(ASTLOGDIR)
+

Modified: team/bweschke/bug_5374/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/UPGRADE.txt?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/UPGRADE.txt (original)
+++ team/bweschke/bug_5374/UPGRADE.txt Tue Feb  7 13:33:24 2006
@@ -21,6 +21,7 @@
 * app_read has been updated to use the newer options codes, using "skip" or
   "noanswer" will not work.  Use s or n.  Also there is a new feature i, for
   using indication tones, so typing in skip would give you unexpected results.
+
 Variables:
 
 * The builtin variables ${CALLERID}, ${CALLERIDNAME}, ${CALLERIDNUM},
@@ -29,6 +30,21 @@
   functions.  You are encouraged to move towards the associated dialplan
   function, as these variables will be removed in a future release.
 
+Functions:
+
+* The function ${CHECK_MD5()} has been deprecated in favor of using an
+  expression: $[${MD5(<string>)} = ${saved_md5}].
+
 The SIP channel:
 
 * The "incominglimit" setting is replaced by the "call-limit" setting in sip.conf.
+
+Installation:
+
+* On BSD systems, the installation directories have changed to more "FreeBSDish" directories. On startup, Asterisk will look for the main configuration in /usr7local/etc/asterisk/asterisk.conf
+If you have an old installation, you might want to remove the binaries and move the configuration files to the new locations. The following directories are now default:
+	ASTLIBDIR	/usr/local/lib/asterisk
+	ASTVARLIBDIR	/usr/local/share/asterisk
+	ASTETCDIR	/usr/local/etc/asterisk
+	ASTBINDIR	/usr/local/bin/asterisk
+	ASTSBINDIR	/usr/local/sbin/asterisk

Modified: team/bweschke/bug_5374/agi/Makefile
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/agi/Makefile?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/agi/Makefile (original)
+++ team/bweschke/bug_5374/agi/Makefile Tue Feb  7 13:33:24 2006
@@ -30,6 +30,9 @@
 	mkdir -p $(DESTDIR)$(AGI_DIR)
 	for x in $(AGIS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(AGI_DIR) ; done
 
+uninstall:
+	for x in $(AGIS); do rm -f $(DESTDIR)$(AGI_DIR)/$$x ; done
+
 eagi-test: eagi-test.o
 	$(CC) $(CFLAGS) -o eagi-test eagi-test.o $(LIBS)
 

Modified: team/bweschke/bug_5374/apps/Makefile
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/Makefile?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/Makefile (original)
+++ team/bweschke/bug_5374/apps/Makefile Tue Feb  7 13:33:24 2006
@@ -26,12 +26,6 @@
      app_userevent.so app_url.so app_verbose.so app_voicemail.so               \
      app_waitforring.so app_waitforsilence.so app_while.so app_zapateller.so   \
      app_morsecode.so
-     
-#
-# Obsolete things...
-#
-#APPS+=app_sql_postgres.so
-#APPS+=app_sql_odbc.so
 
 #
 # Experimental things
@@ -92,6 +86,8 @@
 	rm -f $(DESTDIR)$(MODULES_DIR)/app_datetime.so
 	rm -f $(DESTDIR)$(MODULES_DIR)/app_qcall.so
 
+uninstall:
+
 app_curl.so: app_curl.o
 	$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(CURLLIBS)
 

Modified: team/bweschke/bug_5374/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_dial.c?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_dial.c (original)
+++ team/bweschke/bug_5374/apps/app_dial.c Tue Feb  7 13:33:24 2006
@@ -58,6 +58,7 @@
 #include "asterisk/rtp.h"
 #include "asterisk/manager.h"
 #include "asterisk/privacy.h"
+#include "asterisk/stringfields.h"
 
 static char *tdesc = "Dialing Application";
 
@@ -498,7 +499,7 @@
 							else
 								newcid = in->exten;
 							o->chan->cid.cid_num = strdup(newcid);
-							ast_copy_string(o->chan->accountcode, winner->accountcode, sizeof(o->chan->accountcode));
+							ast_string_field_set(o->chan, accountcode, winner->accountcode);
 							o->chan->cdrflags = winner->cdrflags;
 							if (!o->chan->cid.cid_num)
 								ast_log(LOG_WARNING, "Out of memory\n");
@@ -513,7 +514,7 @@
 								if (!o->chan->cid.cid_name)
 									ast_log(LOG_WARNING, "Out of memory\n");	
 							}
-							ast_copy_string(o->chan->accountcode, in->accountcode, sizeof(o->chan->accountcode));
+							ast_string_field_set(o->chan, accountcode, in->accountcode);
 							o->chan->cdrflags = in->cdrflags;
 						}
 
@@ -1089,11 +1090,11 @@
 			tmp->chan->cid.cid_ani = strdup(chan->cid.cid_ani);
 		
 		/* Copy language from incoming to outgoing */
-		ast_copy_string(tmp->chan->language, chan->language, sizeof(tmp->chan->language));
-		ast_copy_string(tmp->chan->accountcode, chan->accountcode, sizeof(tmp->chan->accountcode));
+		ast_string_field_set(tmp->chan, language, chan->language);
+		ast_string_field_set(tmp->chan, accountcode, chan->accountcode);
 		tmp->chan->cdrflags = chan->cdrflags;
 		if (ast_strlen_zero(tmp->chan->musicclass))
-			ast_copy_string(tmp->chan->musicclass, chan->musicclass, sizeof(tmp->chan->musicclass));
+			ast_string_field_set(tmp->chan, musicclass, chan->musicclass);
 		if (chan->cid.cid_rdnis)
 			tmp->chan->cid.cid_rdnis = strdup(chan->cid.cid_rdnis);
 		/* Pass callingpres setting */

Modified: team/bweschke/bug_5374/apps/app_disa.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_disa.c?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_disa.c (original)
+++ team/bweschke/bug_5374/apps/app_disa.c Tue Feb  7 13:33:24 2006
@@ -47,6 +47,7 @@
 #include "asterisk/translate.h"
 #include "asterisk/ulaw.h"
 #include "asterisk/callerid.h"
+#include "asterisk/stringfields.h"
 
 static char *tdesc = "DISA (Direct Inward System Access) Application";
 
@@ -347,7 +348,7 @@
 			}
 
 			if (!ast_strlen_zero(acctcode))
-				ast_copy_string(chan->accountcode, acctcode, sizeof(chan->accountcode));
+				ast_string_field_set(chan, accountcode, acctcode);
 
 			if (special_noanswer) flags.flags = 0;
 			ast_cdr_reset(chan->cdr, &flags);

Modified: team/bweschke/bug_5374/apps/app_dumpchan.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_dumpchan.c?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_dumpchan.c (original)
+++ team/bweschke/bug_5374/apps/app_dumpchan.c Tue Feb  7 13:33:24 2006
@@ -106,7 +106,7 @@
 			 "Data=               %s\n"
 			 "Blocking_in=        %s\n",
 			 c->name,
-			 c->type,
+			 c->tech->type,
 			 c->uniqueid,
 			 (c->cid.cid_num ? c->cid.cid_num : "(N/A)"),
 			 (c->cid.cid_name ? c->cid.cid_name : "(N/A)"),

Modified: team/bweschke/bug_5374/apps/app_flash.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_flash.c?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_flash.c (original)
+++ team/bweschke/bug_5374/apps/app_flash.c Tue Feb  7 13:33:24 2006
@@ -82,7 +82,7 @@
 	struct localuser *u;
 	struct zt_params ztp;
 	LOCAL_USER_ADD(u);
-	if (!strcasecmp(chan->type, "Zap")) {
+	if (!strcasecmp(chan->tech->type, "Zap")) {
 		memset(&ztp, 0, sizeof(ztp));
 		res = ioctl(chan->fds[0], ZT_GET_PARAMS, &ztp);
 		if (!res) {

Modified: team/bweschke/bug_5374/apps/app_macro.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_macro.c?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_macro.c (original)
+++ team/bweschke/bug_5374/apps/app_macro.c Tue Feb  7 13:33:24 2006
@@ -107,7 +107,7 @@
 	char oldcontext[AST_MAX_CONTEXT] = "";
 	int offset, depth = 0;
 	int setmacrocontext=0;
-	int autoloopflag;
+	int autoloopflag, dead = 0;
   
 	char *save_macro_exten;
 	char *save_macro_context;
@@ -208,8 +208,8 @@
 				break;
 			}
 			switch(res) {
-	        	case MACRO_EXIT_RESULT:
-                        	res = 0;
+			case MACRO_EXIT_RESULT:
+				res = 0;
 				goto out;
 			case AST_PBX_KEEPALIVE:
 				if (option_debug)
@@ -223,6 +223,7 @@
 					ast_log(LOG_DEBUG, "Spawn extension (%s,%s,%d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, chan->name, macro);
 				else if (option_verbose > 1)
 					ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, chan->name, macro);
+				dead = 1;
 				goto out;
 			}
 		}
@@ -242,37 +243,44 @@
 	out:
 	/* Reset the depth back to what it was when the routine was entered (like if we called Macro recursively) */
 	snprintf(depthc, sizeof(depthc), "%d", depth);
-	pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc);
-
-	ast_set2_flag(chan, autoloopflag, AST_FLAG_IN_AUTOLOOP);
-  	for (x=1; x<argc; x++) {
+	if (!dead) {
+		pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc);
+
+		ast_set2_flag(chan, autoloopflag, AST_FLAG_IN_AUTOLOOP);
+	}
+
+  	for (x = 1; x < argc; x++) {
   		/* Restore old arguments and delete ours */
 		snprintf(varname, sizeof(varname), "ARG%d", x);
   		if (oldargs[x]) {
-			pbx_builtin_setvar_helper(chan, varname, oldargs[x]);
+			if (!dead)
+				pbx_builtin_setvar_helper(chan, varname, oldargs[x]);
 			free(oldargs[x]);
-		} else {
+		} else if (!dead) {
 			pbx_builtin_setvar_helper(chan, varname, NULL);
 		}
   	}
 
 	/* Restore macro variables */
-	pbx_builtin_setvar_helper(chan, "MACRO_EXTEN", save_macro_exten);
+	if (!dead) {
+		pbx_builtin_setvar_helper(chan, "MACRO_EXTEN", save_macro_exten);
+		pbx_builtin_setvar_helper(chan, "MACRO_CONTEXT", save_macro_context);
+		pbx_builtin_setvar_helper(chan, "MACRO_PRIORITY", save_macro_priority);
+	}
 	if (save_macro_exten)
 		free(save_macro_exten);
-	pbx_builtin_setvar_helper(chan, "MACRO_CONTEXT", save_macro_context);
 	if (save_macro_context)
 		free(save_macro_context);
-	pbx_builtin_setvar_helper(chan, "MACRO_PRIORITY", save_macro_priority);
 	if (save_macro_priority)
 		free(save_macro_priority);
-	if (setmacrocontext) {
+
+	if (!dead && setmacrocontext) {
 		chan->macrocontext[0] = '\0';
 		chan->macroexten[0] = '\0';
 		chan->macropriority = 0;
 	}
 
-	if (!strcasecmp(chan->context, fullmacro)) {
+	if (!dead && !strcasecmp(chan->context, fullmacro)) {
   		/* If we're leaving the macro normally, restore original information */
 		chan->priority = oldpriority;
 		ast_copy_string(chan->context, oldcontext, sizeof(chan->context));
@@ -292,7 +300,8 @@
 		}
 	}
 
-	pbx_builtin_setvar_helper(chan, "MACRO_OFFSET", save_macro_offset);
+	if (!dead)
+		pbx_builtin_setvar_helper(chan, "MACRO_OFFSET", save_macro_offset);
 	if (save_macro_offset)
 		free(save_macro_offset);
 	LOCAL_USER_REMOVE(u);

Modified: team/bweschke/bug_5374/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_meetme.c?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_meetme.c (original)
+++ team/bweschke/bug_5374/apps/app_meetme.c Tue Feb  7 13:33:24 2006
@@ -206,7 +206,6 @@
 };
 
 static int admin_exec(struct ast_channel *chan, void *data);
-static struct ast_frame null_frame = { AST_FRAME_NULL, };
 
 static void *recordthread(void *args);
 
@@ -426,8 +425,6 @@
 	unsigned char *data;
 	int len;
 	int res = -1;
-	short *data2;
-	int x;
 
 	if (!chan->_softhangup)
 		res = ast_autoservice_start(chan);
@@ -448,10 +445,7 @@
 		len = 0;
 	}
 	if (data) {
-		data2 = alloca(len * 2);
-		for (x=0;x<len;x++)
-			data2[x] = AST_MULAW(data[x]);
-		careful_write(conf->fd, (unsigned char *)data2, len << 1, 1);
+		careful_write(conf->fd, data, len, 1);
 	}
 
 	AST_LIST_UNLOCK(&confs);
@@ -1002,7 +996,7 @@
 	}
 
 	ast_indicate(chan, -1);
-	retryzap = strcasecmp(chan->type, "Zap");
+	retryzap = strcasecmp(chan->tech->type, "Zap");
 	user->zapchannel = !retryzap;
 
  zapretry:
@@ -1308,7 +1302,7 @@
 						using_pseudo = 0;
 					}
 					ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n");
-					retryzap = strcasecmp(c->type, "Zap");
+					retryzap = strcasecmp(c->tech->type, "Zap");
 					user->zapchannel = !retryzap;
 					goto zapretry;
 				}
@@ -1579,7 +1573,7 @@
 								if (conf->transpath[index]) {
 									conf->transframe[index] = ast_translate(conf->transpath[index], conf->origframe, 0);
 									if (!conf->transframe[index])
-										conf->transframe[index] = &null_frame;
+										conf->transframe[index] = &ast_null_frame;
 								}
 							}
 						}

Modified: team/bweschke/bug_5374/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_queue.c?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_queue.c (original)
+++ team/bweschke/bug_5374/apps/app_queue.c Tue Feb  7 13:33:24 2006
@@ -91,6 +91,7 @@
 #include "asterisk/causes.h"
 #include "asterisk/astdb.h"
 #include "asterisk/devicestate.h"
+#include "asterisk/stringfields.h"
 
 #define QUEUE_STRATEGY_RINGALL		0
 #define QUEUE_STRATEGY_ROUNDROBIN	1
@@ -1735,7 +1736,7 @@
 							if (!o->chan->cid.cid_name)
 								ast_log(LOG_WARNING, "Out of memory\n");	
 						}
-						ast_copy_string(o->chan->accountcode, in->accountcode, sizeof(o->chan->accountcode));
+						ast_string_field_set(o->chan, accountcode, in->accountcode);
 						o->chan->cdrflags = in->cdrflags;
 
 						if (in->cid.cid_ani) {
@@ -2182,9 +2183,9 @@
 		   we will always return with -1 so that it is hung up properly after the 
 		   conversation.  */
 		qe->handled++;
-		if (!strcmp(qe->chan->type,"Zap"))
+		if (!strcmp(qe->chan->tech->type, "Zap"))
 			ast_channel_setoption(qe->chan, AST_OPTION_TONE_VERIFY, &nondataquality, sizeof(nondataquality), 0);
-		if (!strcmp(peer->type,"Zap"))
+		if (!strcmp(peer->tech->type, "Zap"))
 			ast_channel_setoption(peer, AST_OPTION_TONE_VERIFY, &nondataquality, sizeof(nondataquality), 0);
 		/* Update parameters for the queue */
 		recalc_holdtime(qe);

Modified: team/bweschke/bug_5374/apps/app_softhangup.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_softhangup.c?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_softhangup.c (original)
+++ team/bweschke/bug_5374/apps/app_softhangup.c Tue Feb  7 13:33:24 2006
@@ -84,7 +84,7 @@
 		/* XXX watch out, i think it is wrong to access c-> after unlocking! */
 		if (all) {
 			/* CAPI is set up like CAPI[foo/bar]/clcnt */ 
-			if (!strcmp(c->type,"CAPI")) 
+			if (!strcmp(c->tech->type, "CAPI")) 
 				cut = strrchr(name,'/');
 			/* Basically everything else is Foo/Bar-Z */
 			else

Modified: team/bweschke/bug_5374/apps/app_transfer.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_transfer.c?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_transfer.c (original)
+++ team/bweschke/bug_5374/apps/app_transfer.c Tue Feb  7 13:33:24 2006
@@ -115,7 +115,7 @@
 		tech = dest;
 		dest = slash + 1;
 		/* Allow execution only if the Tech/destination agrees with the type of the channel */
-		if (strncasecmp(chan->type, tech, len)) {
+		if (strncasecmp(chan->tech->type, tech, len)) {
 			pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
 			LOCAL_USER_REMOVE(u);
 			return 0;

Modified: team/bweschke/bug_5374/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_voicemail.c?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_voicemail.c (original)
+++ team/bweschke/bug_5374/apps/app_voicemail.c Tue Feb  7 13:33:24 2006
@@ -72,6 +72,7 @@
 #include "asterisk/localtime.h"
 #include "asterisk/cli.h"
 #include "asterisk/utils.h"
+#include "asterisk/stringfields.h"
 #ifdef USE_ODBC_STORAGE
 #include "asterisk/res_odbc.h"
 #endif
@@ -2655,7 +2656,7 @@
 }
 
 
-static int say_and_wait(struct ast_channel *chan, int num, char *language)
+static int say_and_wait(struct ast_channel *chan, int num, const char *language)
 {
 	int d;
 	d = ast_say_number(chan, num, AST_DIGIT_ANY, language, (char *) NULL);
@@ -5150,7 +5151,7 @@
 	
 	/* Set language from config to override channel language */
 	if (!ast_strlen_zero(vmu->language))
-		ast_copy_string(chan->language, vmu->language, sizeof(chan->language));
+		ast_string_field_set(chan, language, vmu->language);
 	create_dirpath(vms.curdir, sizeof(vms.curdir), vmu->context, vms.username, "");
 	/* Retrieve old and new message counts */
 	res = open_mailbox(&vms, vmu, 1);

Modified: team/bweschke/bug_5374/apps/app_zapbarge.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_zapbarge.c?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_zapbarge.c (original)
+++ team/bweschke/bug_5374/apps/app_zapbarge.c Tue Feb  7 13:33:24 2006
@@ -131,7 +131,7 @@
 		goto outrun;
 	}
 	ast_indicate(chan, -1);
-	retryzap = strcasecmp(chan->type, "Zap");
+	retryzap = strcasecmp(chan->tech->type, "Zap");
 zapretry:
 	origfd = chan->fds[0];
 	if (retryzap) {

Modified: team/bweschke/bug_5374/apps/app_zapras.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_zapras.c?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_zapras.c (original)
+++ team/bweschke/bug_5374/apps/app_zapras.c Tue Feb  7 13:33:24 2006
@@ -217,7 +217,7 @@
 	/* Answer the channel if it's not up */
 	if (chan->_state != AST_STATE_UP)
 		ast_answer(chan);
-	if (strcasecmp(chan->type, "Zap")) {
+	if (strcasecmp(chan->tech->type, "Zap")) {
 		/* If it's not a zap channel, we're done.  Wait a couple of
 		   seconds and then hangup... */
 		if (option_verbose > 1)

Modified: team/bweschke/bug_5374/apps/app_zapscan.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_zapscan.c?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_zapscan.c (original)
+++ team/bweschke/bug_5374/apps/app_zapscan.c Tue Feb  7 13:33:24 2006
@@ -137,7 +137,7 @@
 		goto outrun;
 	}
 	ast_indicate(chan, -1);
-	retryzap = strcasecmp(chan->type, "Zap");
+	retryzap = strcasecmp(chan->tech->type, "Zap");
  zapretry:
 	origfd = chan->fds[0];
 	if (retryzap) {
@@ -345,7 +345,7 @@
 				continue;
 			}
 		}
-		if ( tempchan && tempchan->type && (!strcmp(tempchan->type, "Zap")) && (tempchan != chan) ) {
+		if (tempchan && (!strcmp(tempchan->tech->type, "Zap")) && (tempchan != chan) ) {
 			ast_verbose(VERBOSE_PREFIX_3 "Zap channel %s is in-use, monitoring...\n", tempchan->name);
 			ast_copy_string(confstr, tempchan->name, sizeof(confstr));
 			ast_mutex_unlock(&tempchan->lock);

Modified: team/bweschke/bug_5374/cdr.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/cdr.c?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/cdr.c (original)
+++ team/bweschke/bug_5374/cdr.c Tue Feb  7 13:33:24 2006
@@ -54,6 +54,7 @@
 #include "asterisk/config.h"
 #include "asterisk/cli.h"
 #include "asterisk/module.h"
+#include "asterisk/stringfields.h"
 
 /*! Default AMA flag for billing records (CDR's) */
 int ast_default_amaflags = AST_CDR_DOCUMENTATION;
@@ -535,7 +536,7 @@
 	return res;
 }
 
-void ast_cdr_setdestchan(struct ast_cdr *cdr, char *chann)
+void ast_cdr_setdestchan(struct ast_cdr *cdr, const char *chann)
 {
 	char *chan; 
 
@@ -682,7 +683,7 @@
 {
 	struct ast_cdr *cdr = chan->cdr;
 
-	ast_copy_string(chan->accountcode, account, sizeof(chan->accountcode));
+	ast_string_field_set(chan, accountcode, account);
 	while (cdr) {
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED))
 			ast_copy_string(cdr->accountcode, chan->accountcode, sizeof(cdr->accountcode));

Modified: team/bweschke/bug_5374/cdr/Makefile
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/cdr/Makefile?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/cdr/Makefile (original)
+++ team/bweschke/bug_5374/cdr/Makefile Tue Feb  7 13:33:24 2006
@@ -112,6 +112,8 @@
 install: all
 	for x in $(MODS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
 
+uninstall:
+
 clean:
 	rm -f *.so *.o .depend
 

Modified: team/bweschke/bug_5374/channel.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/channel.c?rev=9202&r1=9201&r2=9202&view=diff
==============================================================================
--- team/bweschke/bug_5374/channel.c (original)
+++ team/bweschke/bug_5374/channel.c Tue Feb  7 13:33:24 2006
@@ -72,6 +72,7 @@
 #include "asterisk/app.h"
 #include "asterisk/transcap.h"
 #include "asterisk/devicestate.h"
+#include "asterisk/sha1.h"
 
 struct channel_spy_trans {
 	int last_format;
@@ -604,7 +605,12 @@
 		return NULL;
 	}
 	
-	for (x=0; x<AST_MAX_FDS - 1; x++)
+	ast_string_field_init(tmp, 128);
+
+	/* Don't bother initializing the last two FD here, because they
+	   will *always* be set just a few lines down (AST_TIMING_FD,
+	   AST_ALERT_FD). */
+	for (x=0; x<AST_MAX_FDS - 2; x++)
 		tmp->fds[x] = -1;
 
 #ifdef ZAPTEL_OPTIMIZATIONS
@@ -636,10 +642,10 @@
 		tmp->alertpipe[0] = tmp->alertpipe[1] = -1;
 
 	/* Always watch the alertpipe */
-	tmp->fds[AST_MAX_FDS-1] = tmp->alertpipe[0];
+	tmp->fds[AST_ALERT_FD] = tmp->alertpipe[0];
 	/* And timing pipe */
-	tmp->fds[AST_MAX_FDS-2] = tmp->timingfd;
-	strcpy(tmp->name, "**Unknown**");
+	tmp->fds[AST_TIMING_FD] = tmp->timingfd;
+	ast_string_field_set(tmp, name, "**Unknown**");
 	/* Initial state */
 	tmp->_state = AST_STATE_DOWN;
 	tmp->streamid = -1;
@@ -654,11 +660,11 @@
 	ast_mutex_init(&tmp->lock);
 	AST_LIST_HEAD_INIT_NOLOCK(headp);
 	strcpy(tmp->context, "default");
-	ast_copy_string(tmp->language, defaultlanguage, sizeof(tmp->language));
+	ast_string_field_set(tmp, language, defaultlanguage);
 	strcpy(tmp->exten, "s");
 	tmp->priority = 1;
 	tmp->amaflags = ast_default_amaflags;
-	ast_copy_string(tmp->accountcode, ast_default_accountcode, sizeof(tmp->accountcode));
+	ast_string_field_set(tmp, accountcode, ast_default_accountcode);
 
 	tmp->tech = &null_tech;
 
@@ -1416,6 +1422,7 @@
 			chan->generator->release(chan, chan->generatordata);
 		chan->generatordata = NULL;
 		chan->generator = NULL;
+		chan->fds[AST_GENERATOR_FD] = -1;
 		ast_clear_flag(chan, AST_FLAG_WRITE_INT);
 		ast_settimeout(chan, 0, NULL, NULL);
 	}
@@ -1472,56 +1479,8 @@
 /*! \brief Wait for x amount of time on a file descriptor to have input.  */
 int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception)
 {
-	struct timeval start = { 0 , 0 };
-	int res;
-	int x, y;
 	int winner = -1;
-	int spoint;
-	struct pollfd *pfds;
-	
-	pfds = alloca(sizeof(struct pollfd) * n);
-	if (!pfds) {
-		ast_log(LOG_ERROR, "Out of memory\n");
-		return -1;
-	}
-	if (*ms > 0)
-		start = ast_tvnow();
-	y = 0;
-	for (x=0; x < n; x++) {
-		if (fds[x] > -1) {
-			pfds[y].fd = fds[x];
-			pfds[y].events = POLLIN | POLLPRI;
-			y++;
-		}
-	}
-	res = poll(pfds, y, *ms);
-	if (res < 0) {
-		/* Simulate a timeout if we were interrupted */
-		if (errno != EINTR)
-			*ms = -1;
-		else
-			*ms = 0;
-		return -1;
-	}
-	spoint = 0;
-	for (x=0; x < n; x++) {
-		if (fds[x] > -1) {
-			if ((res = ast_fdisset(pfds, fds[x], y, &spoint))) {
-				winner = fds[x];
-				if (exception) {
-					if (res & POLLPRI)
-						*exception = -1;
-					else
-						*exception = 0;
-				}
-			}
-		}
-	}
-	if (*ms > 0) {
-		*ms -= ast_tvdiff_ms(ast_tvnow(), start);
-		if (*ms < 0)
-			*ms = 0;
-	}
+	ast_waitfor_nandfds(NULL, 0, fds, n, exception, &winner, ms);
 	return winner;
 }
 
@@ -1534,13 +1493,19 @@
 	int res;
 	long rms;
 	int x, y, max;
-	int spoint;
+	int sz;
 	time_t now = 0;
-	long whentohangup = 0, havewhen = 0, diff;
+	long whentohangup = 0, diff;
 	struct ast_channel *winner = NULL;
-
-	pfds = alloca(sizeof(struct pollfd) * (n * AST_MAX_FDS + nfds));
-	if (!pfds) {
+	struct fdmap {
+		int chan;
+		int fdno;
+	} *fdmap;
+
+	sz = n * AST_MAX_FDS + nfds;
+	pfds = alloca(sizeof(struct pollfd) * sz);
+	fdmap = alloca(sizeof(struct fdmap) * sz);
+	if (!pfds || !fdmap) {
 		ast_log(LOG_ERROR, "Out of memory\n");
 		*outfd = -1;
 		return NULL;
@@ -1554,15 +1519,6 @@
 	/* Perform any pending masquerades */
 	for (x=0; x < n; x++) {
 		ast_mutex_lock(&c[x]->lock);
-		if (c[x]->whentohangup) {
-			if (!havewhen)
-				time(&now);
-			diff = c[x]->whentohangup - now;
-			if (!havewhen || (diff < whentohangup)) {
-				havewhen++;
-				whentohangup = diff;
-			}
-		}
 		if (c[x]->masq) {
 			if (ast_do_masquerade(c[x])) {
 				ast_log(LOG_WARNING, "Masquerade failed\n");
@@ -1571,40 +1527,52 @@
 				return NULL;
 			}
 		}
+		if (c[x]->whentohangup) {
+			if (!whentohangup)
+				time(&now);
+			diff = c[x]->whentohangup - now;
+			if (diff < 1) {
+				/* Should already be hungup */
+				c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT;
+				ast_mutex_unlock(&c[x]->lock);
+				return c[x];
+			}
+			if (!whentohangup || (diff < whentohangup))
+				whentohangup = diff;
+		}
 		ast_mutex_unlock(&c[x]->lock);
 	}
-
+	/* Wait full interval */
 	rms = *ms;
-	
-	if (havewhen) {
-		if ((*ms < 0) || (whentohangup * 1000 < *ms)) {
-			rms =  whentohangup * 1000;
-		}
-	}
+	if (whentohangup) {
+		rms = (whentohangup - now) * 1000;	/* timeout in milliseconds */
+		if (*ms >= 0 && *ms < rms)		/* original *ms still smaller */
+			rms =  *ms;
+	}
+	/*
+	 * Build the pollfd array, putting the channels' fds first,
+	 * followed by individual fds. Order is important because
+	 * individual fd's must have priority over channel fds.
+	 */
 	max = 0;
-	for (x=0; x < n; x++) {
-		for (y=0; y< AST_MAX_FDS; y++) {
-			if (c[x]->fds[y] > -1) {
-				pfds[max].fd = c[x]->fds[y];
-				pfds[max].events = POLLIN | POLLPRI;
-				pfds[max].revents = 0;
-				max++;
-			}
+	for (x=0; x<n; x++) {
+		for (y=0; y<AST_MAX_FDS; y++) {
+			fdmap[max].fdno = y;  /* fd y is linked to this pfds */
+			fdmap[max].chan = x;  /* channel x is linked to this pfds */
+			max += ast_add_fd(&pfds[max], c[x]->fds[y]);
 		}
 		CHECK_BLOCKING(c[x]);
 	}
-	for (x=0; x < nfds; x++) {
-		if (fds[x] > -1) {
-			pfds[max].fd = fds[x];
-			pfds[max].events = POLLIN | POLLPRI;

[... 9693 lines stripped ...]


More information about the asterisk-commits mailing list