<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/6710">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Jenkins2: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">astobj2: Add ao2_weakproxy_find function.<br><br>This function finds a weak proxy in an ao2_container and returns the<br>real object associated with it.<br><br>Change-Id: I9da822049747275f5961b5c0a7f14e87157d65d8<br>---<br>M include/asterisk/astobj2.h<br>M main/astobj2_container.c<br>2 files changed, 53 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/include/asterisk/astobj2.h b/include/asterisk/astobj2.h<br>index 9b5ec12..a18f099 100644<br>--- a/include/asterisk/astobj2.h<br>+++ b/include/asterisk/astobj2.h<br>@@ -1775,6 +1775,17 @@<br> void *__ao2_find(struct ao2_container *c, const void *arg, enum search_flags flags,<br> const char *tag, const char *file, int line, const char *func);<br> <br>+/*!<br>+ * \brief Perform an ao2_find on a container with ao2_weakproxy objects, returning the real object.<br>+ *<br>+ * \note Only OBJ_SEARCH_* and OBJ_NOLOCK flags are supported by this function.<br>+ * \see ao2_callback for description of arguments.<br>+ */<br>+#define ao2_weakproxy_find(c, arg, flags, tag) \<br>+ __ao2_weakproxy_find(c, arg, flags, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__)<br>+void *__ao2_weakproxy_find(struct ao2_container *c, const void *arg, enum search_flags flags,<br>+ const char *tag, const char *file, int line, const char *func);<br>+<br> /*! \brief<br> *<br> *<br>diff --git a/main/astobj2_container.c b/main/astobj2_container.c<br>index a978db3..c75dff9 100644<br>--- a/main/astobj2_container.c<br>+++ b/main/astobj2_container.c<br>@@ -437,6 +437,48 @@<br> return __ao2_callback(c, flags, c->cmp_fn, arged, tag, file, line, func);<br> }<br> <br>+void *__ao2_weakproxy_find(struct ao2_container *c, const void *arg, enum search_flags flags,<br>+ const char *tag, const char *file, int line, const char *func)<br>+{<br>+ void *proxy;<br>+ void *obj = NULL;<br>+ enum ao2_lock_req orig_lock;<br>+<br>+ ast_assert(!!c);<br>+ ast_assert(flags & OBJ_SEARCH_MASK);<br>+ ast_assert(!(flags & ~(OBJ_SEARCH_MASK | OBJ_NOLOCK)));<br>+<br>+ if (flags & OBJ_NOLOCK) {<br>+ orig_lock = __adjust_lock(c, AO2_LOCK_REQ_RDLOCK, 1);<br>+ } else {<br>+ orig_lock = AO2_LOCK_REQ_RDLOCK;<br>+ ao2_rdlock(c);<br>+ }<br>+<br>+ while ((proxy = ao2_find(c, arg, flags | OBJ_NOLOCK))) {<br>+ obj = __ao2_weakproxy_get_object(proxy, 0, tag ?: __PRETTY_FUNCTION__, file, line, func);<br>+<br>+ if (obj) {<br>+ ao2_ref(proxy, -1);<br>+ break;<br>+ }<br>+<br>+ /* Upgrade to a write lock */<br>+ __adjust_lock(c, AO2_LOCK_REQ_WRLOCK, 1);<br>+ ao2_unlink_flags(c, proxy, OBJ_NOLOCK);<br>+ ao2_ref(proxy, -1);<br>+ }<br>+<br>+ if (flags & OBJ_NOLOCK) {<br>+ /* We'll keep any upgraded lock */<br>+ __adjust_lock(c, orig_lock, 1);<br>+ } else {<br>+ ao2_unlock(c);<br>+ }<br>+<br>+ return obj;<br>+}<br>+<br> /*!<br> * initialize an iterator so we start from the first object<br> */<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6710">change 6710</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/6710"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I9da822049747275f5961b5c0a7f14e87157d65d8 </div>
<div style="display:none"> Gerrit-Change-Number: 6710 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>