[svn-commits] branch jcollie/vcard r36193 - in /team/jcollie/vcard: ./ channels/ channels/m...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Wed Jun 28 08:53:32 MST 2006


Author: jcollie
Date: Wed Jun 28 10:53:32 2006
New Revision: 36193

URL: http://svn.digium.com/view/asterisk?rev=36193&view=rev
Log:
Merged revisions 36171,36173,36175-36182,36188,36190-36192 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r36171 | oej | 2006-06-27 05:54:57 -0500 (Tue, 27 Jun 2006) | 3 lines

Don't change direction of the dialogue when we send a re-invite
(will confuse to/from headers and to/from tags)

........
r36173 | crichter | 2006-06-27 06:28:48 -0500 (Tue, 27 Jun 2006) | 1 line

fixes segfault on incoming call which is disconnected in Alerting state
........
r36175 | mogorman | 2006-06-27 09:07:24 -0500 (Tue, 27 Jun 2006) | 3 lines

dont copy an id or a message if they dont exist.


........
r36176 | tilghman | 2006-06-27 10:53:27 -0500 (Tue, 27 Jun 2006) | 2 lines

Missing parenthesis

........
r36177 | oej | 2006-06-27 12:30:14 -0500 (Tue, 27 Jun 2006) | 3 lines

Inspired by issue 6742, but solved in a different way.
(Yes, I like the system name setting)

........
r36178 | oej | 2006-06-27 13:00:09 -0500 (Tue, 27 Jun 2006) | 3 lines

issue #7033 - Don't burst pokes to peers at load or reload.
Open for a cool algorithm to space them out...

........
r36179 | jcollie | 2006-06-27 13:49:04 -0500 (Tue, 27 Jun 2006) | 1 line

menuselect writes both menuselect.makeopts and menuselect.makedeps at once, make sure that the Makefile knows about that.
........
r36180 | oej | 2006-06-27 14:28:04 -0500 (Tue, 27 Jun 2006) | 2 lines

Formatting and doxygen fixes

........
r36181 | oej | 2006-06-27 15:52:52 -0500 (Tue, 27 Jun 2006) | 3 lines

Code cleanup while trying to understand this channel...
- please check

........
r36182 | oej | 2006-06-27 15:54:06 -0500 (Tue, 27 Jun 2006) | 2 lines

Don't delete initid scheduled item twice... Thanks, vecher, for bugging me about this.

........
r36188 | crichter | 2006-06-28 09:15:29 -0500 (Wed, 28 Jun 2006) | 1 line

fixed a few state problems when hanging up the call. also changed a few debug messages to higher log level
........
r36190 | crichter | 2006-06-28 09:24:18 -0500 (Wed, 28 Jun 2006) | 1 line

moved a notice into a log
........
r36191 | oej | 2006-06-28 10:05:06 -0500 (Wed, 28 Jun 2006) | 2 lines

Block patch to 1.2 that was by mistake committed to trunk first...

........
r36192 | russell | 2006-06-28 10:10:57 -0500 (Wed, 28 Jun 2006) | 4 lines

fix the case where menuselect.makeopts is getting generated in the same run of
"make" as the current build and some of the MENUELSELECT_CFLAGS are set in the
user or global level asterisk.makeopts file

........

Modified:
    team/jcollie/vcard/   (props changed)
    team/jcollie/vcard/Makefile
    team/jcollie/vcard/channels/chan_agent.c
    team/jcollie/vcard/channels/chan_misdn.c
    team/jcollie/vcard/channels/chan_sip.c
    team/jcollie/vcard/channels/misdn/isdn_lib.c
    team/jcollie/vcard/doc/extconfig.txt
    team/jcollie/vcard/doc/realtime.txt
    team/jcollie/vcard/res/res_jabber.c

Propchange: team/jcollie/vcard/
------------------------------------------------------------------------------
Binary property 'branch-1.2-blocked' - no diff available.

Propchange: team/jcollie/vcard/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Jun 28 10:53:32 2006
@@ -1,1 +1,1 @@
-/trunk:1-36154
+/trunk:1-36192

Modified: team/jcollie/vcard/Makefile
URL: http://svn.digium.com/view/asterisk/team/jcollie/vcard/Makefile?rev=36193&r1=36192&r2=36193&view=diff
==============================================================================
--- team/jcollie/vcard/Makefile (original)
+++ team/jcollie/vcard/Makefile Wed Jun 28 10:53:32 2006
@@ -132,6 +132,10 @@
 MOD_SUBDIR_CFLAGS=-I../include -I..
 OTHER_SUBDIR_CFLAGS=-I../include -I..
 
+ifeq ($(origin MENUSELECT_CFLAGS),undefined)
+  MENUSELECT_CFLAGS:=$(shell echo $(or $(shell grep MENUSELECT_CFLAGS $(USER_MAKEOPTS) .),$(shell grep MENUSELECT_CFLAGS $(GLOBAL_MAKEOPTS) .)) | cut -f2 -d'=')
+endif
+
 ifeq ($(or $(findstring dont-optimize,$(MAKECMDGOALS)),$(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS))),)
 # More GSM codec optimization
 # Uncomment to enable MMXTM optimizations for x86 architecture CPU's
@@ -390,11 +394,8 @@
 	@echo "****"
 	@exit 1
 
-menuselect.makeopts: menuselect/menuselect makeopts.xml
-	@menuselect/menuselect --check-deps ${GLOBAL_MAKEOPTS} ${USER_MAKEOPTS} $@
-
-menuselect.makedeps: menuselect/menuselect makeopts.xml
-	@menuselect/menuselect --check-deps ${GLOBAL_MAKEOPTS} ${USER_MAKEOPTS} $@
+menuselect.makeopts menuselect.makedeps: menuselect/menuselect makeopts.xml
+	menuselect/menuselect --check-deps ${GLOBAL_MAKEOPTS} ${USER_MAKEOPTS} menuselect.makeopts
 
 #ifneq ($(wildcard tags),)
 ctags: tags

Modified: team/jcollie/vcard/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/vcard/channels/chan_agent.c?rev=36193&r1=36192&r2=36193&view=diff
==============================================================================
--- team/jcollie/vcard/channels/chan_agent.c (original)
+++ team/jcollie/vcard/channels/chan_agent.c Wed Jun 28 10:53:32 2006
@@ -171,7 +171,7 @@
 
 #define GETAGENTBYCALLERID	"AGENTBYCALLERID"
 
-/*! \brief * Structure representing an agent.  */
+/*! \brief Structure representing an agent.  */
 struct agent_pvt {
 	ast_mutex_t lock;              /*!< Channel private lock */
 	int dead;                      /*!< Poised for destruction? */
@@ -368,7 +368,7 @@
  * Deletes an agent after doing some clean up.
  * Further documentation: How safe is this function ? What state should the agent be to be cleaned.
  * \param p Agent to be deleted.
- * @returns Always 0.
+ * \returns Always 0.
  */
 static int agent_cleanup(struct agent_pvt *p)
 {
@@ -653,16 +653,20 @@
 		return res;
 	}
 	ast_verbose( VERBOSE_PREFIX_3 "agent_call, call to agent '%s' call on '%s'\n", p->agent, p->chan->name);
-	ast_log( LOG_DEBUG, "Playing beep, lang '%s'\n", p->chan->language);
+	if (option_debug > 2)
+		ast_log(LOG_DEBUG, "Playing beep, lang '%s'\n", p->chan->language);
 	res = ast_streamfile(p->chan, beep, p->chan->language);
-	ast_log( LOG_DEBUG, "Played beep, result '%d'\n", res);
+	if (option_debug > 2)
+		ast_log(LOG_DEBUG, "Played beep, result '%d'\n", res);
 	if (!res) {
 		res = ast_waitstream(p->chan, "");
-		ast_log( LOG_DEBUG, "Waited for stream, result '%d'\n", res);
+		if (option_debug > 2)
+			ast_log(LOG_DEBUG, "Waited for stream, result '%d'\n", res);
 	}
 	if (!res) {
 		res = ast_set_read_format(p->chan, ast_best_codec(p->chan->nativeformats));
-		ast_log( LOG_DEBUG, "Set read format, result '%d'\n", res);
+		if (option_debug > 2)
+			ast_log(LOG_DEBUG, "Set read format, result '%d'\n", res);
 		if (res)
 			ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats)));
 	} else {
@@ -671,32 +675,32 @@
 	}
 
 	if (!res) {
-		ast_set_write_format(p->chan, ast_best_codec(p->chan->nativeformats));
-		ast_log( LOG_DEBUG, "Set write format, result '%d'\n", res);
+		res = ast_set_write_format(p->chan, ast_best_codec(p->chan->nativeformats));
+		if (option_debug > 2)
+			ast_log(LOG_DEBUG, "Set write format, result '%d'\n", res);
 		if (res)
 			ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats)));
 	}
-	if( !res )
-	{
+	if(!res) {
 		/* Call is immediately up, or might need ack */
 		if (p->ackcall > 1)
 			newstate = AST_STATE_RINGING;
 		else {
 			newstate = AST_STATE_UP;
 			if (recordagentcalls)
-				agent_start_monitoring(ast,0);
+				agent_start_monitoring(ast, 0);
 			p->acknowledged = 1;
 		}
 		res = 0;
 	}
-	CLEANUP(ast,p);
+	CLEANUP(ast, p);
 	ast_mutex_unlock(&p->lock);
 	if (newstate)
 		ast_setstate(ast, newstate);
 	return res;
 }
 
-/* store/clear the global variable that stores agentid based on the callerid */
+/*! \brief store/clear the global variable that stores agentid based on the callerid */
 static void set_agentbycallerid(const char *callerid, const char *agent)
 {
 	char buf[AST_MAX_BUF];
@@ -705,7 +709,7 @@
 	if (ast_strlen_zero(callerid))
 		return;
 
-	snprintf(buf, sizeof(buf), "%s_%s",GETAGENTBYCALLERID, callerid);
+	snprintf(buf, sizeof(buf), "%s_%s", GETAGENTBYCALLERID, callerid);
 	pbx_builtin_setvar_helper(NULL, buf, agent);
 }
 
@@ -730,13 +734,14 @@
 	ast_atomic_fetchadd_int(&__mod_desc->usecnt, -1);
 	/* XXX do we need ast_update_use_count(); */
 
-	ast_log(LOG_DEBUG, "Hangup called for state %s\n", ast_state2str(ast->_state));
+	if (option_debug)
+		ast_log(LOG_DEBUG, "Hangup called for state %s\n", ast_state2str(ast->_state));
 	if (p->start && (ast->_state != AST_STATE_UP)) {
 		howlong = time(NULL) - p->start;
 		p->start = 0;
-	} else if (ast->_state == AST_STATE_RESERVED) {
+	} else if (ast->_state == AST_STATE_RESERVED) 
 		howlong = 0;
-	} else
+	else
 		p->start = 0; 
 	if (p->chan) {
 		p->chan->_bridge = NULL;
@@ -767,13 +772,13 @@
 				agent_logoff_maintenance(p, p->loginchan, logintime, ast->uniqueid, "Autologoff");
 			}
 		} else if (p->dead) {
-			ast_mutex_lock(&p->chan->lock);
+			ast_channel_lock(p->chan);
 			ast_softhangup(p->chan, AST_SOFTHANGUP_EXPLICIT);
-			ast_mutex_unlock(&p->chan->lock);
+			ast_channel_unlock(p->chan);
 		} else {
-			ast_mutex_lock(&p->chan->lock);
+			ast_channel_lock(p->chan);
 			ast_moh_start(p->chan, p->moh);
-			ast_mutex_unlock(&p->chan->lock);
+			ast_channel_unlock(p->chan);
 		}
 	}
 	ast_mutex_unlock(&p->lock);
@@ -820,14 +825,14 @@
 			res = 1;
 	}
 	ast_mutex_unlock(&p->lock);
-#if 0
-	if( !res )
-		ast_log( LOG_DEBUG, "agent_cont_sleep() returning %d\n", res );
-#endif		
+
+	if(option_debug > 4 && !res )
+		ast_log(LOG_DEBUG, "agent_cont_sleep() returning %d\n", res );
+
 	return res;
 }
 
-static int agent_ack_sleep( void *data )
+static int agent_ack_sleep(void *data)
 {
 	struct agent_pvt *p;
 	int res=0;
@@ -836,50 +841,42 @@
 
 	/* Wait a second and look for something */
 
-	p = (struct agent_pvt *)data;
-	if (p->chan) {
-		for(;;) {
-			to = ast_waitfor(p->chan, to);
-			if (to < 0) {
-				res = -1;
-				break;
-			}
-			if (!to) {
-				res = 0;
-				break;
-			}
-			f = ast_read(p->chan);
-			if (!f) {
-				res = -1;
-				break;
-			}
-			if (f->frametype == AST_FRAME_DTMF)
-				res = f->subclass;
-			else
-				res = 0;
-			ast_frfree(f);
-			ast_mutex_lock(&p->lock);
-			if (!p->app_sleep_cond) {
-				ast_mutex_unlock(&p->lock);
-				res = 0;
-				break;
-			} else if (res == '#') {
-				ast_mutex_unlock(&p->lock);
-				res = 1;
-				break;
-			}
+	p = (struct agent_pvt *) data;
+	if (!p->chan) 
+		return -1;
+
+	for(;;) {
+		to = ast_waitfor(p->chan, to);
+		if (to < 0) 
+			return -1;
+		if (!to) 
+			return 0;
+		f = ast_read(p->chan);
+		if (!f) 
+			return -1;
+		if (f->frametype == AST_FRAME_DTMF)
+			res = f->subclass;
+		else
+			res = 0;
+		ast_frfree(f);
+		ast_mutex_lock(&p->lock);
+		if (!p->app_sleep_cond) {
 			ast_mutex_unlock(&p->lock);
-			res = 0;
-		}
-	} else
-		res = -1;
+			return 0;
+		} else if (res == '#') {
+			ast_mutex_unlock(&p->lock);
+			return 1;
+		}
+		ast_mutex_unlock(&p->lock);
+		res = 0;
+	}
 	return res;
 }
 
 static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge)
 {
 	struct agent_pvt *p = bridge->tech_pvt;
-	struct ast_channel *ret=NULL;
+	struct ast_channel *ret = NULL;
 
 	if (p) {
 		if (chan == p->chan)
@@ -893,7 +890,7 @@
 	return ret;
 }
 
-/*! \brief Create new agent channel ---*/
+/*! \brief Create new agent channel */
 static struct ast_channel *agent_new(struct agent_pvt *p, int state)
 {
 	struct ast_channel *tmp;
@@ -904,74 +901,74 @@
 	}
 #endif	
 	tmp = ast_channel_alloc(0);
-	if (tmp) {
-		tmp->tech = &agent_tech;
+	if (!tmp) {
+		ast_log(LOG_WARNING, "Unable to allocate agent channel structure\n");
+		return NULL;
+	}
+
+	tmp->tech = &agent_tech;
+	if (p->chan) {
+		tmp->nativeformats = p->chan->nativeformats;
+		tmp->writeformat = p->chan->writeformat;
+		tmp->rawwriteformat = p->chan->writeformat;
+		tmp->readformat = p->chan->readformat;
+		tmp->rawreadformat = p->chan->readformat;
+		ast_string_field_set(tmp, language, p->chan->language);
+		ast_copy_string(tmp->context, p->chan->context, sizeof(tmp->context));
+		ast_copy_string(tmp->exten, p->chan->exten, sizeof(tmp->exten));
+		/* XXX Is this really all we copy form the originating channel?? */
+	} else {
+		tmp->nativeformats = AST_FORMAT_SLINEAR;
+		tmp->writeformat = AST_FORMAT_SLINEAR;
+		tmp->rawwriteformat = AST_FORMAT_SLINEAR;
+		tmp->readformat = AST_FORMAT_SLINEAR;
+		tmp->rawreadformat = AST_FORMAT_SLINEAR;
+	}
+	if (p->pending)
+		ast_string_field_build(tmp, name, "Agent/P%s-%d", p->agent, ast_random() & 0xffff);
+	else
+		ast_string_field_build(tmp, name, "Agent/%s", p->agent);
+	/* Safe, agentlock already held */
+	ast_setstate(tmp, state);
+	tmp->tech_pvt = p;
+	p->owner = tmp;
+	ast_atomic_fetchadd_int(&__mod_desc->usecnt, +1);
+	ast_update_use_count();
+	tmp->priority = 1;
+	/* Wake up and wait for other applications (by definition the login app)
+	 * to release this channel). Takes ownership of the agent channel
+	 * to this thread only.
+	 * For signalling the other thread, ast_queue_frame is used until we
+	 * can safely use signals for this purpose. The pselect() needs to be
+	 * implemented in the kernel for this.
+	 */
+	p->app_sleep_cond = 0;
+	if(ast_mutex_trylock(&p->app_lock)) {
 		if (p->chan) {
-			tmp->nativeformats = p->chan->nativeformats;
-			tmp->writeformat = p->chan->writeformat;
-			tmp->rawwriteformat = p->chan->writeformat;
-			tmp->readformat = p->chan->readformat;
-			tmp->rawreadformat = p->chan->readformat;
-			ast_string_field_set(tmp, language, p->chan->language);
-			ast_copy_string(tmp->context, p->chan->context, sizeof(tmp->context));
-			ast_copy_string(tmp->exten, p->chan->exten, sizeof(tmp->exten));
+			ast_queue_frame(p->chan, &ast_null_frame);
+			ast_mutex_unlock(&p->lock);	/* For other thread to read the condition. */
+			ast_mutex_lock(&p->app_lock);
+			ast_mutex_lock(&p->lock);
 		} else {
-			tmp->nativeformats = AST_FORMAT_SLINEAR;
-			tmp->writeformat = AST_FORMAT_SLINEAR;
-			tmp->rawwriteformat = AST_FORMAT_SLINEAR;
-			tmp->readformat = AST_FORMAT_SLINEAR;
-			tmp->rawreadformat = AST_FORMAT_SLINEAR;
-		}
-		if (p->pending)
-			ast_string_field_build(tmp, name, "Agent/P%s-%d", p->agent, ast_random() & 0xffff);
-		else
-			ast_string_field_build(tmp, name, "Agent/%s", p->agent);
-		/* Safe, agentlock already held */
-		ast_setstate(tmp, state);
-		tmp->tech_pvt = p;
-		p->owner = tmp;
-		ast_atomic_fetchadd_int(&__mod_desc->usecnt, +1);
-		ast_update_use_count();
-		tmp->priority = 1;
-		/* Wake up and wait for other applications (by definition the login app)
-		 * to release this channel). Takes ownership of the agent channel
-		 * to this thread only.
-		 * For signalling the other thread, ast_queue_frame is used until we
-		 * can safely use signals for this purpose. The pselect() needs to be
-		 * implemented in the kernel for this.
-		 */
-		p->app_sleep_cond = 0;
-		if( ast_mutex_trylock(&p->app_lock) )
-		{
-			if (p->chan) {
-				ast_queue_frame(p->chan, &ast_null_frame);
-				ast_mutex_unlock(&p->lock);	/* For other thread to read the condition. */
-				ast_mutex_lock(&p->app_lock);
-				ast_mutex_lock(&p->lock);
-			}
-			if( !p->chan )
-			{
-				ast_log(LOG_WARNING, "Agent disconnected while we were connecting the call\n");
-				p->owner = NULL;
-				tmp->tech_pvt = NULL;
-				p->app_sleep_cond = 1;
-				ast_channel_free( tmp );
-				ast_mutex_unlock(&p->lock);	/* For other thread to read the condition. */
-				ast_mutex_unlock(&p->app_lock);
-				return NULL;
-			}
-		}
-		p->owning_app = pthread_self();
-		/* After the above step, there should not be any blockers. */
-		if (p->chan) {
-			if (ast_test_flag(p->chan, AST_FLAG_BLOCKING)) {
-				ast_log( LOG_ERROR, "A blocker exists after agent channel ownership acquired\n" );
-				CRASH;
-			}
-			ast_moh_stop(p->chan);
-		}
-	} else
-		ast_log(LOG_WARNING, "Unable to allocate agent channel structure\n");
+			ast_log(LOG_WARNING, "Agent disconnected while we were connecting the call\n");
+			p->owner = NULL;
+			tmp->tech_pvt = NULL;
+			p->app_sleep_cond = 1;
+			ast_channel_free( tmp );
+			ast_mutex_unlock(&p->lock);	/* For other thread to read the condition. */
+			ast_mutex_unlock(&p->app_lock);
+			return NULL;
+		}
+	}
+	p->owning_app = pthread_self();
+	/* After the above step, there should not be any blockers. */
+	if (p->chan) {
+		if (ast_test_flag(p->chan, AST_FLAG_BLOCKING)) {
+			ast_log( LOG_ERROR, "A blocker exists after agent channel ownership acquired\n" );
+			CRASH;
+		}
+		ast_moh_stop(p->chan);
+	}
 	return tmp;
 }
 
@@ -979,7 +976,7 @@
 /*!
  * Read configuration data. The file named agents.conf.
  *
- * @returns Always 0, or so it seems.
+ * \returns Always 0, or so it seems.
  */
 static int read_agent_config(void)
 {
@@ -1013,10 +1010,7 @@
 	/* Read in [general] section for persistence */
 	if ((general_val = ast_variable_retrieve(cfg, "general", "persistentagents")))
 		persistent_agents = ast_true(general_val);
-	if (ast_false(ast_variable_retrieve(cfg, "general", "multiplelogin") ) ) 
-		multiplelogin=0;
-	if (ast_true(ast_variable_retrieve(cfg, "general", "multiplelogin") ) )
-		multiplelogin=1;
+	multiplelogin = ast_true(ast_variable_retrieve(cfg, "general", "multiplelogin"));
 
 	/* Read in the [agents] section */
 	v = ast_variable_browse(cfg, "agents");
@@ -1221,16 +1215,17 @@
 }
 
 /* return 1 if multiple login is fine, 0 if it is not and we find a match, -1 if multiplelogin is not allowed and we don't find a match. */
-static int allow_multiple_login(char *chan,char *context)
+static int allow_multiple_login(char *chan, char *context)
 {
 	struct agent_pvt *p;
 	char loginchan[80];
+
 	if(multiplelogin)
 		return 1;
 	if(!chan) 
 		return 0;
 
-	snprintf(loginchan, sizeof(loginchan), "%s@%s", chan, S_OR(context,"default"));
+	snprintf(loginchan, sizeof(loginchan), "%s@%s", chan, S_OR(context, "default"));
 	
 	AST_LIST_TRAVERSE(&agents, p, list) {
 		if(!strcasecmp(chan, p->loginchan))
@@ -1239,7 +1234,7 @@
 	return -1;
 }
 
-/*! \brief Part of the Asterisk PBX interface ---*/
+/*! \brief Part of the Asterisk PBX interface */
 static struct ast_channel *agent_request(const char *type, int format, void *data, int *cause)
 {
 	struct agent_pvt *p;
@@ -1257,9 +1252,8 @@
 	} else if ((s[0] == ':') && (sscanf(s + 1, "%d", &groupoff) == 1)) {
 		groupmatch = (1 << groupoff);
 		waitforagent = 1;
-	} else {
+	} else 
 		groupmatch = 0;
-	}
 
 	/* Check actual logged in agents first */
 	AST_LIST_LOCK(&agents);
@@ -1324,16 +1318,12 @@
 			p = add_agent(data, 1);
 			p->group = groupmatch;
 			chan = agent_new(p, AST_STATE_DOWN);
-			if (!chan) {
+			if (!chan) 
 				ast_log(LOG_WARNING, "Weird...  Fix this to drop the unused pending agent\n");
-			}
 		} else
 			ast_log(LOG_DEBUG, "Not creating place holder for '%s' since nobody logged in\n", s);
 	}
-	if (hasagent)
-		*cause = AST_CAUSE_BUSY;
-	else
-		*cause = AST_CAUSE_UNREGISTERED;
+	*cause = hasagent ? AST_CAUSE_BUSY : AST_CAUSE_UNREGISTERED;
 	AST_LIST_UNLOCK(&agents);
 	return chan;
 }
@@ -1353,7 +1343,7 @@
  * It is registered on load_module() and it gets called by the manager backend.
  * \param s
  * \param m
- * @returns 
+ * \returns 
  * \sa action_agent_logoff(), action_agent_callback_login(), load_module().
  */
 static int action_agents(struct mansession *s, struct message *m)
@@ -1380,11 +1370,7 @@
 		   AGENT_ONCALL    - Agent is logged in, and on a call
 		   AGENT_UNKNOWN   - Don't know anything about agent. Shouldn't ever get this. */
 
-		if(!ast_strlen_zero(p->name)) {
-			username = p->name;
-		} else {
-			username = "None";
-		}
+		username = S_OR(p->name, "None");
 
 		/* Set a default status. It 'should' get changed. */
 		status = "AGENT_UNKNOWN";
@@ -1438,9 +1424,9 @@
 
 	if (!ast_strlen_zero(logcommand))
 		tmp = logcommand;
-	else {
+	else
 		tmp = ast_strdupa("");
-	}
+
 	snprintf(agent, sizeof(agent), "Agent/%s", p->agent);
 
 	if (!ast_strlen_zero(uniqueid)) {
@@ -1451,7 +1437,6 @@
 				"Logintime: %ld\r\n"
 				"Uniqueid: %s\r\n", 
 				p->agent, tmp, loginchan, logintime, uniqueid);
-				ast_queue_log("NONE", uniqueid, agent, "AGENTCALLBACKLOGOFF", "%s|%ld|%s", loginchan, logintime, tmp);
 	} else {
 		manager_event(EVENT_FLAG_AGENT, "Agentcallbacklogoff",
 				"Agent: %s\r\n"
@@ -1459,10 +1444,9 @@
 				"Loginchan: %s\r\n"
 				"Logintime: %ld\r\n",
 				p->agent, tmp, loginchan, logintime);
-				ast_queue_log("NONE", "NONE", agent, "AGENTCALLBACKLOGOFF", "%s|%ld|%s", loginchan, logintime, tmp);
-	}
-
-
+	}
+
+	ast_queue_log("NONE", ast_strlen_zero(uniqueid) ? "NONE" : uniqueid, agent, "AGENTCALLBACKLOGOFF", "%s|%ld|%s", loginchan, logintime, tmp);
 	set_agentbycallerid(p->logincallerid, NULL);
 	p->loginchan[0] ='\0';
 	p->logincallerid[0] = '\0';
@@ -1481,12 +1465,10 @@
 	AST_LIST_TRAVERSE(&agents, p, list) {
 		if (!strcasecmp(p->agent, agent)) {
 			if (!soft) {
-				if (p->owner) {
+				if (p->owner)
 					ast_softhangup(p->owner, AST_SOFTHANGUP_EXPLICIT);
-				}
-				if (p->chan) {
+				if (p->chan) 
 					ast_softhangup(p->chan, AST_SOFTHANGUP_EXPLICIT);
-				}
 			}
 			ret = 0; /* found an agent => return 0 */
 			logintime = time(NULL) - p->loginstart;
@@ -1522,7 +1504,7 @@
  * It is registered on load_module() and it gets called by the manager backend.
  * \param s
  * \param m
- * @returns 
+ * \returns 
  * \sa action_agents(), action_agent_callback_login(), load_module().
  */
 static int action_agent_logoff(struct mansession *s, struct message *m)
@@ -1537,11 +1519,7 @@
 		return 0;
 	}
 
-	if (ast_true(soft_s))
-		soft = 1;
-	else
-		soft = 0;
-
+	soft = ast_true(soft_s) ? 1 : 0;
 	ret = agent_logoff(agent, soft);
 	if (ret == 0)
 		astman_send_ack(s, m, "Agent logged out");
@@ -1563,9 +1541,9 @@
 			if (!strncasecmp(word, name, len) && ++which > state)
 				return ast_strdup(name);
 		}
-	} else if (pos == 3 && state == 0) {
+	} else if (pos == 3 && state == 0) 
 		return ast_strdup("soft");
-	}
+	
 	return NULL;
 }
 
@@ -1579,9 +1557,9 @@
 	char location[AST_MAX_BUF] = "";
 	char talkingto[AST_MAX_BUF] = "";
 	char moh[AST_MAX_BUF];
-	int count_agents = 0;		/* Number of agents configured */
-	int online_agents = 0;		/* Number of online agents */
-	int offline_agents = 0;		/* Number of offline agents */
+	int count_agents = 0;		/*!< Number of agents configured */
+	int online_agents = 0;		/*!< Number of online agents */
+	int offline_agents = 0;		/*!< Number of offline agents */
 	if (argc != 2)
 		return RESULT_SHOWUSAGE;
 	AST_LIST_LOCK(&agents);
@@ -1599,11 +1577,10 @@
 				username[0] = '\0';
 			if (p->chan) {
 				snprintf(location, sizeof(location), "logged in on %s", p->chan->name);
-				if (p->owner && ast_bridged_channel(p->owner)) {
+				if (p->owner && ast_bridged_channel(p->owner))
 					snprintf(talkingto, sizeof(talkingto), " talking to %s", ast_bridged_channel(p->owner)->name);
-				} else {
+				 else 
 					strcpy(talkingto, " is idle");
-				}
 				online_agents++;
 			} else if (!ast_strlen_zero(p->loginchan)) {
 				if (ast_tvdiff_ms(ast_tvnow(), p->lastdisc) > 0 || !(p->lastdisc.tv_sec)) 
@@ -1628,11 +1605,10 @@
 		ast_mutex_unlock(&p->lock);
 	}
 	AST_LIST_UNLOCK(&agents);
-	if ( !count_agents ) {
+	if ( !count_agents ) 
 		ast_cli(fd, "No Agents are configured in %s\n",config);
-	} else {
+	else 
 		ast_cli(fd, "%d agents configured [%d online , %d offline]\n",count_agents, online_agents, offline_agents);
-	}
 	ast_cli(fd, "\n");
 	                
 	return RESULT_SUCCESS;
@@ -1661,11 +1637,10 @@
 			username[0] = '\0';
 		if (p->chan) {
 			snprintf(location, sizeof(location), "logged in on %s", p->chan->name);
-			if (p->owner && ast_bridged_channel(p->owner)) {
+			if (p->owner && ast_bridged_channel(p->owner)) 
 				snprintf(talkingto, sizeof(talkingto), " talking to %s", ast_bridged_channel(p->owner)->name);
-			} else {
+			else 
 				strcpy(talkingto, " is idle");
-			}
 			agent_status = 1;
 			online_agents++;
 		} else if (!ast_strlen_zero(p->loginchan)) {
@@ -1684,10 +1659,10 @@
 		ast_mutex_unlock(&p->lock);
 	}
 	AST_LIST_UNLOCK(&agents);
-	if ( !count_agents ) 
-		ast_cli(fd, "No Agents are configured in %s\n",config);
+	if (!count_agents) 
+		ast_cli(fd, "No Agents are configured in %s\n", config);
 	else
-		ast_cli(fd, "%d agents online\n",online_agents);
+		ast_cli(fd, "%d agents online\n", online_agents);
 	ast_cli(fd, "\n");
 	return RESULT_SUCCESS;
 }
@@ -2010,8 +1985,7 @@
 						if (option_verbose > 1)
 							ast_verbose(VERBOSE_PREFIX_2 "Agent '%s' logged in (format %s/%s)\n", p->agent,
 								    ast_getformatname(chan->readformat), ast_getformatname(chan->writeformat));
-						/* Login this channel and wait for it to
-						   go away */
+						/* Login this channel and wait for it to go away */
 						p->chan = chan;
 						if (p->ackcall > 1)
 							check_beep(p, 0);
@@ -2053,8 +2027,7 @@
 							if (p->ackcall > 1) 
 								res = agent_ack_sleep(p);
 							else
-								res = ast_safe_sleep_conditional( chan, 1000,
-												  agent_cont_sleep, p );
+								res = ast_safe_sleep_conditional( chan, 1000, agent_cont_sleep, p );
 							ast_mutex_unlock( &p->app_lock );
 							if ((p->ackcall > 1)  && (res == 1)) {
 								AST_LIST_LOCK(&agents);
@@ -2120,21 +2093,16 @@
 	if (!callbackmode) {
 		LOCAL_USER_REMOVE(u);
 		return -1;
-	}
-	/* AgentCallbackLogin() exit*/
-	else {
+	} else { /* AgentCallbackLogin() exit*/
 		/* Set variables */
 		if (login_state > 0) {
 			pbx_builtin_setvar_helper(chan, "AGENTNUMBER", user);
 			if (login_state==1) {
 				pbx_builtin_setvar_helper(chan, "AGENTSTATUS", "on");
 				pbx_builtin_setvar_helper(chan, "AGENTEXTEN", args.extension);
-			}
-			else {
+			} else 
 				pbx_builtin_setvar_helper(chan, "AGENTSTATUS", "off");
-			}
-		}
-		else {
+		} else {
 			pbx_builtin_setvar_helper(chan, "AGENTSTATUS", "fail");
 		}
 		if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 1, chan->cid.cid_num)) {
@@ -2164,7 +2132,7 @@
  * 
  * \param chan
  * \param data
- * @returns
+ * \returns
  * \sa callback_login_exec(), agentmonitoroutgoing_exec(), load_module().
  */
 static int login_exec(struct ast_channel *chan, void *data)
@@ -2177,7 +2145,7 @@
  * 
  * \param chan
  * \param data
- * @returns
+ * \returns
  * \sa login_exec(), agentmonitoroutgoing_exec(), load_module().
  */
 static int callback_exec(struct ast_channel *chan, void *data)
@@ -2190,7 +2158,7 @@
  * It is registered on load_module() and it gets called by the manager backend.
  * \param s
  * \param m
- * @returns 
+ * \returns 
  * \sa action_agents(), action_agent_logoff(), load_module().
  */
 static int action_agent_callback_login(struct mansession *s, struct message *m)
@@ -2215,9 +2183,8 @@
 
 	AST_LIST_LOCK(&agents);
 	AST_LIST_TRAVERSE(&agents, p, list) {
-		if (strcmp(p->agent, agent) || p->pending) {
+		if (strcmp(p->agent, agent) || p->pending) 
 			continue;
-		}
 		if (p->chan) {
 			login_state = 2; /* already logged in (and on the phone)*/
 			break;
@@ -2325,8 +2292,7 @@
 			chan->priority+=100;
 			if (option_verbose > 2)
 				ast_verbose(VERBOSE_PREFIX_3 "Going to %d priority because there is no callerid or the agentid cannot be found.\n",chan->priority);
-		}
-		else if (exitifnoagentid)
+		} else if (exitifnoagentid)
 			return res;
 	}
 	return 0;
@@ -2389,7 +2355,7 @@
 			ast_mutex_unlock(&cur_agent->lock);
 		if (!ast_db_get(pa_family, agent_num, agent_data, sizeof(agent_data)-1)) {
 			if (option_debug)
-				ast_log(LOG_DEBUG, "Reload Agent: %s on %s\n", cur_agent->agent, agent_data);
+				ast_log(LOG_DEBUG, "Reload Agent from AstDB: %s on %s\n", cur_agent->agent, agent_data);
 			parse = agent_data;
 			agent_chan = strsep(&parse, ";");
 			agent_callerid = strsep(&parse, ";");
@@ -2422,14 +2388,13 @@
 	int res = AST_DEVICE_INVALID;
 	
 	s = data;
-	if ((s[0] == '@') && (sscanf(s + 1, "%d", &groupoff) == 1)) {
+	if ((s[0] == '@') && (sscanf(s + 1, "%d", &groupoff) == 1))
 		groupmatch = (1 << groupoff);
-	} else if ((s[0] == ':') && (sscanf(s + 1, "%d", &groupoff) == 1)) {
+	else if ((s[0] == ':') && (sscanf(s + 1, "%d", &groupoff) == 1)) {
 		groupmatch = (1 << groupoff);
 		waitforagent = 1;
-	} else {
+	} else 
 		groupmatch = 0;
-	}
 
 	/* Check actual logged in agents first */
 	AST_LIST_LOCK(&agents);
@@ -2504,22 +2469,21 @@
 		if (agent->chan || !ast_strlen_zero(agent->loginchan)) 
 			status = "LOGGEDIN";	
 		ast_copy_string(buf, status, len);
-	} else if (!strcasecmp(args.item, "password")) {
+	} else if (!strcasecmp(args.item, "password")) 
 		ast_copy_string(buf, agent->password, len);
-	} else if (!strcasecmp(args.item, "name")) {
+	else if (!strcasecmp(args.item, "name"))
 		ast_copy_string(buf, agent->name, len);
-	} else if (!strcasecmp(args.item, "mohclass")) {
+	else if (!strcasecmp(args.item, "mohclass"))
 		ast_copy_string(buf, agent->moh, len);
-	} else if (!strcasecmp(args.item, "channel")) {
+	else if (!strcasecmp(args.item, "channel")) {
 		if (agent->chan) {
 			ast_copy_string(buf, agent->chan->name, len);
 			tmp = strrchr(buf, '-');
 			if (tmp)
 				*tmp = '\0';
 		} 
-	} else if (!strcasecmp(args.item, "exten")) {
+	} else if (!strcasecmp(args.item, "exten"))
 		ast_copy_string(buf, agent->loginchan, len);	
-	}
 
 	return 0;
 }

Modified: team/jcollie/vcard/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/vcard/channels/chan_misdn.c?rev=36193&r1=36192&r2=36193&view=diff
==============================================================================
--- team/jcollie/vcard/channels/chan_misdn.c (original)
+++ team/jcollie/vcard/channels/chan_misdn.c Wed Jun 28 10:53:32 2006
@@ -2087,6 +2087,8 @@
 				misdn_lib_send_event(bc, EVENT_DISCONNECT);
 			}
 		}
+
+		p->state=MISDN_CLEANING;
     
 	}
 	
@@ -2899,13 +2901,6 @@
 		release_unlock;
 		
 		chan_misdn_log(1, bc->port, "release_chan: bc with l3id: %x\n",bc->l3_id);
-#if 0
-		if (ch->dummy) {
-			ast_hangup(ast);
-			ch->ast=NULL;
-			ast=NULL;
-		}
-#endif
 		
 		/*releaseing jitterbuffer*/
 		if (ch->jb ) {
@@ -2927,6 +2922,7 @@
 			
 			close(ch->pipe[0]);
 			close(ch->pipe[1]);
+
 			
 			if (ast && MISDN_ASTERISK_TECH_PVT(ast)) {
 				chan_misdn_log(1, bc->port, "* RELEASING CHANNEL pid:%d ctx:%s dad:%s oad:%s state: %s\n",bc?bc->pid:-1, ast->context, ast->exten,AST_CID_P(ast),misdn_get_ch_state(ch));
@@ -2957,8 +2953,6 @@
 				case MISDN_PROCEEDING:
 					chan_misdn_log(2,  bc->port, "* --> In State Dialin\n");
 					chan_misdn_log(2,  bc->port, "* --> Queue Hangup\n");
-					
-					ch->state=MISDN_CLEANING;
 					ast_queue_hangup(ast);
 					
 					break;
@@ -2992,6 +2986,7 @@
 					}
 				}
 			}
+			ch->state=MISDN_CLEANING;
 			cl_dequeue_chan(&cl_te, ch);
 			
 			free(ch);
@@ -3185,14 +3180,19 @@
 		ch=find_chan_by_l3id(cl_te, bc->l3_id);
 	
 	if (event != EVENT_BCHAN_DATA && event != EVENT_TONE_GENERATE) { /*  Debug Only Non-Bchan */
-		chan_misdn_log(1, bc->port, "I IND :%s oad:%s dad:%s pid:%d\n", manager_isdn_get_info(event), bc->oad, bc->dad, bc->pid);
+		chan_misdn_log(1, bc->port, "I IND :%s oad:%s dad:%s pid:%d state:%s\n", manager_isdn_get_info(event), bc->oad, bc->dad, bc->pid, ch?misdn_get_ch_state(ch):"none");
 		misdn_lib_log_ies(bc);
 		chan_misdn_log(2,bc->port," --> bc_state:%s\n",bc_state2str(bc->bc_state));
 	}
 	
 	if (event != EVENT_SETUP) {
 		if (!ch) {
-			if (event != EVENT_CLEANUP )
+			if (event == EVENT_RELEASE_COMPLETE) {
+				chan_misdn_log(1, bc->port, " --> no Ch, so we've already released.\n");
+				return 0;
+			}
+		
+			if (event != EVENT_CLEANUP && event != EVENT_TONE_GENERATE && event != EVENT_BCHAN_DATA)
 				ast_log(LOG_NOTICE, "Chan not existing at the moment bc->l3id:%x bc:%p event:%s port:%d channel:%d\n",bc->l3_id, bc, manager_isdn_get_info( event), bc->port,bc->channel);
 			return -1;
 		}
@@ -3711,7 +3711,8 @@
 			   dialled number, or perhaps even giving an
 			   alternative number, then play it instead of
 			   immediately releasing the call */
-			chan_misdn_log(0,bc->port, " --> Inband Info Avail, not sending RELEASE\n");
+			chan_misdn_log(1,bc->port, " --> Inband Info Avail, not sending RELEASE\n");
+		
 			ch->state=MISDN_DISCONNECTED;
 			start_bc_tones(ch);
 			break;
@@ -3729,6 +3730,7 @@
 		stop_bc_tones(ch);
 		bc->out_cause=-1;
 		
+		release_chan(bc);
 		misdn_lib_send_event(bc,EVENT_RELEASE);
 	}
 	break;
@@ -3747,6 +3749,8 @@
 				*/
 				
 				/*return RESPONSE_OK;*/
+				if (!bc->nt) release_chan(bc);
+
 				break;
 			}
 			
@@ -3764,6 +3768,7 @@
 		break;
 	case EVENT_RELEASE_COMPLETE:
 	{
+		ch->state=MISDN_CLEANING;
 		stop_bc_tones(ch);
 		release_chan(bc);
 	}

Modified: team/jcollie/vcard/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/vcard/channels/chan_sip.c?rev=36193&r1=36192&r2=36193&view=diff
==============================================================================
--- team/jcollie/vcard/channels/chan_sip.c (original)
+++ team/jcollie/vcard/channels/chan_sip.c Wed Jun 28 10:53:32 2006
@@ -828,9 +828,9 @@
 	char referred_by[AST_MAX_EXTENSION];		/*!< Place to store REFERRED-BY extension */
 	char referred_by_name[AST_MAX_EXTENSION];	/*!< Place to store REFERRED-BY extension */
 	char refer_contact[AST_MAX_EXTENSION];		/*!< Place to store Contact info from a REFER extension */
-	char replaces_callid[BUFSIZ];			/*!< Replace info */
-	char replaces_callid_totag[BUFSIZ/2];		/*!< Replace info */
-	char replaces_callid_fromtag[BUFSIZ/2];		/*!< Replace info */
+	char replaces_callid[BUFSIZ];			/*!< Replace info: callid */
+	char replaces_callid_totag[BUFSIZ/2];		/*!< Replace info: to-tag */
+	char replaces_callid_fromtag[BUFSIZ/2];		/*!< Replace info: from-tag */
 	struct sip_pvt *refer_call;			/*!< Call we are referring */
 	int attendedtransfer;				/*!< Attended or blind transfer? */
 	int localtransfer;				/*!< Transfer to local domain? */
@@ -871,15 +871,14 @@
 		AST_STRING_FIELD(okcontacturi);	/*!< URI from the 200 OK on INVITE */
 		AST_STRING_FIELD(peersecret);	/*!< Password */
 		AST_STRING_FIELD(peermd5secret);
-		AST_STRING_FIELD(cid_num);	/*!< Caller*ID */
-		AST_STRING_FIELD(cid_name);	/*!< Caller*ID */
+		AST_STRING_FIELD(cid_num);	/*!< Caller*ID number */
+		AST_STRING_FIELD(cid_name);	/*!< Caller*ID name */
 		AST_STRING_FIELD(via);		/*!< Via: header */
 		AST_STRING_FIELD(fullcontact);	/*!< The Contact: that the UA registers with us */
 		AST_STRING_FIELD(our_contact);	/*!< Our contact header */
 		AST_STRING_FIELD(rpid);		/*!< Our RPID header */
 		AST_STRING_FIELD(rpid_from);	/*!< Our RPID From header */
 	);
-	struct ast_codec_pref prefs;		/*!< codec prefs */
 	unsigned int ocseq;			/*!< Current outgoing seqno */
 	unsigned int icseq;			/*!< Current incoming seqno */
 	ast_group_t callgroup;			/*!< Call group */
@@ -887,7 +886,8 @@
 	int lastinvite;				/*!< Last Cseq of invite */
 	struct ast_flags flags[2];		/*!< SIP_ flags */
 	int timer_t1;				/*!< SIP timer T1, ms rtt */
-	unsigned int sipoptions;		/*!< Supported SIP sipoptions on the other end */
+	unsigned int sipoptions;		/*!< Supported SIP options on the other end */
+	struct ast_codec_pref prefs;		/*!< codec prefs */
 	int capability;				/*!< Special capability (codec) */
 	int jointcapability;			/*!< Supported capability at both ends (codecs ) */
 	int peercapability;			/*!< Supported peer capability */
@@ -901,40 +901,40 @@
 	int callingpres;			/*!< Calling presentation */
 	int authtries;				/*!< Times we've tried to authenticate */
 	int expiry;				/*!< How long we take to expire */
-	long branch;				/*!< One random number */
-	char tag[11];				/*!< Another random number */
+	long branch;				/*!< The branch identifier of this session */
+	char tag[11];				/*!< Our tag for this session */
 	int sessionid;				/*!< SDP Session ID */
 	int sessionversion;			/*!< SDP Session Version */
 	struct sockaddr_in sa;			/*!< Our peer */
 	struct sockaddr_in redirip;		/*!< Where our RTP should be going if not to us */
 	struct sockaddr_in vredirip;		/*!< Where our Video RTP should be going if not to us */
+	time_t lastrtprx;			/*!< Last RTP received */
+	time_t lastrtptx;			/*!< Last RTP sent */
+	int rtptimeout;				/*!< RTP timeout time */
+	int rtpholdtimeout;			/*!< RTP timeout when on hold */
+	int rtpkeepalive;			/*!< Send RTP packets for keepalive */
 	struct sockaddr_in recv;		/*!< Received as */
 	struct in_addr ourip;			/*!< Our IP */
-	struct ast_channel *owner;		/*!< Who owns us */
+	struct ast_channel *owner;		/*!< Who owns us (if we have an owner) */
 	struct sip_route *route;		/*!< Head of linked list of routing steps (fm Record-Route) */
 	int route_persistant;			/*!< Is this the "real" route? */
 	struct sip_auth *peerauth;		/*!< Realm authentication */
 	int noncecount;				/*!< Nonce-count */
 	char lastmsg[256];			/*!< Last Message sent/received */
 	int amaflags;				/*!< AMA Flags */
-	int pendinginvite;			/*!< Any pending invite */
+	int pendinginvite;			/*!< Any pending invite ? (seqno of this) */
 	struct sip_request initreq;		/*!< Initial request that opened the SIP dialog */
 	
 	int maxtime;				/*!< Max time for first response */
-	int initid;				/*!< Auto-congest ID if appropriate */
-	int autokillid;				/*!< Auto-kill ID */
-	time_t lastrtprx;			/*!< Last RTP received */
-	time_t lastrtptx;			/*!< Last RTP sent */
-	int rtptimeout;				/*!< RTP timeout time */
-	int rtpholdtimeout;			/*!< RTP timeout when on hold */
-	int rtpkeepalive;			/*!< Send RTP packets for keepalive */
-	enum transfermodes allowtransfer;	/*! SIP Refer restriction scheme */
+	int initid;				/*!< Auto-congest ID if appropriate (scheduler) */
+	int autokillid;				/*!< Auto-kill ID (scheduler) */
+	enum transfermodes allowtransfer;	/*!< REFER: restriction scheme */
+	struct sip_refer *refer;		/*!< REFER: SIP transfer data structure */
 	enum subscriptiontype subscribed;	/*!< SUBSCRIBE: Is this dialog a subscription?  */
 	int stateid;				/*!< SUBSCRIBE: ID for devicestate subscriptions */
 	int laststate;				/*!< SUBSCRIBE: Last known extension state */
 	int dialogver;				/*!< SUBSCRIBE: Version for subscription dialog-info */
 	
-	struct sip_refer *refer;		/*!< REFER: SIP transfer data structure */
 	struct ast_dsp *vad;			/*!< Voice Activation Detection dsp */
 	
 	struct sip_peer *relatedpeer;		/*!< If this dialog is related to a peer, which one 
@@ -2175,12 +2175,20 @@
 	return 0;	
 }
 
-/*! \brief Update peer object in realtime storage */
+/*! \brief Update peer object in realtime storage 
+	If the Asterisk system name is set in asterisk.conf, we will use
+	that name and store that in the "regserver" field in the sippeers
+	table to facilitate multi-server setups.
+*/
 static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *username, const char *fullcontact, int expirey)
 {
 	char port[10];
 	char ipaddr[20];
 	char regseconds[20];
+
+	char *sysname = ast_config_AST_SYSTEM_NAME;
+	char *syslabel = NULL;
+
 	time_t nowtime = time(NULL) + expirey;
 	const char *fc = fullcontact ? "fullcontact" : NULL;
 	
@@ -2188,9 +2196,14 @@
 	ast_inet_ntoa(ipaddr, sizeof(ipaddr), sin->sin_addr);
 	snprintf(port, sizeof(port), "%d", ntohs(sin->sin_port));
 	
+	if (ast_strlen_zero(sysname))	/* No system name, disable this */
+		sysname = NULL;
+	else
+		syslabel = "regserver";
+
 	ast_update_realtime("sippeers", "name", peername, "ipaddr", ipaddr,
 		"port", port, "regseconds", regseconds,
-		"username", username, fc, fullcontact, NULL); /* note fc _can_ be NULL */
+		"username", username, fc, fullcontact, syslabel, sysname, NULL); /* note fc _can_ be NULL */
 }
 
 /*! \brief Automatically add peer extension to dial plan */
@@ -2236,9 +2249,8 @@
 	if (peer->call)
 		sip_destroy(peer->call);
 
-	if (peer->mwipvt) {	/* We have an active subscription, delete it */

[... 188 lines stripped ...]


More information about the svn-commits mailing list