[asterisk-commits] bebuild: tag 10.6.0-digiumphones-rc2 r369689 - in /tags/10.6.0-digiumphones-r...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jul 5 18:06:36 CDT 2012


Author: bebuild
Date: Thu Jul  5 18:06:32 2012
New Revision: 369689

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=369689
Log:
Commit changes for 10.6.0-digiumphones-rc2

ASTERISK-19905: r368947
ASTERISK-20040: r369215
ASTERISK-19992: r369437,369558,369580,369627
ASTERISK-19923: r369653
ASTERISK-20008: r369067
ASTERISK-20012: r369044

Removed:
    tags/10.6.0-digiumphones-rc2/asterisk-10.6.0-digiumphones-rc1-summary.html
    tags/10.6.0-digiumphones-rc2/asterisk-10.6.0-digiumphones-rc1-summary.txt
Modified:
    tags/10.6.0-digiumphones-rc2/   (props changed)
    tags/10.6.0-digiumphones-rc2/.version
    tags/10.6.0-digiumphones-rc2/ChangeLog
    tags/10.6.0-digiumphones-rc2/apps/app_voicemail.c
    tags/10.6.0-digiumphones-rc2/channels/chan_sip.c
    tags/10.6.0-digiumphones-rc2/channels/chan_skinny.c
    tags/10.6.0-digiumphones-rc2/channels/sip/include/sip.h
    tags/10.6.0-digiumphones-rc2/main/features.c

Propchange: tags/10.6.0-digiumphones-rc2/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Propchange: tags/10.6.0-digiumphones-rc2/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Jul  5 18:06:32 2012
@@ -1,0 +1,1 @@
+/branches/10:368947,369044,369067,369215,369437,369558,369580,369627,369653

Modified: tags/10.6.0-digiumphones-rc2/.version
URL: http://svnview.digium.com/svn/asterisk/tags/10.6.0-digiumphones-rc2/.version?view=diff&rev=369689&r1=369688&r2=369689
==============================================================================
--- tags/10.6.0-digiumphones-rc2/.version (original)
+++ tags/10.6.0-digiumphones-rc2/.version Thu Jul  5 18:06:32 2012
@@ -1,1 +1,1 @@
-10.6.0-digiumphones-rc1
+10.6.0-digiumphones-rc2

Modified: tags/10.6.0-digiumphones-rc2/ChangeLog
URL: http://svnview.digium.com/svn/asterisk/tags/10.6.0-digiumphones-rc2/ChangeLog?view=diff&rev=369689&r1=369688&r2=369689
==============================================================================
--- tags/10.6.0-digiumphones-rc2/ChangeLog (original)
+++ tags/10.6.0-digiumphones-rc2/ChangeLog Thu Jul  5 18:06:32 2012
@@ -1,3 +1,39 @@
+2012-07-06  Asterisk Development Team <asteriskteam at digium.com>
+
+	* Asterisk 10.6.0-digiumphones-rc2 Released.
+
+	* AST-2012-009
+
+	* AST-2012-010
+
+	* AST-2012-011
+
+	* Fix crash on a guest directmedia call
+
+	  A sip_pvt may not have relatedpeer set if a call doesn't match up
+	  with a peer.  If there is no relatedpeer, there is no direct media
+	  ACL to apply, so just return that is is allowed.
+
+	  (closes issue ASTERISK-20040)
+	
+	* Fix request routing issue when outboundproxy is used
+
+	  Asterisk was incorrectly setting the destination of CANCELs and ACKs
+	  for error responses to the URI of the initial INVITE.  This resulted
+	  in further requests, such as INVITEs with authentication
+	  credentials, to be routed incorrectly.  Instead when these CANCEL or
+	  ACKs are to be esnt, we should simply keep the destination the same
+	  as what it previously was.  There is no need to alter it any.
+
+	  (closes issue ASTERISK-20008)
+	
+	* Fix monitoring calls put in a parking lot
+
+	  Fix a regression that was introduced by r366167 which effectively
+	  disabled monitoring parked calls.
+
+	  (closes issue ASTERISK-20012)
+
 2012-06-12  Asterisk Development Team <asteriskteam at digium.com>
 
 	* 10.6.0-digiumphones-rc1 Released.

Modified: tags/10.6.0-digiumphones-rc2/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/tags/10.6.0-digiumphones-rc2/apps/app_voicemail.c?view=diff&rev=369689&r1=369688&r2=369689
==============================================================================
--- tags/10.6.0-digiumphones-rc2/apps/app_voicemail.c (original)
+++ tags/10.6.0-digiumphones-rc2/apps/app_voicemail.c Thu Jul  5 18:06:32 2012
@@ -1787,24 +1787,27 @@
 static int vm_allocate_dh(struct vm_state *vms, struct ast_vm_user *vmu, int count_msg) {
 
 	int arraysize = (vmu->maxmsg > count_msg ? vmu->maxmsg : count_msg);
-	if (!vms->dh_arraysize) {
-		/* initial allocation */
+
+	/* remove old allocation */
+	if (vms->deleted) {
+		ast_free(vms->deleted);
+		vms->deleted = NULL;
+	}
+	if (vms->heard) {
+		ast_free(vms->heard);
+		vms->heard = NULL;
+	}
+	vms->dh_arraysize = 0;
+
+	if (arraysize > 0) {
 		if (!(vms->deleted = ast_calloc(arraysize, sizeof(int)))) {
 			return -1;
 		}
 		if (!(vms->heard = ast_calloc(arraysize, sizeof(int)))) {
+			ast_free(vms->deleted);
+			vms->deleted = NULL;
 			return -1;
 		}
-		vms->dh_arraysize = arraysize;
-	} else if (vms->dh_arraysize < arraysize) {
-		if (!(vms->deleted = ast_realloc(vms->deleted, arraysize * sizeof(int)))) {
-			return -1;
-		}
-		if (!(vms->heard = ast_realloc(vms->heard, arraysize * sizeof(int)))) {
-			return -1;
-		}
-		memset(vms->deleted, 0, arraysize * sizeof(int));
-		memset(vms->heard, 0, arraysize * sizeof(int));
 		vms->dh_arraysize = arraysize;
 	}
 
@@ -6899,13 +6902,20 @@
 		ast_callerid_parse(cid, &name, &num);
 		if (!name)
 			name = num;
-	} else
+	} else {
 		name = "Unknown Caller";
+	}
 
 	/* If deleted, show "undeleted" */
-
-	if (vms->deleted[vms->curmsg])
+#ifdef IMAP_STORAGE
+	ast_mutex_lock(&vms->lock);
+#endif
+	if (vms->deleted[vms->curmsg]) {
 		keys[1] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 11);
+	}
+#ifdef IMAP_STORAGE
+	ast_mutex_unlock(&vms->lock);
+#endif
 
 	/* Except "Exit" */
 	keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 5);
@@ -6958,8 +6968,15 @@
 	}
 
 	/* If deleted, show "undeleted" */
-	if (vms->deleted[vms->curmsg]) 
+#ifdef IMAP_STORAGE
+	ast_mutex_lock(&vms->lock);
+#endif
+	if (vms->deleted[vms->curmsg]) {
 		keys[1] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 11);
+	}
+#ifdef IMAP_STORAGE
+	ast_mutex_unlock(&vms->lock);
+#endif
 
 	/* Except "Exit" */
 	keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 5);
@@ -8140,8 +8157,12 @@
 
 	if (!res) {
 		make_file(vms->fn, sizeof(vms->fn), vms->curdir, vms->curmsg);
+#ifdef IMAP_STORAGE
+		ast_mutex_lock(&vms->lock);
+#endif
 		vms->heard[vms->curmsg] = 1;
 #ifdef IMAP_STORAGE
+		ast_mutex_unlock(&vms->lock);
 		/*IMAP storage stores any prepended message from a forward
 		 * as a separate file from the rest of the message
 		 */
@@ -8356,6 +8377,7 @@
 	}
 	ast_unlock_path(vms->curdir);
 #else /* defined(IMAP_STORAGE) */
+	ast_mutex_lock(&vms->lock);
 	if (vms->deleted) {
 		/* Since we now expunge after each delete, deleting in reverse order
 		 * ensures that no reordering occurs between each step. */
@@ -8370,12 +8392,18 @@
 #endif
 
 done:
-	if (vms->deleted && last_msg_idx) {
+	if (vms->deleted) {
 		ast_free(vms->deleted);
-	}
-	if (vms->heard && last_msg_idx) {
+		vms->deleted = NULL;
+	}
+	if (vms->heard) {
 		ast_free(vms->heard);
-	}
+		vms->heard = NULL;
+	}
+	vms->dh_arraysize = 0;
+#ifdef IMAP_STORAGE
+	ast_mutex_unlock(&vms->lock);
+#endif
 
 	return 0;
 }
@@ -9470,14 +9498,25 @@
 				res = ast_play_and_wait(chan, "vm-next");
 			}
 			if (!res) {
-				if (!vms->deleted[vms->curmsg])
+				int curmsg_deleted;
+#ifdef IMAP_STORAGE
+				ast_mutex_lock(&vms->lock);
+#endif
+				curmsg_deleted = vms->deleted[vms->curmsg];
+#ifdef IMAP_STORAGE
+				ast_mutex_unlock(&vms->lock);
+#endif
+				if (!curmsg_deleted) {
 					res = ast_play_and_wait(chan, "vm-delete");
-				else
+				} else {
 					res = ast_play_and_wait(chan, "vm-undelete");
-				if (!res)
+				}
+				if (!res) {
 					res = ast_play_and_wait(chan, "vm-toforward");
-				if (!res)
+				}
+				if (!res) {
 					res = ast_play_and_wait(chan, "vm-savemessage");
+				}
 			}
 		}
 		if (!res) {
@@ -10673,6 +10712,7 @@
 			}
 
 			vms.starting = 1;
+			vms.curmsg = 0;
 			break;
 		case '3': /* Advanced options */
 			ast_test_suite_event_notify("ADVOPTIONS", "Message: entering advanced options menu");

Modified: tags/10.6.0-digiumphones-rc2/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/tags/10.6.0-digiumphones-rc2/channels/chan_sip.c?view=diff&rev=369689&r1=369688&r2=369689
==============================================================================
--- tags/10.6.0-digiumphones-rc2/channels/chan_sip.c (original)
+++ tags/10.6.0-digiumphones-rc2/channels/chan_sip.c Thu Jul  5 18:06:32 2012
@@ -3897,7 +3897,7 @@
 			ast_debug(3, "Re-scheduled destruction of SIP call %s\n", p->callid ? p->callid : "<unknown>");
 			append_history(p, "ReliableXmit", "timeout");
 			if (sscanf(p->lastmsg, "Tx: %30s", method_str) == 1 || sscanf(p->lastmsg, "Rx: %30s", method_str) == 1) {
-				if (method_match(SIP_CANCEL, method_str) || method_match(SIP_BYE, method_str)) {
+				if (p->ongoing_reinvite || method_match(SIP_CANCEL, method_str) || method_match(SIP_BYE, method_str)) {
 					pvt_set_needdestroy(p, "autodestruct");
 				}
 			}
@@ -6293,6 +6293,21 @@
 	return 0;
 }
 
+static int reinvite_timeout(const void *data)
+{
+	struct sip_pvt *dialog = (struct sip_pvt *) data;
+	struct ast_channel *owner = sip_pvt_lock_full(dialog);
+	dialog->reinviteid = -1;
+	check_pendings(dialog);
+	if (owner) {
+		ast_channel_unlock(owner);
+		ast_channel_unref(owner);
+	}
+	ao2_unlock(dialog);
+	dialog_unref(dialog, "unref for reinvite timeout");
+	return 0;
+}
+
 /*! \brief  sip_hangup: Hangup SIP call
  * Part of PBX interface, called from ast_hangup */
 static int sip_hangup(struct ast_channel *ast)
@@ -6487,8 +6502,16 @@
 				ast_set_flag(&p->flags[0], SIP_PENDINGBYE);	
 				ast_clear_flag(&p->flags[0], SIP_NEEDREINVITE);	
 				AST_SCHED_DEL_UNREF(sched, p->waitid, dialog_unref(p, "when you delete the waitid sched, you should dec the refcount for the stored dialog ptr"));
-				if (sip_cancel_destroy(p))
+				if (sip_cancel_destroy(p)) {
 					ast_log(LOG_WARNING, "Unable to cancel SIP destruction.  Expect bad things.\n");
+				}
+				/* If we have an ongoing reinvite, there is a chance that we have gotten a provisional
+				 * response, but something weird has happened and we will never receive a final response.
+				 * So, just in case, check for pending actions after a bit of time to trigger the pending
+				 * bye that we are setting above */
+				if (p->ongoing_reinvite && p->reinviteid < 0) {
+					p->reinviteid = ast_sched_add(sched, 32 * p->timer_t1, reinvite_timeout, dialog_ref(p, "ref for reinvite_timeout"));
+				}
 			}
 		}
 	}
@@ -7871,6 +7894,7 @@
 	p->method = intended_method;
 	p->initid = -1;
 	p->waitid = -1;
+	p->reinviteid = -1;
 	p->autokillid = -1;
 	p->request_queue_sched_id = -1;
 	p->provisional_keepalive_sched_id = -1;
@@ -10737,10 +10761,9 @@
 	 * final response. For a CANCEL or ACK, we have to send to the same destination
 	 * as the original INVITE.
 	 */
-	if (sipmethod == SIP_CANCEL ||
-			(sipmethod == SIP_ACK && (p->invitestate == INV_COMPLETED || p->invitestate == INV_CANCELLED))) {
-		set_destination(p, ast_strdupa(p->uri));
-	} else if (p->route) {
+	if (p->route &&
+			!(sipmethod == SIP_CANCEL ||
+				(sipmethod == SIP_ACK && (p->invitestate == INV_COMPLETED || p->invitestate == INV_CANCELLED)))) {
 		set_destination(p, p->route->hop);
 		add_route(req, is_strict ? p->route->next : p->route);
 	}
@@ -12358,7 +12381,7 @@
 	initialize_initreq(p, &req);
 	p->lastinvite = p->ocseq;
 	ast_set_flag(&p->flags[0], SIP_OUTGOING);       /* Change direction of this dialog */
-
+	p->ongoing_reinvite = 1;
 	return send_request(p, &req, XMIT_CRITICAL, p->ocseq);
 }
 
@@ -20587,8 +20610,11 @@
 static void check_pendings(struct sip_pvt *p)
 {
 	if (ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
-		/* if we can't BYE, then this is really a pending CANCEL */
-		if (p->invitestate == INV_PROCEEDING || p->invitestate == INV_EARLY_MEDIA) {
+		if (p->reinviteid > -1) {
+			/* Outstanding p->reinviteid timeout, so wait... */
+			return;
+		} else if (p->invitestate == INV_PROCEEDING || p->invitestate == INV_EARLY_MEDIA) {
+			/* if we can't BYE, then this is really a pending CANCEL */
 			p->invitestate = INV_CANCELLED;
 			transmit_request(p, SIP_CANCEL, p->lastinvite, XMIT_RELIABLE, FALSE);
 			/* If the cancel occurred on an initial invite, cancel the pending BYE */
@@ -20599,8 +20625,9 @@
 			   INVITE, but do set an autodestruct just in case we never get it. */
 		} else {
 			/* We have a pending outbound invite, don't send something
-				new in-transaction */
-			if (p->pendinginvite)
+			 * new in-transaction, unless it is a pending reinvite, then
+			 * by the time we are called here, we should probably just hang up. */
+			if (p->pendinginvite && !p->ongoing_reinvite)
 				return;
 
 			if (p->owner) {
@@ -20810,9 +20837,17 @@
  	if (resp >= 300 && (p->invitestate == INV_CALLING || p->invitestate == INV_PROCEEDING || p->invitestate == INV_EARLY_MEDIA ))
  		p->invitestate = INV_COMPLETED;
  	
+	if ((resp >= 200 && reinvite)) {
+		p->ongoing_reinvite = 0;
+		if (p->reinviteid > -1) {
+			AST_SCHED_DEL_UNREF(sched, p->reinviteid, dialog_unref(p, "unref dialog for reinvite timeout because of a final response"));
+		}
+	}
+
 	/* Final response, clear out pending invite */
-	if ((resp == 200 || resp >= 300) && p->pendinginvite && seqno == p->pendinginvite)
+	if ((resp == 200 || resp >= 300) && p->pendinginvite && seqno == p->pendinginvite) {
 		p->pendinginvite = 0;
+	}
 
 	/* If this is a response to our initial INVITE, we need to set what we can use
 	 * for this peer.
@@ -30216,6 +30251,12 @@
 	ast_rtp_instance_get_remote_address(p1->rtp, &them);
 	ast_rtp_instance_get_local_address(p1->rtp, &us);
 
+	/* If p2 is a guest call, there will be no peer. If there is no peer, there
+	 * is no directmediaha, so go ahead and allow it */
+	if (!p2->relatedpeer) {
+		return res;
+	}
+
 	if ((res = ast_apply_ha(p2->relatedpeer->directmediaha, &them)) == AST_SENSE_DENY) {
 		const char *us_addr = ast_strdupa(ast_sockaddr_stringify(&us));
 		const char *them_addr = ast_strdupa(ast_sockaddr_stringify(&them));

Modified: tags/10.6.0-digiumphones-rc2/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/tags/10.6.0-digiumphones-rc2/channels/chan_skinny.c?view=diff&rev=369689&r1=369688&r2=369689
==============================================================================
--- tags/10.6.0-digiumphones-rc2/channels/chan_skinny.c (original)
+++ tags/10.6.0-digiumphones-rc2/channels/chan_skinny.c Thu Jul  5 18:06:32 2012
@@ -4982,6 +4982,11 @@
 	pthread_t t;
 	int actualstate = state;
 
+	if (!l->device) {
+		ast_log(LOG_WARNING, "Device for line %s is not registered.\n", l->name);
+		return;
+	}
+
 	if (sub->substate == SUBSTATE_ONHOOK) {
 		return;
 	}
@@ -5374,15 +5379,20 @@
 	struct skinny_subchannel *activatesub = NULL;
 	struct skinny_subchannel *tsub;
 
+	if (!l->device) {
+		ast_log(LOG_WARNING, "Device for line %s is not registered.\n", l->name);
+		return;
+	}
+
 	if (skinnydebug) {
 		ast_verb(3, "Sub %d - Dumping\n", sub->callid);
 	}
-	
+
 	if (!forcehangup && sub->substate == SUBSTATE_HOLD) {
 		l->activesub = NULL;
 		return;
 	}
-	
+
 	if (sub == l->activesub) {
 		d->hookstate = SKINNY_ONHOOK;
 		transmit_speaker_mode(d, SKINNY_SPEAKEROFF); 

Modified: tags/10.6.0-digiumphones-rc2/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/tags/10.6.0-digiumphones-rc2/channels/sip/include/sip.h?view=diff&rev=369689&r1=369688&r2=369689
==============================================================================
--- tags/10.6.0-digiumphones-rc2/channels/sip/include/sip.h (original)
+++ tags/10.6.0-digiumphones-rc2/channels/sip/include/sip.h Thu Jul  5 18:06:32 2012
@@ -1101,6 +1101,7 @@
 	struct sip_auth_container *peerauth;/*!< Realm authentication credentials */
 	int noncecount;                     /*!< Nonce-count */
 	unsigned int stalenonce:1;          /*!< Marks the current nonce as responded too */
+	unsigned int ongoing_reinvite:1;    /*!< There is a reinvite in progress that might need to be cleaned up */
 	char lastmsg[256];                  /*!< Last Message sent/received */
 	int amaflags;                       /*!< AMA Flags */
 	uint32_t pendinginvite; /*!< Any pending INVITE or state NOTIFY (in subscribe pvt's) ? (seqno of this) */
@@ -1113,6 +1114,7 @@
 
 	int initid;                         /*!< Auto-congest ID if appropriate (scheduler) */
 	int waitid;                         /*!< Wait ID for scheduler after 491 or other delays */
+	int reinviteid;                     /*!< Reinvite in case of provisional, but no final response */
 	int autokillid;                     /*!< Auto-kill ID (scheduler) */
 	int t38id;                          /*!< T.38 Response ID */
 	struct sip_refer *refer;            /*!< REFER: SIP transfer data structure */

Modified: tags/10.6.0-digiumphones-rc2/main/features.c
URL: http://svnview.digium.com/svn/asterisk/tags/10.6.0-digiumphones-rc2/main/features.c?view=diff&rev=369689&r1=369688&r2=369689
==============================================================================
--- tags/10.6.0-digiumphones-rc2/main/features.c (original)
+++ tags/10.6.0-digiumphones-rc2/main/features.c Thu Jul  5 18:06:32 2012
@@ -4631,7 +4631,6 @@
 	struct ast_channel *chan = pu->chan;	/* shorthand */
 	int tms;        /* timeout for this item */
 	int x;          /* fd index in channel */
-	int parking_complete = 0;
 
 	tms = ast_tvdiff_ms(ast_tvnow(), pu->start);
 	if (tms > pu->parkingtime) {
@@ -4746,104 +4745,103 @@
 		}
 
 		/* And take them out of the parking lot */
-		parking_complete = 1;
-	} else {	/* still within parking time, process descriptors */
-		x = 0;
-		if (pfds) {
-			for (; x < AST_MAX_FDS; x++) {
-				struct ast_frame *f;
-				int y;
-
-				if (chan->fds[x] == -1) {
-					continue;	/* nothing on this descriptor */
+		return 1;
+	}
+
+	/* still within parking time, process descriptors */
+	if (pfds) {
+		for (x = 0; x < AST_MAX_FDS; x++) {
+			struct ast_frame *f;
+			int y;
+
+			if (chan->fds[x] == -1) {
+				continue;	/* nothing on this descriptor */
+			}
+
+			for (y = 0; y < nfds; y++) {
+				if (pfds[y].fd == chan->fds[x]) {
+					/* Found poll record! */
+					break;
 				}
-
-				for (y = 0; y < nfds; y++) {
-					if (pfds[y].fd == chan->fds[x]) {
-						/* Found poll record! */
-						break;
-					}
+			}
+			if (y == nfds) {
+				/* Not found */
+				continue;
+			}
+
+			if (!(pfds[y].revents & (POLLIN | POLLERR | POLLPRI))) {
+				/* Next x */
+				continue;
+			}
+
+			if (pfds[y].revents & POLLPRI) {
+				ast_set_flag(chan, AST_FLAG_EXCEPTION);
+			} else {
+				ast_clear_flag(chan, AST_FLAG_EXCEPTION);
+			}
+			chan->fdno = x;
+
+			/* See if they need servicing */
+			f = ast_read(pu->chan);
+			/* Hangup? */
+			if (!f || (f->frametype == AST_FRAME_CONTROL
+				&& f->subclass.integer == AST_CONTROL_HANGUP)) {
+				if (f) {
+					ast_frfree(f);
 				}
-				if (y == nfds) {
-					/* Not found */
-					continue;
+				post_manager_event("ParkedCallGiveUp", pu);
+				ast_cel_report_event(pu->chan, AST_CEL_PARK_END, NULL, "ParkedCallGiveUp",
+					NULL);
+
+				/* There's a problem, hang them up */
+				ast_verb(2, "%s got tired of being parked\n", chan->name);
+				ast_hangup(chan);
+
+				/* And take them out of the parking lot */
+				return 1;
+			} else {
+				/* XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */
+				ast_frfree(f);
+				if (pu->hold_method == AST_CONTROL_HOLD
+					&& pu->moh_trys < 3
+					&& !chan->generatordata) {
+					ast_debug(1,
+						"MOH on parked call stopped by outside source.  Restarting on channel %s.\n",
+						chan->name);
+					ast_indicate_data(chan, AST_CONTROL_HOLD,
+						S_OR(pu->parkinglot->cfg.mohclass, NULL),
+						(!ast_strlen_zero(pu->parkinglot->cfg.mohclass)
+							? strlen(pu->parkinglot->cfg.mohclass) + 1 : 0));
+					pu->moh_trys++;
 				}
-
-				if (!(pfds[y].revents & (POLLIN | POLLERR | POLLPRI))) {
-					/* Next x */
-					continue;
-				}
-
-				if (pfds[y].revents & POLLPRI) {
-					ast_set_flag(chan, AST_FLAG_EXCEPTION);
-				} else {
-					ast_clear_flag(chan, AST_FLAG_EXCEPTION);
-				}
-				chan->fdno = x;
-
-				/* See if they need servicing */
-				f = ast_read(pu->chan);
-				/* Hangup? */
-				if (!f || (f->frametype == AST_FRAME_CONTROL
-					&& f->subclass.integer == AST_CONTROL_HANGUP)) {
-					if (f) {
-						ast_frfree(f);
-					}
-					post_manager_event("ParkedCallGiveUp", pu);
-					ast_cel_report_event(pu->chan, AST_CEL_PARK_END, NULL, "ParkedCallGiveUp",
-						NULL);
-
-					/* There's a problem, hang them up */
-					ast_verb(2, "%s got tired of being parked\n", chan->name);
-					ast_hangup(chan);
-
-					/* And take them out of the parking lot */
-					parking_complete = 1;
-					break;
-				} else {
-					/* XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */
-					ast_frfree(f);
-					if (pu->hold_method == AST_CONTROL_HOLD
-						&& pu->moh_trys < 3
-						&& !chan->generatordata) {
-						ast_debug(1,
-							"MOH on parked call stopped by outside source.  Restarting on channel %s.\n",
-							chan->name);
-						ast_indicate_data(chan, AST_CONTROL_HOLD,
-							S_OR(pu->parkinglot->cfg.mohclass, NULL),
-							(!ast_strlen_zero(pu->parkinglot->cfg.mohclass)
-								? strlen(pu->parkinglot->cfg.mohclass) + 1 : 0));
-						pu->moh_trys++;
-					}
-					goto std;	/* XXX Ick: jumping into an else statement??? XXX */
-				}
-			} /* End for */
-		}
-		if (x >= AST_MAX_FDS) {
-std:
-			for (x = 0; x < AST_MAX_FDS; x++) {	/* mark fds for next round */
-				if (chan->fds[x] > -1) {
-					void *tmp = ast_realloc(*new_pfds,
-						(*new_nfds + 1) * sizeof(struct pollfd));
-
-					if (!tmp) {
-						continue;
-					}
-					*new_pfds = tmp;
-					(*new_pfds)[*new_nfds].fd = chan->fds[x];
-					(*new_pfds)[*new_nfds].events = POLLIN | POLLERR | POLLPRI;
-					(*new_pfds)[*new_nfds].revents = 0;
-					(*new_nfds)++;
-				}
-			}
-			/* Keep track of our shortest wait */
-			if (tms < *ms || *ms < 0) {
-				*ms = tms;
-			}
-		}
-	}
-
-	return parking_complete;
+				break;
+			}
+		} /* End for */
+	}
+
+	/* mark fds for next round */
+	for (x = 0; x < AST_MAX_FDS; x++) {
+		if (chan->fds[x] > -1) {
+			void *tmp = ast_realloc(*new_pfds,
+				(*new_nfds + 1) * sizeof(struct pollfd));
+
+			if (!tmp) {
+				continue;
+			}
+			*new_pfds = tmp;
+			(*new_pfds)[*new_nfds].fd = chan->fds[x];
+			(*new_pfds)[*new_nfds].events = POLLIN | POLLERR | POLLPRI;
+			(*new_pfds)[*new_nfds].revents = 0;
+			(*new_nfds)++;
+		}
+	}
+	/* Keep track of our shortest wait */
+	if (tms < *ms || *ms < 0) {
+		*ms = tms;
+	}
+
+	/* Stay in the parking lot. */
+	return 0;
 }
 
 /*! \brief Run management on parkinglots, called once per parkinglot */




More information about the asterisk-commits mailing list