summaryrefslogtreecommitdiff
path: root/include/asterisk
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2015-03-13 01:12:35 +0000
committerCorey Farrell <git@cfware.com>2015-03-13 01:12:35 +0000
commitc08fd275bf8c45dc09084f104521cbff04eab25b (patch)
tree09cc14b9a9190254980ec88b981d6f561ec8a9b5 /include/asterisk
parent38ee441ea7debef3ebf6b162fc290b121fa3588d (diff)
Logger: Convert 'struct ast_callid' to unsigned int.
Switch logger callid's from AO2 objects to simple integers. This helps in two ways. Copying integers is faster than referencing AO2 objects, so this will result in a small reduction in logger overhead. This also erases the possibility of an infinate loop caused by an invalid callid in threadstorage. ASTERISK-24833 #comment Committed callid conversion to trunk. Reported by: Corey Farrell Review: https://reviewboard.asterisk.org/r/4466/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432834 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk')
-rw-r--r--include/asterisk/bridge.h2
-rw-r--r--include/asterisk/bridge_channel.h2
-rw-r--r--include/asterisk/channel.h4
-rw-r--r--include/asterisk/core_unreal.h3
-rw-r--r--include/asterisk/logger.h62
5 files changed, 20 insertions, 53 deletions
diff --git a/include/asterisk/bridge.h b/include/asterisk/bridge.h
index 8fa0f36ed..8243a1ddb 100644
--- a/include/asterisk/bridge.h
+++ b/include/asterisk/bridge.h
@@ -280,7 +280,7 @@ struct ast_bridge {
/*! Per-bridge topics */
struct stasis_cp_single *topics;
/*! Call ID associated with the bridge */
- struct ast_callid *callid;
+ ast_callid callid;
/*! Linked list of channels participating in the bridge */
AST_LIST_HEAD_NOLOCK(, ast_bridge_channel) channels;
/*! Queue of actions to perform on the bridge. */
diff --git a/include/asterisk/bridge_channel.h b/include/asterisk/bridge_channel.h
index 1d071a014..c53848511 100644
--- a/include/asterisk/bridge_channel.h
+++ b/include/asterisk/bridge_channel.h
@@ -138,7 +138,7 @@ struct ast_bridge_channel {
/*! Copy of write format used by chan before join */
struct ast_format *write_format;
/*! Call ID associated with bridge channel */
- struct ast_callid *callid;
+ ast_callid callid;
/*! A clone of the roles living on chan when the bridge channel joins the bridge. This may require some opacification */
struct bridge_roles_datastore *bridge_roles;
/*! Linked list information */
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index b6755e256..6dd3ac49c 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -4046,12 +4046,12 @@ void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tec
enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan);
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value);
enum ast_channel_state ast_channel_state(const struct ast_channel *chan);
-struct ast_callid *ast_channel_callid(const struct ast_channel *chan);
+ast_callid ast_channel_callid(const struct ast_channel *chan);
/*!
* \pre chan is locked
*/
-void ast_channel_callid_set(struct ast_channel *chan, struct ast_callid *value);
+void ast_channel_callid_set(struct ast_channel *chan, ast_callid value);
/* XXX Internal use only, make sure to move later */
void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state);
diff --git a/include/asterisk/core_unreal.h b/include/asterisk/core_unreal.h
index e118c74bd..45045e0a9 100644
--- a/include/asterisk/core_unreal.h
+++ b/include/asterisk/core_unreal.h
@@ -40,7 +40,6 @@ extern "C" {
/* Forward declare some struct names */
struct ast_format_cap;
-struct ast_callid;
/* ------------------------------------------------------------------- */
@@ -207,7 +206,7 @@ struct ast_unreal_pvt *ast_unreal_alloc(size_t size, ao2_destructor_fn destructo
struct ast_channel *ast_unreal_new_channels(struct ast_unreal_pvt *p,
const struct ast_channel_tech *tech, int semi1_state, int semi2_state,
const char *exten, const char *context, const struct ast_assigned_ids *assignedids,
- const struct ast_channel *requestor, struct ast_callid *callid);
+ const struct ast_channel *requestor, ast_callid callid);
/*!
* \brief Setup unreal owner and chan channels before initiating call.
diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h
index 84e6991f0..feb9c7eda 100644
--- a/include/asterisk/logger.h
+++ b/include/asterisk/logger.h
@@ -63,7 +63,7 @@ void ast_log(int level, const char *file, int line, const char *function, const
__attribute__((format(printf, 5, 6)));
/* XXX needs documentation */
-struct ast_callid;
+typedef unsigned int ast_callid;
/*! \brief Used for sending a log message with a known call_id
This is a modified logger function which is functionally identical to the above logger function,
@@ -77,7 +77,7 @@ struct ast_callid;
\param callid This is the ast_callid that is associated with the log message. May be NULL.
\param fmt This is what is important. The format is the same as your favorite breed of printf. You know how that works, right? :-)
*/
-void ast_log_callid(int level, const char *file, int line, const char *function, struct ast_callid *callid, const char *fmt, ...)
+void ast_log_callid(int level, const char *file, int line, const char *function, ast_callid callid, const char *fmt, ...)
__attribute__((format(printf, 6, 7)));
/*!
@@ -117,12 +117,12 @@ void __attribute__((format(printf, 5, 6))) __ast_verbose(const char *file, int l
* allow you to specify that a log will never display a call id even when there is a call id bound to the
* thread.
*/
-void __attribute__((format(printf, 6, 7))) __ast_verbose_callid(const char *file, int line, const char *func, int level, struct ast_callid *callid, const char *fmt, ...);
+void __attribute__((format(printf, 6, 7))) __ast_verbose_callid(const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt, ...);
#define ast_verbose(...) __ast_verbose(__FILE__, __LINE__, __PRETTY_FUNCTION__, -1, __VA_ARGS__)
#define ast_verbose_callid(callid, ...) __ast_verbose_callid(__FILE__, __LINE__, __PRETTY_FUNCTION__, -1, callid, __VA_ARGS__)
-void __attribute__((format(printf, 6, 0))) __ast_verbose_ap(const char *file, int line, const char *func, int level, struct ast_callid *callid, const char *fmt, va_list ap);
+void __attribute__((format(printf, 6, 0))) __ast_verbose_ap(const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt, va_list ap);
void __attribute__((format(printf, 2, 3))) ast_child_verbose(int level, const char *fmt, ...);
@@ -277,49 +277,17 @@ const char *ast_logger_get_dateformat(void);
/*!
* \brief factory function to create a new uniquely identifying callid.
*
- * \retval ast_callid struct pointer containing the call id
- *
- * \note The newly created callid will be referenced upon creation and this function should be
- * paired with a call to ast_callid_unref()
+ * \retval The call id
*/
-struct ast_callid *ast_create_callid(void);
+ast_callid ast_create_callid(void);
/*!
* \brief extracts the callerid from the thread
*
- * \retval ast_callid reference to call_id related to the thread
- * \retval NULL if no call_id is present in the thread
- *
- * This reference must be unreffed before it loses scope to prevent memory leaks.
- */
-struct ast_callid *ast_read_threadstorage_callid(void);
-
-/*!
- * \brief Increase callid reference count
- *
- * \param c the ast_callid
- *
- * \retval c always
- */
-#define ast_callid_ref(c) ({ ao2_ref(c, +1); (c); })
-
-/*!
- * \brief Decrease callid reference count
- *
- * \param c the ast_callid
- *
- * \retval NULL always
- */
-#define ast_callid_unref(c) ({ ao2_ref(c, -1); (struct ast_callid *) (NULL); })
-
-/*!
- * \brief Cleanup a callid reference (NULL safe ao2 unreference)
- *
- * \param c the ast_callid
- *
- * \retval NULL always
+ * \retval Non-zero Call id related to the thread
+ * \retval 0 if no call_id is present in the thread
*/
-#define ast_callid_cleanup(c) ({ ao2_cleanup(c); (struct ast_callid *) (NULL); })
+ast_callid ast_read_threadstorage_callid(void);
/*!
* \brief Sets what is stored in the thread storage to the given
@@ -328,7 +296,7 @@ struct ast_callid *ast_read_threadstorage_callid(void);
* \retval 0 - success
* \retval non-zero - failure
*/
-int ast_callid_threadassoc_change(struct ast_callid *callid);
+int ast_callid_threadassoc_change(ast_callid callid);
/*!
* \brief Adds a known callid to thread storage of the calling thread
@@ -336,7 +304,7 @@ int ast_callid_threadassoc_change(struct ast_callid *callid);
* \retval 0 - success
* \retval non-zero - failure
*/
-int ast_callid_threadassoc_add(struct ast_callid *callid);
+int ast_callid_threadassoc_add(ast_callid callid);
/*!
* \brief Removes callid from thread storage of the calling thread
@@ -351,12 +319,12 @@ int ast_callid_threadassoc_remove(void);
* If not, then a new one will be created, bound to the thread, and a reference
* to it will be stored.
*
- * \param callid pointer to struct pointer used to store the referenced callid
+ * \param callid pointer to store the callid
* \retval 0 - callid was found
* \retval 1 - callid was created
* \retval -1 - the function failed somehow (presumably memory problems)
*/
-int ast_callid_threadstorage_auto(struct ast_callid **callid);
+int ast_callid_threadstorage_auto(ast_callid *callid);
/*!
* \brief Use in conjunction with ast_callid_threadstorage_auto. Cleans up the
@@ -365,7 +333,7 @@ int ast_callid_threadstorage_auto(struct ast_callid **callid);
* \param callid The callid set by ast_callid_threadstorage_auto
* \param callid_created The integer returned through ast_callid_threadstorage_auto
*/
-void ast_callid_threadstorage_auto_clean(struct ast_callid *callid, int callid_created);
+void ast_callid_threadstorage_auto_clean(ast_callid callid, int callid_created);
/*!
* \brief copy a string representation of the callid into a target string
@@ -374,7 +342,7 @@ void ast_callid_threadstorage_auto_clean(struct ast_callid *callid, int callid_c
* \param buffer_size maximum writable length of the string (Less than 13 will result in truncation)
* \param callid Callid for which string is being requested
*/
-void ast_callid_strnprint(char *buffer, size_t buffer_size, struct ast_callid *callid);
+void ast_callid_strnprint(char *buffer, size_t buffer_size, ast_callid callid);
/*!
* \brief Send a log message to a dynamically registered log level