> On Dec. 9, 2014, 7:36 p.m., rmudgett wrote: > > /trunk/main/astobj2.c, line 432 > > <https://reviewboard.asterisk.org/r/4108/diff/3/?file=68553#file68553line432> > > > > Use of obj->priv_data.weakptr is not protected from other threads > > creating a weak object from the object. This wouldn't be a problem if the > > object were required to be immediately weakened after creation. > > Corey Farrell wrote: > I've transfered the actual creation of weak proxy objects from ao2_weaken > to ao2_alloc (with an option).
I've changed my mind. Creation of ao2_weakproxy objects requires it's own allocation function. I'm envisioning scenarios where the weakproxy can be a persistant object. So after the object a weakproxy points to is free'd, we may want to point the weakproxy to a new object. Previous patches did not allow for this although there is no technical reason against it. So to your original finding, I've documented the thread safety concerns about ao2_weakproxy_set_object. Documentation / wording is not my strongest area, I'm open to any suggestions that make it clear when it's safe to associate an object to a weakproxy. - Corey ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviewboard.asterisk.org/r/4108/#review13933 ----------------------------------------------------------- On March 4, 2015, 4:43 p.m., Corey Farrell wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviewboard.asterisk.org/r/4108/ > ----------------------------------------------------------- > > (Updated March 4, 2015, 4:43 p.m.) > > > Review request for Asterisk Developers, George Joseph and rmudgett. > > > Repository: Asterisk > > > Description > ------- > > This implements "weak" references. The weakproxy object is a real ao2 with > normal reference counting of its own. When a weakproxy is pointed to a > normal object they hold references to each other. The normal object is > automatically freed when a single reference remains (the weakproxy). The > weakproxy also supports subscriptions that will notify callbacks when the > normal object is about to be destroyed. > > > Diffs > ----- > > /trunk/tests/test_astobj2_weaken.c PRE-CREATION > /trunk/main/astobj2.c 432445 > /trunk/include/asterisk/astobj2.h 432445 > > Diff: https://reviewboard.asterisk.org/r/4108/diff/ > > > Testing > ------- > > Ran the included test with REF_DEBUG enabled under valgrind. No reference > leaks or improper memory access. Though this does not test for races, I > don't know of an automated way to do that. > > > Thanks, > > Corey Farrell > >
-- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-dev mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-dev