[svn-commits] russell: branch russell/smdi-1.4 r93468 - in /team/russell/smdi-1.4: apps/ in...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Dec 17 17:33:37 CST 2007


Author: russell
Date: Mon Dec 17 17:33:36 2007
New Revision: 93468

URL: http://svn.digium.com/view/asterisk?view=rev&rev=93468
Log:
Move documentation of public functions into smdi.h.  Add a new function,
ast_smdi_mwi_message_wait_station(), which allows waiting for an SMDI
response to MWI for a specific station.  This fixes a bug in app_voicemail
where the message received is not guaranteed to be the response to the MWI
set or unset that was just done ...

Modified:
    team/russell/smdi-1.4/apps/app_voicemail.c
    team/russell/smdi-1.4/include/asterisk/smdi.h
    team/russell/smdi-1.4/res/res_smdi.c

Modified: team/russell/smdi-1.4/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/russell/smdi-1.4/apps/app_voicemail.c?view=diff&rev=93468&r1=93467&r2=93468
==============================================================================
--- team/russell/smdi-1.4/apps/app_voicemail.c (original)
+++ team/russell/smdi-1.4/apps/app_voicemail.c Mon Dec 17 17:33:36 2007
@@ -2748,7 +2748,7 @@
 		else
 			ast_smdi_mwi_unset(smdi_iface, extension);
 
-		if ((mwi_msg = ast_smdi_mwi_message_wait(smdi_iface, SMDI_MWI_WAIT_TIMEOUT))) {
+		if ((mwi_msg = ast_smdi_mwi_message_wait_station(smdi_iface, SMDI_MWI_WAIT_TIMEOUT, extension))) {
 			ast_log(LOG_ERROR, "Error executing SMDI MWI change for %s\n", extension);
 			if (!strncmp(mwi_msg->cause, "INV", 3))
 				ast_log(LOG_ERROR, "Invalid MWI extension: %s\n", mwi_msg->fwd_st);

Modified: team/russell/smdi-1.4/include/asterisk/smdi.h
URL: http://svn.digium.com/view/asterisk/team/russell/smdi-1.4/include/asterisk/smdi.h?view=diff&rev=93468&r1=93467&r2=93468
==============================================================================
--- team/russell/smdi-1.4/include/asterisk/smdi.h (original)
+++ team/russell/smdi-1.4/include/asterisk/smdi.h Mon Dec 17 17:33:36 2007
@@ -84,25 +84,110 @@
 
 void ast_smdi_interface_unref(struct ast_smdi_interface *iface);
 
-/* MD message queue functions */
+/*! 
+ * \brief Get the next SMDI message from the queue.
+ * \param iface a pointer to the interface to use.
+ *
+ * This function pulls the first unexpired message from the SMDI message queue
+ * on the specified interface.  It will purge all expired SMDI messages before
+ * returning.
+ *
+ * \return the next SMDI message, or NULL if there were no pending messages.
+ */
 struct ast_smdi_md_message *ast_smdi_md_message_pop(struct ast_smdi_interface *iface);
+
+/*!
+ * \brief Get the next SMDI message from the queue.
+ * \param iface a pointer to the interface to use.
+ * \param timeout the time to wait before returning in milliseconds.
+ *
+ * This function pulls a message from the SMDI message queue on the specified
+ * interface.  If no message is available this function will wait the specified
+ * amount of time before returning.
+ *
+ * \return the next SMDI message, or NULL if there were no pending messages and
+ * the timeout has expired.
+ */
 struct ast_smdi_md_message *ast_smdi_md_message_wait(struct ast_smdi_interface *iface, int timeout);
+
+/*!
+ * \brief Put an SMDI message back in the front of the queue.
+ * \param iface a pointer to the interface to use.
+ * \param md_msg a pointer to the message to use.
+ *
+ * This function puts a message back in the front of the specified queue.  It
+ * should be used if a message was popped but is not going to be processed for
+ * some reason, and the message needs to be returned to the queue.
+ */
 void ast_smdi_md_message_putback(struct ast_smdi_interface *iface, struct ast_smdi_md_message *msg);
 
-/* MWI message queue functions */
+/*!
+ * \brief Get the next SMDI message from the queue.
+ * \param iface a pointer to the interface to use.
+ *
+ * This function pulls the first unexpired message from the SMDI message queue
+ * on the specified interface.  It will purge all expired SMDI messages before
+ * returning.
+ *
+ * \return the next SMDI message, or NULL if there were no pending messages.
+ */
 struct ast_smdi_mwi_message *ast_smdi_mwi_message_pop(struct ast_smdi_interface *iface);
+
+/*!
+ * \brief Get the next SMDI message from the queue.
+ * \param iface a pointer to the interface to use.
+ * \param timeout the time to wait before returning in milliseconds.
+ *
+ * This function pulls a message from the SMDI message queue on the specified
+ * interface.  If no message is available this function will wait the specified
+ * amount of time before returning.
+ *
+ * \return the next SMDI message, or NULL if there were no pending messages and
+ * the timeout has expired.
+ */
 struct ast_smdi_mwi_message *ast_smdi_mwi_message_wait(struct ast_smdi_interface *iface, int timeout);
+struct ast_smdi_mwi_message *ast_smdi_mwi_message_wait_station(struct ast_smdi_interface *iface, 
+	int timeout, const char *station);
+
+/*!
+ * \brief Put an SMDI message back in the front of the queue.
+ * \param iface a pointer to the interface to use.
+ * \param mwi_msg a pointer to the message to use.
+ *
+ * This function puts a message back in the front of the specified queue.  It
+ * should be used if a message was popped but is not going to be processed for
+ * some reason, and the message needs to be returned to the queue.
+ */
 void ast_smdi_mwi_message_putback(struct ast_smdi_interface *iface, struct ast_smdi_mwi_message *msg);
 
+/*!
+ * \brief Find an SMDI interface with the specified name.
+ * \param iface_name the name/port of the interface to search for.
+ *
+ * \return a pointer to the interface located or NULL if none was found.  This
+ * actually returns an ASTOBJ reference and should be released using
+ * #ASTOBJ_UNREF(iface, ast_smdi_interface_destroy).
+ */
 struct ast_smdi_interface *ast_smdi_interface_find(const char *iface_name);
 
-/* MWI functions */
+/*!
+ * \brief Set the MWI indicator for a mailbox.
+ * \param iface the interface to use.
+ * \param mailbox the mailbox to use.
+ */
 int ast_smdi_mwi_set(struct ast_smdi_interface *iface, const char *mailbox);
+
+/*! 
+ * \brief Unset the MWI indicator for a mailbox.
+ * \param iface the interface to use.
+ * \param mailbox the mailbox to use.
+ */
 int ast_smdi_mwi_unset(struct ast_smdi_interface *iface, const char *mailbox);
 
+/*! \brief ast_smdi_md_message destructor. */
 void ast_smdi_md_message_destroy(struct ast_smdi_md_message *msg);
+
+/*! \brief ast_smdi_mwi_message destructor. */
 void ast_smdi_mwi_message_destroy(struct ast_smdi_mwi_message *msg);
 
-void ast_smdi_interface_destroy(struct ast_smdi_interface *iface);
-
 #endif /* !ASTERISK_SMDI_H */

Modified: team/russell/smdi-1.4/res/res_smdi.c
URL: http://svn.digium.com/view/asterisk/team/russell/smdi-1.4/res/res_smdi.c?view=diff&rev=93468&r1=93467&r2=93468
==============================================================================
--- team/russell/smdi-1.4/res/res_smdi.c (original)
+++ team/russell/smdi-1.4/res/res_smdi.c Mon Dec 17 17:33:36 2007
@@ -126,6 +126,34 @@
 	.thread = AST_PTHREADT_NULL,
 };
 
+static void ast_smdi_interface_destroy(struct ast_smdi_interface *iface)
+{
+	if (iface->thread != AST_PTHREADT_NULL && iface->thread != AST_PTHREADT_STOP) {
+		pthread_cancel(iface->thread);
+		pthread_join(iface->thread, NULL);
+	}
+	
+	iface->thread = AST_PTHREADT_STOP;
+	
+	if (iface->file) 
+		fclose(iface->file);
+	
+	ASTOBJ_CONTAINER_DESTROYALL(&iface->md_q, ast_smdi_md_message_destroy);
+	ASTOBJ_CONTAINER_DESTROYALL(&iface->mwi_q, ast_smdi_mwi_message_destroy);
+	ASTOBJ_CONTAINER_DESTROY(&iface->md_q);
+	ASTOBJ_CONTAINER_DESTROY(&iface->mwi_q);
+
+	ast_mutex_destroy(&iface->md_q_lock);
+	ast_cond_destroy(&iface->md_q_cond);
+
+	ast_mutex_destroy(&iface->mwi_q_lock);
+	ast_cond_destroy(&iface->mwi_q_cond);
+
+	free(iface);
+
+	ast_module_unref(ast_module_info->self);
+}
+
 void ast_smdi_interface_unref(struct ast_smdi_interface *iface)
 {
 	ASTOBJ_UNREF(iface, ast_smdi_interface_destroy);
@@ -188,35 +216,16 @@
 	return 0;
 }
 
-/*!
- * \brief Set the MWI indicator for a mailbox.
- * \param iface the interface to use.
- * \param mailbox the mailbox to use.
- */
 int ast_smdi_mwi_set(struct ast_smdi_interface *iface, const char *mailbox)
 {
 	return smdi_toggle_mwi(iface, mailbox, 1);
 }
 
-/*! 
- * \brief Unset the MWI indicator for a mailbox.
- * \param iface the interface to use.
- * \param mailbox the mailbox to use.
- */
 int ast_smdi_mwi_unset(struct ast_smdi_interface *iface, const char *mailbox)
 {
 	return smdi_toggle_mwi(iface, mailbox, 0);
 }
 
-/*!
- * \brief Put an SMDI message back in the front of the queue.
- * \param iface a pointer to the interface to use.
- * \param md_msg a pointer to the message to use.
- *
- * This function puts a message back in the front of the specified queue.  It
- * should be used if a message was popped but is not going to be processed for
- * some reason, and the message needs to be returned to the queue.
- */
 void ast_smdi_md_message_putback(struct ast_smdi_interface *iface, struct ast_smdi_md_message *md_msg)
 {
 	ast_mutex_lock(&iface->md_q_lock);
@@ -225,15 +234,6 @@
 	ast_mutex_unlock(&iface->md_q_lock);
 }
 
-/*!
- * \brief Put an SMDI message back in the front of the queue.
- * \param iface a pointer to the interface to use.
- * \param mwi_msg a pointer to the message to use.
- *
- * This function puts a message back in the front of the specified queue.  It
- * should be used if a message was popped but is not going to be processed for
- * some reason, and the message needs to be returned to the queue.
- */
 void ast_smdi_mwi_message_putback(struct ast_smdi_interface *iface, struct ast_smdi_mwi_message *mwi_msg)
 {
 	ast_mutex_lock(&iface->mwi_q_lock);
@@ -429,84 +429,40 @@
 	return smdi_msg_pop(iface, type);
 }
 
+struct ast_smdi_md_message *ast_smdi_md_message_pop(struct ast_smdi_interface *iface)
+{
+	return smdi_msg_pop(iface, SMDI_MD);
+}
+
+struct ast_smdi_md_message *ast_smdi_md_message_wait(struct ast_smdi_interface *iface, int timeout)
+{
+	return smdi_message_wait(iface, timeout, SMDI_MD, NULL);
+}
+
+struct ast_smdi_mwi_message *ast_smdi_mwi_message_pop(struct ast_smdi_interface *iface)
+{
+	return smdi_msg_pop(iface, SMDI_MWI);
+}
+
+struct ast_smdi_mwi_message *ast_smdi_mwi_message_wait(struct ast_smdi_interface *iface, int timeout)
+{
+	return smdi_message_wait(iface, timeout, SMDI_MWI, NULL);
+}
+
+struct ast_smdi_mwi_message *ast_smdi_mwi_message_wait_station(struct ast_smdi_interface *iface, int timeout,
+	const char *station)
+{
+	return smdi_message_wait(iface, timeout, SMDI_MWI, station);
+}
+
+struct ast_smdi_interface *ast_smdi_interface_find(const char *iface_name)
+{
+	return (ASTOBJ_CONTAINER_FIND(&smdi_ifaces, iface_name));
+}
+
 /*! 
- * \brief Get the next SMDI message from the queue.
- * \param iface a pointer to the interface to use.
- *
- * This function pulls the first unexpired message from the SMDI message queue
- * on the specified interface.  It will purge all expired SMDI messages before
- * returning.
- *
- * \return the next SMDI message, or NULL if there were no pending messages.
- */
-struct ast_smdi_md_message *ast_smdi_md_message_pop(struct ast_smdi_interface *iface)
-{
-	return smdi_msg_pop(iface, SMDI_MD);
-}
-
-/*!
- * \brief Get the next SMDI message from the queue.
- * \param iface a pointer to the interface to use.
- * \param timeout the time to wait before returning in milliseconds.
- *
- * This function pulls a message from the SMDI message queue on the specified
- * interface.  If no message is available this function will wait the specified
- * amount of time before returning.
- *
- * \return the next SMDI message, or NULL if there were no pending messages and
- * the timeout has expired.
- */
-struct ast_smdi_md_message *ast_smdi_md_message_wait(struct ast_smdi_interface *iface, int timeout)
-{
-	return smdi_message_wait(iface, timeout, SMDI_MD, NULL);
-}
-
-/*!
- * \brief Get the next SMDI message from the queue.
- * \param iface a pointer to the interface to use.
- *
- * This function pulls the first unexpired message from the SMDI message queue
- * on the specified interface.  It will purge all expired SMDI messages before
- * returning.
- *
- * \return the next SMDI message, or NULL if there were no pending messages.
- */
-struct ast_smdi_mwi_message *ast_smdi_mwi_message_pop(struct ast_smdi_interface *iface)
-{
-	return smdi_msg_pop(iface, SMDI_MWI);
-}
-
-/*!
- * \brief Get the next SMDI message from the queue.
- * \param iface a pointer to the interface to use.
- * \param timeout the time to wait before returning in milliseconds.
- *
- * This function pulls a message from the SMDI message queue on the specified
- * interface.  If no message is available this function will wait the specified
- * amount of time before returning.
- *
- * \return the next SMDI message, or NULL if there were no pending messages and
- * the timeout has expired.
- */
-struct ast_smdi_mwi_message *ast_smdi_mwi_message_wait(struct ast_smdi_interface *iface, int timeout)
-{
-	return smdi_message_wait(iface, timeout, SMDI_MWI, NULL);
-}
-
-/*!
- * \brief Find an SMDI interface with the specified name.
- * \param iface_name the name/port of the interface to search for.
- *
- * \return a pointer to the interface located or NULL if none was found.  This
- * actually returns an ASTOBJ reference and should be released using
- * #ASTOBJ_UNREF(iface, ast_smdi_interface_destroy).
- */
-struct ast_smdi_interface *ast_smdi_interface_find(const char *iface_name)
-{
-	return (ASTOBJ_CONTAINER_FIND(&smdi_ifaces, iface_name));
-}
-
-/*! \brief Read an SMDI message.
+ * \internal
+ * \brief Read an SMDI message.
  *
  * \param iface_p the SMDI interface to read from.
  *
@@ -660,45 +616,14 @@
 	return NULL;
 }
 
-/*! \brief ast_smdi_md_message destructor. */
 void ast_smdi_md_message_destroy(struct ast_smdi_md_message *msg)
 {
 	free(msg);
 }
 
-/*! \brief ast_smdi_mwi_message destructor. */
 void ast_smdi_mwi_message_destroy(struct ast_smdi_mwi_message *msg)
 {
 	free(msg);
-}
-
-/*! \brief ast_smdi_interface destructor. */
-void ast_smdi_interface_destroy(struct ast_smdi_interface *iface)
-{
-	if (iface->thread != AST_PTHREADT_NULL && iface->thread != AST_PTHREADT_STOP) {
-		pthread_cancel(iface->thread);
-		pthread_join(iface->thread, NULL);
-	}
-	
-	iface->thread = AST_PTHREADT_STOP;
-	
-	if (iface->file) 
-		fclose(iface->file);
-	
-	ASTOBJ_CONTAINER_DESTROYALL(&iface->md_q, ast_smdi_md_message_destroy);
-	ASTOBJ_CONTAINER_DESTROYALL(&iface->mwi_q, ast_smdi_mwi_message_destroy);
-	ASTOBJ_CONTAINER_DESTROY(&iface->md_q);
-	ASTOBJ_CONTAINER_DESTROY(&iface->mwi_q);
-
-	ast_mutex_destroy(&iface->md_q_lock);
-	ast_cond_destroy(&iface->md_q_cond);
-
-	ast_mutex_destroy(&iface->mwi_q_lock);
-	ast_cond_destroy(&iface->mwi_q_cond);
-
-	free(iface);
-
-	ast_module_unref(ast_module_info->self);
 }
 
 static void destroy_mailbox_mapping(struct mailbox_mapping *mm)




More information about the svn-commits mailing list