[svn-commits] file: branch file/bridging r180365 - in /team/file/bridging: apps/ bridges/ m...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Mar 5 10:47:34 CST 2009


Author: file
Date: Thu Mar  5 10:47:31 2009
New Revision: 180365

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=180365
Log:
Address comments from the review from Russell.

Modified:
    team/file/bridging/apps/app_confbridge.c
    team/file/bridging/bridges/bridge_multiplexed.c
    team/file/bridging/main/bridging.c

Modified: team/file/bridging/apps/app_confbridge.c
URL: http://svn.digium.com/svn-view/asterisk/team/file/bridging/apps/app_confbridge.c?view=diff&rev=180365&r1=180364&r2=180365
==============================================================================
--- team/file/bridging/apps/app_confbridge.c (original)
+++ team/file/bridging/apps/app_confbridge.c Thu Mar  5 10:47:31 2009
@@ -123,13 +123,13 @@
 	OPTION_MARKEDUSER = (1 << 6),        /*!< Set if the caller is a marked user */
 	OPTION_WAITMARKED = (1 << 7),        /*!< Set if the conference must wait for a marked user before starting */
 	OPTION_QUIET = (1 << 8),             /*!< Set if no audio prompts should be played */
-} option_flags;
+};
 
 enum {
 	OPTION_MUSICONHOLD_CLASS,            /*!< If the 'M' option is set, the music on hold class to play */
 	/*This must be the last element */
 	OPTION_ARRAY_SIZE,
-} option_args;
+};
 
 AST_APP_OPTIONS(app_opts,{
 	AST_APP_OPTION('A', OPTION_MARKEDUSER),
@@ -153,8 +153,8 @@
 struct conference_bridge {
 	char name[MAX_CONF_NAME];                                         /*!< Name of the conference bridge */
 	struct ast_bridge *bridge;                                        /*!< Bridge structure doing the mixing */
-	int users;                                                        /*!< Number of users present */
-	int markedusers;                                                  /*!< Number of marked users present */
+	unsigned int users;                                               /*!< Number of users present */
+	unsigned int markedusers;                                         /*!< Number of marked users present */
 	unsigned int locked:1;                                            /*!< Is this conference bridge locked? */
 	AST_LIST_HEAD_NOLOCK(, conference_bridge_user) users_list;        /*!< List of users participating in the conference bridge */
 	struct ast_channel *playback_chan;                                /*!< Channel used for playback into the conference bridge */
@@ -221,8 +221,6 @@
 			return;
 		}
 	}
-
-	return;
 }
 
 /*!
@@ -241,7 +239,6 @@
 	ao2_unlock(conference_bridge);
 	ast_stream_and_wait(chan, file, "");
 	ao2_lock(conference_bridge);
-	return;
 }
 
 /*!
@@ -307,8 +304,6 @@
 			ast_moh_start(conference_bridge_user->chan, conference_bridge_user->opt_args[OPTION_MUSICONHOLD_CLASS], NULL);
 		}
 	}
-
-	return;
 }
 
 /*!
@@ -354,8 +349,6 @@
 			ast_bridge_unsuspend(conference_bridge->bridge, first_participant->chan);
 		}
 	}
-
-	return;
 }
 
 /*!
@@ -385,8 +378,6 @@
 		ast_bridge_destroy(conference_bridge->bridge);
 		conference_bridge->bridge = NULL;
 	}
-
-	return;
 }
 
 /*!
@@ -544,8 +535,6 @@
 	ao2_unlock(conference_bridge);
 
 	ao2_ref(conference_bridge, -1);
-
-	return;
 }
 
 /*!

Modified: team/file/bridging/bridges/bridge_multiplexed.c
URL: http://svn.digium.com/svn-view/asterisk/team/file/bridging/bridges/bridge_multiplexed.c?view=diff&rev=180365&r1=180364&r2=180365
==============================================================================
--- team/file/bridging/bridges/bridge_multiplexed.c (original)
+++ team/file/bridging/bridges/bridge_multiplexed.c Thu Mar  5 10:47:31 2009
@@ -59,10 +59,10 @@
 	struct ast_channel *chans[MULTIPLEXED_MAX_CHANNELS];
 	/*! Number of channels in this thread */
 	unsigned int count;
+	/*! Bit used to indicate that the thread is waiting on channels */
+	unsigned int waiting:1;
 	/*! Number of channels actually being serviced by this thread */
 	unsigned int service_count;
-	/*! Bit used to indicate that the thread is waiting on channels */
-	unsigned int waiting:1;
 };
 
 /*! \brief Container of all operating multiplexed threads */
@@ -167,7 +167,7 @@
 	}
 
 	while (multiplexed_thread->waiting) {
-		usleep(1);
+		sched_yield();
 	}
 
 	return;
@@ -214,8 +214,8 @@
 		memmove(multiplexed_thread->chans, multiplexed_thread->chans + 1, sizeof(struct ast_channel *) * (multiplexed_thread->service_count - 1));
 		multiplexed_thread->chans[multiplexed_thread->service_count - 1] = first;
 
+		multiplexed_thread->waiting = 1;
 		ao2_unlock(multiplexed_thread);
-		multiplexed_thread->waiting = 1;
 		winner = ast_waitfor_nandfds(multiplexed_thread->chans, multiplexed_thread->service_count, &fds, 1, NULL, &outfd, &to);
 		multiplexed_thread->waiting = 0;
 		ao2_lock(multiplexed_thread);

Modified: team/file/bridging/main/bridging.c
URL: http://svn.digium.com/svn-view/asterisk/team/file/bridging/main/bridging.c?view=diff&rev=180365&r1=180364&r2=180365
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Thu Mar  5 10:47:31 2009
@@ -142,13 +142,16 @@
 	return;
 }
 
-/*! \brief Helper function to add a channel to the bridge array */
+/*! \brief Helper function to add a channel to the bridge array
+ *
+ * \note This function assumes the bridge is locked.
+ */
 static void bridge_array_add(struct ast_bridge *bridge, struct ast_channel *chan)
 {
 	/* We have to make sure the bridge thread is not using the bridge array before messing with it */
 	while (bridge->waiting) {
 		bridge_poke(bridge);
-		usleep(1);
+		sched_yield();
 	}
 
 	bridge->array[bridge->array_num++] = chan;
@@ -159,7 +162,10 @@
 	if (bridge->array_num == bridge->array_size) {
 		struct ast_channel **tmp;
 		ast_debug(1, "Growing bridge array on %p from %d to %d\n", bridge, (int)bridge->array_size, (int)bridge->array_size + BRIDGE_ARRAY_GROW);
-		tmp = ast_realloc(bridge->array, (bridge->array_size + BRIDGE_ARRAY_GROW) * sizeof(struct ast_channel*));
+		if (!(tmp = ast_realloc(bridge->array, (bridge->array_size + BRIDGE_ARRAY_GROW) * sizeof(struct ast_channel *)))) {
+			ast_log(LOG_ERROR, "Failed to allocate more space for another channel on bridge '%p', this is not going to end well\n", bridge);
+			return;
+		}
 		bridge->array = tmp;
 		bridge->array_size += BRIDGE_ARRAY_GROW;
 	}
@@ -167,7 +173,10 @@
 	return;
 }
 
-/*! \brief Helper function to remove a channel from the bridge array */
+/*! \brief Helper function to remove a channel from the bridge array
+ *
+ * \note This function assumes the bridge is locked.
+ */
 static void bridge_array_remove(struct ast_bridge *bridge, struct ast_channel *chan)
 {
 	int i;
@@ -175,7 +184,7 @@
 	/* We have to make sure the bridge thread is not using the bridge array before messing with it */
 	while (bridge->waiting) {
 		bridge_poke(bridge);
-		usleep(1);
+		sched_yield();
 	}
 
 	for (i = 0; i < bridge->array_num; i++) {
@@ -315,8 +324,8 @@
 		}
 
 		/* Wait on the channels */
+		bridge->waiting = 1;
 		ao2_unlock(bridge);
-		bridge->waiting = 1;
 		winner = ast_waitfor_n(bridge->array, (int)bridge->array_num, &to);
 		bridge->waiting = 0;
 		ao2_lock(bridge);




More information about the svn-commits mailing list