stasis: No need to keep a stasis type ref in a stasis msg or cache object.

Stasis message types are global ao2 objects and we make stasis messages
and cache entries hold references to them.  Since there are currently
situations where cache objects are never deleted, the reference count on
the types can exceed 100000 and generate a FRACK assertion message.  The
stasis message cache could conceivably also have that many messages
legitimately on large systems.

The only down side to not holding the message type ref in the stasis
message is it only makes a crash either at shutdown or when manually
unloading a busy module slightly more likely.  However, this is more
exposing a pre-existing stasis shutdown ordering issue than a problem with
not holding a message type ref in stasis messages.

* Made stasis messages and cache entries no longer hold a ref to the
message type.

Change-Id: Ibaa28efa8d8ad3836f0c65957192424c7f561707
This commit is contained in:
Richard Mudgett
2018-09-14 15:51:41 -05:00
parent f4294baf21
commit ac18bb23a9
2 changed files with 18 additions and 4 deletions

View File

@@ -112,7 +112,6 @@ struct stasis_message {
static void stasis_message_dtor(void *obj)
{
struct stasis_message *message = obj;
ao2_cleanup(message->type);
ao2_cleanup(message->data);
}
@@ -131,7 +130,14 @@ struct stasis_message *stasis_message_create_full(struct stasis_message_type *ty
}
message->timestamp = ast_tvnow();
ao2_ref(type, +1);
/*
* XXX Normal ao2 ref counting rules says we should increment the message
* type ref here and decrement it in stasis_message_dtor(). However, the
* stasis message could be cached and legitimately cause the type ref count
* to hit the excessive ref count assertion. Since the message type
* practically has to be a global object anyway, we can get away with not
* holding a ref in the stasis message.
*/
message->type = type;
ao2_ref(data, +1);
message->data = data;