[svn-commits] bebuild: tag 1.8.22.0-rc2 r388195 - in /tags/1.8.22.0-rc2: ./ main/ res/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu May 9 10:26:17 CDT 2013


Author: bebuild
Date: Thu May  9 10:26:14 2013
New Revision: 388195

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388195
Log:
Merge blockers for 1.8.22.0-rc2

(issue ASTERISK-21356)
Merged r386256

(issue ASTERISK-21389)
Merged r386109

(issue ASTERISK-21394)
Merged r387036

(issue ASTERISK-21429)
Merged r385916

Removed:
    tags/1.8.22.0-rc2/asterisk-1.8.22.0-rc2-summary.html
    tags/1.8.22.0-rc2/asterisk-1.8.22.0-rc2-summary.txt
Modified:
    tags/1.8.22.0-rc2/   (props changed)
    tags/1.8.22.0-rc2/main/channel.c
    tags/1.8.22.0-rc2/main/devicestate.c
    tags/1.8.22.0-rc2/main/features.c
    tags/1.8.22.0-rc2/res/res_jabber.c
    tags/1.8.22.0-rc2/res/res_timing_pthread.c

Propchange: tags/1.8.22.0-rc2/
------------------------------------------------------------------------------
    svn:mergeinfo = /branches/1.8:385916,386109,386256,387036

Modified: tags/1.8.22.0-rc2/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/tags/1.8.22.0-rc2/main/channel.c?view=diff&rev=388195&r1=388194&r2=388195
==============================================================================
--- tags/1.8.22.0-rc2/main/channel.c (original)
+++ tags/1.8.22.0-rc2/main/channel.c Thu May  9 10:26:14 2013
@@ -7223,8 +7223,11 @@
 				if (c1->_softhangup & AST_SOFTHANGUP_UNBRIDGE) {
 					ast_channel_clear_softhangup(c1, AST_SOFTHANGUP_UNBRIDGE);
 				}
+				ast_channel_lock_both(c0, c1);
 				c0->_bridge = c1;
 				c1->_bridge = c0;
+				ast_channel_unlock(c0);
+				ast_channel_unlock(c1);
 			}
 			continue;
 		}
@@ -7471,8 +7474,11 @@
 	}
 
 	/* Keep track of bridge */
+	ast_channel_lock_both(c0, c1);
 	c0->_bridge = c1;
 	c1->_bridge = c0;
+	ast_channel_unlock(c0);
+	ast_channel_unlock(c1);
 
 	ast_set_owners_and_peers(c0, c1);
 
@@ -7569,8 +7575,11 @@
 			if (c1->_softhangup & AST_SOFTHANGUP_UNBRIDGE) {
 				ast_channel_clear_softhangup(c1, AST_SOFTHANGUP_UNBRIDGE);
 			}
+			ast_channel_lock_both(c0, c1);
 			c0->_bridge = c1;
 			c1->_bridge = c0;
+			ast_channel_unlock(c0);
+			ast_channel_unlock(c1);
 			ast_debug(1, "Unbridge signal received. Ending native bridge.\n");
 			continue;
 		}
@@ -7627,8 +7636,11 @@
 					continue;
 				}
 
+				ast_channel_lock_both(c0, c1);
 				c0->_bridge = NULL;
 				c1->_bridge = NULL;
+				ast_channel_unlock(c0);
+				ast_channel_unlock(c1);
 				return res;
 			} else {
 				ast_clear_flag(c0, AST_FLAG_NBRIDGE);
@@ -7678,8 +7690,11 @@
 	ast_indicate(c0, AST_CONTROL_SRCUPDATE);
 	ast_indicate(c1, AST_CONTROL_SRCUPDATE);
 
+	ast_channel_lock_both(c0, c1);
 	c0->_bridge = NULL;
 	c1->_bridge = NULL;
+	ast_channel_unlock(c0);
+	ast_channel_unlock(c1);
 
 	ast_manager_event_multichan(EVENT_FLAG_CALL, "Unlink", 2, chans,
 		"Channel1: %s\r\n"

Modified: tags/1.8.22.0-rc2/main/devicestate.c
URL: http://svnview.digium.com/svn/asterisk/tags/1.8.22.0-rc2/main/devicestate.c?view=diff&rev=388195&r1=388194&r2=388195
==============================================================================
--- tags/1.8.22.0-rc2/main/devicestate.c (original)
+++ tags/1.8.22.0-rc2/main/devicestate.c Thu May  9 10:26:14 2013
@@ -705,7 +705,7 @@
 static void devstate_change_collector_cb(const struct ast_event *event, void *data)
 {
 	struct devstate_change *sc;
-	const char *device;
+	const char *device, *cachable_str;
 	const struct ast_eid *eid;
 	uint32_t state;
 	enum ast_devstate_cache cachable = AST_DEVSTATE_CACHABLE;
@@ -713,7 +713,6 @@
 	device = ast_event_get_ie_str(event, AST_EVENT_IE_DEVICE);
 	eid = ast_event_get_ie_raw(event, AST_EVENT_IE_EID);
 	state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
-	cachable = ast_event_get_ie_uint(event, AST_EVENT_IE_CACHABLE);
 
 	if (ast_strlen_zero(device) || !eid) {
 		ast_log(LOG_ERROR, "Invalid device state change event received\n");
@@ -726,6 +725,16 @@
 	strcpy(sc->device, device);
 	sc->eid = *eid;
 	sc->state = state;
+
+	/* For 'cachable' we cannot use ast_event_get_ie_uint(), it overwrites the default of AST_DEVSTATE_CACHABLE we
+	 * have already setup for 'cachable', if for whatever reason the AST_EVENT_IE_CACHABLE wasn't
+	 * posted in the event ast_event_get_ie_uint() is going will return 0,
+	 * which equates to AST_DEVSTATE_NOT_CACHABLE the first enumeration in 'ast_devstate_cache'.
+	 */
+
+	if ((cachable_str = ast_event_get_ie_str(event, AST_EVENT_IE_CACHABLE))) {
+		sscanf(cachable_str, "%30u", &cachable);
+	}
 	sc->cachable = cachable;
 
 	ast_mutex_lock(&devstate_collector.lock);

Modified: tags/1.8.22.0-rc2/main/features.c
URL: http://svnview.digium.com/svn/asterisk/tags/1.8.22.0-rc2/main/features.c?view=diff&rev=388195&r1=388194&r2=388195
==============================================================================
--- tags/1.8.22.0-rc2/main/features.c (original)
+++ tags/1.8.22.0-rc2/main/features.c Thu May  9 10:26:14 2013
@@ -4208,17 +4208,6 @@
 		if (!f || (f->frametype == AST_FRAME_CONTROL &&
 				(f->subclass.integer == AST_CONTROL_HANGUP || f->subclass.integer == AST_CONTROL_BUSY ||
 					f->subclass.integer == AST_CONTROL_CONGESTION))) {
-			/*
-			 * If the bridge was broken for a hangup that isn't real,
-			 * then don't run the h extension, because the channel isn't
-			 * really hung up. This should really only happen with AST_SOFTHANGUP_ASYNCGOTO,
-			 * but it doesn't hurt to check AST_SOFTHANGUP_UNBRIDGE either.
-			 */
-			ast_channel_lock(chan);
-			if (chan->_softhangup & (AST_SOFTHANGUP_ASYNCGOTO | AST_SOFTHANGUP_UNBRIDGE)) {
-				ast_set_flag(chan, AST_FLAG_BRIDGE_HANGUP_DONT);
-			}
-			ast_channel_unlock(chan);
 			res = -1;
 			break;
 		}
@@ -4404,9 +4393,17 @@
 
 	/* run the hangup exten on the chan object IFF it was NOT involved in a parking situation 
 	 * if it were, then chan belongs to a different thread now, and might have been hung up long
-     * ago.
+	 * ago.
 	 */
-	if (ast_test_flag(&config->features_caller, AST_FEATURE_NO_H_EXTEN)) {
+	if (chan->_softhangup & (AST_SOFTHANGUP_ASYNCGOTO | AST_SOFTHANGUP_UNBRIDGE)) {
+		/*
+		 * If the bridge was broken for a hangup that isn't real,
+		 * then don't run the h extension, because the channel isn't
+		 * really hung up. This should really only happen with AST_SOFTHANGUP_ASYNCGOTO,
+		 * but it doesn't hurt to check AST_SOFTHANGUP_UNBRIDGE either.
+		 */
+		h_context = NULL;
+	} else if (ast_test_flag(&config->features_caller, AST_FEATURE_NO_H_EXTEN)) {
 		h_context = NULL;
 	} else if (ast_exists_extension(chan, chan->context, "h", 1,
 		S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {

Modified: tags/1.8.22.0-rc2/res/res_jabber.c
URL: http://svnview.digium.com/svn/asterisk/tags/1.8.22.0-rc2/res/res_jabber.c?view=diff&rev=388195&r1=388194&r2=388195
==============================================================================
--- tags/1.8.22.0-rc2/res/res_jabber.c (original)
+++ tags/1.8.22.0-rc2/res/res_jabber.c Thu May  9 10:26:14 2013
@@ -3280,14 +3280,15 @@
 		return IKS_FILTER_EAT;
 	}
 	if (!strcasecmp(iks_name(item_content), "state")) {
+		if ((cachable_str = iks_find_attrib(item_content, "cachable"))) {
+			sscanf(cachable_str, "%30d", &cachable);
+		}
 		device_state = iks_find_cdata(item, "state");
-		if ((cachable_str = iks_find_cdata(item, "cachable"))) {
-			sscanf(cachable_str, "%30d", &cachable);
-		}
 		if (!(event = ast_event_new(AST_EVENT_DEVICE_STATE_CHANGE,
 					    AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, item_id, AST_EVENT_IE_STATE,
 					    AST_EVENT_IE_PLTYPE_UINT, ast_devstate_val(device_state), AST_EVENT_IE_EID,
 					    AST_EVENT_IE_PLTYPE_RAW, &pubsub_eid, sizeof(pubsub_eid),
+					    AST_EVENT_IE_CACHABLE, AST_EVENT_IE_PLTYPE_UINT, cachable,
 					    AST_EVENT_IE_END))) {
 			return IKS_FILTER_EAT;
 		}

Modified: tags/1.8.22.0-rc2/res/res_timing_pthread.c
URL: http://svnview.digium.com/svn/asterisk/tags/1.8.22.0-rc2/res/res_timing_pthread.c?view=diff&rev=388195&r1=388194&r2=388195
==============================================================================
--- tags/1.8.22.0-rc2/res/res_timing_pthread.c (original)
+++ tags/1.8.22.0-rc2/res/res_timing_pthread.c Thu May  9 10:26:14 2013
@@ -31,8 +31,10 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
 
+#include <stdbool.h>
 #include <math.h>
-#include <sys/select.h>
+#include <unistd.h>
+#include <fcntl.h>
 
 #include "asterisk/module.h"
 #include "asterisk/timing.h"
@@ -40,7 +42,6 @@
 #include "asterisk/astobj2.h"
 #include "asterisk/time.h"
 #include "asterisk/lock.h"
-#include "asterisk/poll-compat.h"
 
 static void *timing_funcs_handle;
 
@@ -91,13 +92,15 @@
 	unsigned int tick_count;
 	unsigned int pending_ticks;
 	struct timeval start;
-	unsigned int continuous:1;
+	bool continuous:1;
+	bool pipe_signaled:1;
 };
 
 static void pthread_timer_destructor(void *obj);
 static struct pthread_timer *find_timer(int handle, int unlinkobj);
-static void write_byte(struct pthread_timer *timer);
-static int read_pipe(struct pthread_timer *timer, unsigned int num);
+static void signal_pipe(struct pthread_timer *timer);
+static void unsignal_pipe(struct pthread_timer *timer);
+static void ack_ticks(struct pthread_timer *timer, unsigned int num);
 
 /*!
  * \brief Data for the timing thread
@@ -113,6 +116,7 @@
 {
 	struct pthread_timer *timer;
 	int fd;
+	int i;
 
 	if (!(timer = ao2_alloc(sizeof(*timer), pthread_timer_destructor))) {
 		errno = ENOMEM;
@@ -127,6 +131,12 @@
 		return -1;
 	}
 
+	for (i = 0; i < ARRAY_LEN(timer->pipe); ++i) {
+		int flags = fcntl(timer->pipe[i], F_GETFL);
+		flags |= O_NONBLOCK;
+		fcntl(timer->pipe[i], F_SETFL, flags);
+	}
+	
 	ao2_lock(pthread_timers);
 	if (!ao2_container_count(pthread_timers)) {
 		ast_mutex_lock(&timing_thread.lock);
@@ -193,7 +203,6 @@
 static int pthread_timer_ack(int handle, unsigned int quantity)
 {
 	struct pthread_timer *timer;
-	int res;
 
 	ast_assert(quantity > 0);
 
@@ -202,12 +211,12 @@
 	}
 
 	ao2_lock(timer);
-	res = read_pipe(timer, quantity);
+	ack_ticks(timer, quantity);
 	ao2_unlock(timer);
 
 	ao2_ref(timer, -1);
 
-	return res;
+	return 0;
 }
 
 static int pthread_timer_enable_continuous(int handle)
@@ -221,8 +230,8 @@
 
 	ao2_lock(timer);
 	if (!timer->continuous) {
-		timer->continuous = 1;
-		write_byte(timer);
+		timer->continuous = true;
+		signal_pipe(timer);
 	}
 	ao2_unlock(timer);
 
@@ -242,13 +251,8 @@
 
 	ao2_lock(timer);
 	if (timer->continuous) {
-		timer->continuous = 0;
-		if (read_pipe(timer, 1) != 0) {
-			/* Let the errno from read_pipe propagate up */
-			ao2_unlock(timer);
-			ao2_ref(timer, -1);
-			return -1;
-		}
+		timer->continuous = false;
+		unsignal_pipe(timer);
 	}
 	ao2_unlock(timer);
 
@@ -267,7 +271,7 @@
 	}
 
 	ao2_lock(timer);
-	if (timer->continuous && timer->pending_ticks == 1) {
+	if (timer->continuous) {
 		res = AST_TIMING_EVENT_CONTINUOUS;
 	}
 	ao2_unlock(timer);
@@ -366,79 +370,69 @@
 /*!
  * \internal
  * \pre timer is locked
- * \retval 0 if nothing to read or read success
- * \retval -1 on error
- */
-static int read_pipe(struct pthread_timer *timer, unsigned int quantity)
-{
-	int rd_fd = timer->pipe[PIPE_READ];
+ */
+static void ack_ticks(struct pthread_timer *timer, unsigned int quantity)
+{
 	int pending_ticks = timer->pending_ticks;
 
 	ast_assert(quantity);
-
-	if (timer->continuous && pending_ticks) {
-		pending_ticks--;
-	}
 
 	if (quantity > pending_ticks) {
 		quantity = pending_ticks;
 	}
 
 	if (!quantity) {
-		return 0;
-	}
-
-	do {
-		unsigned char buf[1024];
-		ssize_t res;
-		struct pollfd pfd = {
-			.fd = rd_fd,
-			.events = POLLIN,
-		};
-
-		if (ast_poll(&pfd, 1, 0) != 1) {
-			ast_debug(1, "Reading not available on timing pipe, "
-					"quantity: %u\n", quantity);
-			return -1;
-		}
-
-		res = read(rd_fd, buf,
-			(quantity < sizeof(buf)) ? quantity : sizeof(buf));
-
-		if (res == -1) {
-			if (errno == EAGAIN) {
-				continue;
-			}
-			ast_log(LOG_ERROR, "read failed on timing pipe: %s\n",
-					strerror(errno));
-			return -1;
-		}
-
-		quantity -= res;
-		timer->pending_ticks -= res;
-	} while (quantity);
-
-	return 0;
+		return;
+	}
+
+	timer->pending_ticks -= quantity;
+
+	if ((0 == timer->pending_ticks) && !timer->continuous) {
+		unsignal_pipe(timer);
+	}
 }
 
 /*!
  * \internal
  * \pre timer is locked
  */
-static void write_byte(struct pthread_timer *timer)
+static void signal_pipe(struct pthread_timer *timer)
 {
 	ssize_t res;
 	unsigned char x = 42;
 
-	do {
-		res = write(timer->pipe[PIPE_WRITE], &x, 1);
-	} while (res == -1 && errno == EAGAIN);
-
-	if (res == -1) {
+	if (timer->pipe_signaled) {
+		return;
+	}
+
+	res = write(timer->pipe[PIPE_WRITE], &x, 1);
+	if (-1 == res) {
 		ast_log(LOG_ERROR, "Error writing to timing pipe: %s\n",
 				strerror(errno));
 	} else {
-		timer->pending_ticks++;
+		timer->pipe_signaled = true;
+	}
+}
+
+/*!
+ * \internal
+ * \pre timer is locked
+ */
+static void unsignal_pipe(struct pthread_timer *timer)
+{
+	ssize_t res;
+	unsigned long buffer;
+
+	if (!timer->pipe_signaled) {
+		return;
+	}
+
+	res = read(timer->pipe[PIPE_READ], &buffer, sizeof(buffer));
+	if (-1 == res) {
+		ast_log(LOG_ERROR, "Error reading from pipe: %s\n",
+				strerror(errno));
+	} else {
+		timer->pipe_signaled = false;
 	}
 }
 
@@ -452,7 +446,8 @@
 
 	ao2_lock(timer);
 	if (check_timer(timer)) {
-		write_byte(timer);
+		timer->pending_ticks++;
+		signal_pipe(timer);
 	}
 	ao2_unlock(timer);
 




More information about the svn-commits mailing list