[asterisk-commits] jrose: branch jrose/bridge_projects r385214 - /team/jrose/bridge_projects/res...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Apr 10 10:16:43 CDT 2013
Author: jrose
Date: Wed Apr 10 10:16:41 2013
New Revision: 385214
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385214
Log:
Make parked users properly take a reference to their respective parking lot states to eliminate a segfault that was occuring on retrieval. It's also just better that way.
Modified:
team/jrose/bridge_projects/res/parking/parking_controller.c
Modified: team/jrose/bridge_projects/res/parking/parking_controller.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/parking_controller.c?view=diff&rev=385214&r1=385213&r2=385214
==============================================================================
--- team/jrose/bridge_projects/res/parking/parking_controller.c (original)
+++ team/jrose/bridge_projects/res/parking/parking_controller.c Wed Apr 10 10:16:41 2013
@@ -75,7 +75,6 @@
if (pu->lot_state) {
ao2_unlink(pu->lot_state->parked_user_list, pu);
parking_lot_state_remove_if_unused(pu->lot_state);
- pu->lot_state = NULL;
return 0;
}
@@ -184,7 +183,6 @@
ao2_unlock(user);
parking_lot_state_remove_if_unused(user->lot_state);
- user->lot_state = NULL;
/* Bump the ref count by 1 since the RAII_VAR will eat the reference otherwise */
ao2_ref(user, +1);
@@ -194,6 +192,10 @@
static void destroy_parked_user(void *obj)
{
struct parked_user *pu = obj;
+
+ /* Free the reference to the bridge that this lot should have taken on creation */
+ ao2_cleanup(pu->lot_state);
+
ao2_cleanup(pu->parker);
}
@@ -300,7 +302,11 @@
lot_state->next_space = ((parking_space + 1) - lot_state->parking_start) % (lot_state->parking_stop - lot_state->parking_start + 1) + lot_state->parking_start;
new_parked_user->chan = chan;
new_parked_user->parking_space = parking_space;
+
+ /* Have the parked user take a reference to the parking lot state. This reference should be immutable and released at destruction */
new_parked_user->lot_state = lot_state;
+ ao2_ref(lot_state, +1);
+
new_parked_user->start = ast_tvnow();
new_parked_user->time_limit = (time_limit >= 0) ? time_limit : lot_state->parkingtime;
new_parked_user->parker = ast_channel_snapshot_create(parker);
More information about the asterisk-commits
mailing list