]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
astobj2: Correct ao2_iterator opacity violations
authorKinsey Moore <kmoore@digium.com>
Thu, 9 Jan 2014 20:34:19 +0000 (20:34 +0000)
committerKinsey Moore <kmoore@digium.com>
Thu, 9 Jan 2014 20:34:19 +0000 (20:34 +0000)
This corrects the ao2_iterator opacity violations in
res_pjsip_session.c by adding a global function to get the number of
elements inside the container hidden behind the iterator.

(closes issue ASTERISK-23053)
Review: https://reviewboard.asterisk.org/r/3111/
Reported by: Richard Mudgett
........

Merged revisions 405253 from http://svn.asterisk.org/svn/asterisk/branches/12

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@405254 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/astobj2.h
main/astobj2.c
res/res_pjsip_session.c

index 9129c4b67e7aea5548366fa0bbe127f7db525f12..2a9be185add2f19ad72a96a758fd3c12d6e0bb6e 100644 (file)
@@ -1933,4 +1933,13 @@ void __ao2_cleanup_debug(void *obj, const char *file, int line, const char *func
 #endif
 void ao2_iterator_cleanup(struct ao2_iterator *iter);
 
+/*!
+ * \brief Get a count of the iterated container objects.
+ *
+ * \param iter the iterator to query
+ *
+ * \retval The number of objects in the iterated container
+ */
+int ao2_iterator_count(struct ao2_iterator *iter);
+
 #endif /* _ASTERISK_ASTOBJ2_H */
index 614e170960fa02d8ee2ea23e9e92efbb6682ce0e..ec80f64896fa4b45a7bb9925c483d0034afbf5f6 100644 (file)
@@ -1682,6 +1682,11 @@ void *__ao2_iterator_next(struct ao2_iterator *iter)
        return internal_ao2_iterator_next(iter, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__);
 }
 
+int ao2_iterator_count(struct ao2_iterator *iter)
+{
+       return ao2_container_count(iter->c);
+}
+
 static void container_destruct(void *_c)
 {
        struct ao2_container *c = _c;
index caaed317a5cb7a61522405bf52e7fa7582799478..d548d29b8d514782c87bc96bd8d2ef3acbbec5c3 100644 (file)
@@ -471,7 +471,7 @@ static int handle_negotiated_sdp(struct ast_sip_session *session, const pjmedia_
        };
 
        successful = ao2_callback(session->media, OBJ_MULTIPLE, handle_negotiated_sdp_session_media, &callback_data);
-       if (successful && ao2_container_count(successful->c) == ao2_container_count(session->media)) {
+       if (successful && ao2_iterator_count(successful) == ao2_container_count(session->media)) {
                /* Nothing experienced a catastrophic failure */
                ast_queue_frame(session->channel, &ast_null_frame);
                return 0;
@@ -2026,7 +2026,7 @@ static struct pjmedia_sdp_session *create_local_sdp(pjsip_inv_session *inv, stru
 
        /* Now let the handlers add streams of various types, pjmedia will automatically reorder the media streams for us */
        successful = ao2_callback_data(session->media, OBJ_MULTIPLE, add_sdp_streams, local, session);
-       if (!successful || ao2_container_count(successful->c) != ao2_container_count(session->media)) {
+       if (!successful || ao2_iterator_count(successful) != ao2_container_count(session->media)) {
                /* Something experienced a catastrophic failure */
                return NULL;
        }