/*-- Forward declarations */
static void aji_message_destroy(struct aji_message *obj);
-static void aji_buddy_destroy(struct aji_buddy *obj);
-static void aji_client_destroy(struct aji_client *obj);
static int aji_is_secure(struct aji_client *client);
#ifdef HAVE_OPENSSL
static int aji_start_tls(struct aji_client *client);
* \param obj aji_client The structure we will delete.
* \return void.
*/
-static void aji_client_destroy(struct aji_client *obj)
+void ast_aji_client_destroy(struct aji_client *obj)
{
struct aji_message *tmp;
- ASTOBJ_CONTAINER_DESTROYALL(&obj->buddies, aji_buddy_destroy);
+ ASTOBJ_CONTAINER_DESTROYALL(&obj->buddies, ast_aji_buddy_destroy);
ASTOBJ_CONTAINER_DESTROY(&obj->buddies);
iks_filter_delete(obj->f);
iks_parser_delete(obj->p);
* \param obj aji_buddy The structure we will delete.
* \return void.
*/
-static void aji_buddy_destroy(struct aji_buddy *obj)
+void ast_aji_buddy_destroy(struct aji_buddy *obj)
{
struct aji_resource *tmp;
buddy = ASTOBJ_CONTAINER_FIND(&client->buddies, jid.screenname);
if (!buddy) {
ast_log(LOG_WARNING, "Could not find buddy in list: '%s'\n", jid.screenname);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return -1;
}
r = aji_find_resource(buddy, jid.resource);
if (!r && buddy->resources) {
r = buddy->resources;
}
+ ASTOBJ_UNREF(buddy, ast_aji_buddy_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
if (!r) {
ast_log(LOG_NOTICE, "Resource '%s' of buddy '%s' was not found\n", jid.resource, jid.screenname);
} else {
buddy = ASTOBJ_CONTAINER_FIND(&client->buddies, jid.screenname);
if (!buddy) {
ast_log(LOG_WARNING, "Could not find buddy in list: '%s'\n", jid.screenname);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return -1;
}
r = aji_find_resource(buddy, jid.resource);
if (!r && buddy->resources) {
r = buddy->resources;
}
+ ASTOBJ_UNREF(buddy, ast_aji_buddy_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
if (!r) {
ast_log(LOG_NOTICE, "Resource %s of buddy %s was not found.\n", jid.resource, jid.screenname);
} else {
return -1;
}
- client = ast_aji_get_client(args.account);
- if (!client) {
- ast_log(LOG_WARNING, "Could not find client %s, exiting\n", args.account);
- return -1;
- }
-
parse = ast_strdupa(args.jid);
AST_NONSTANDARD_APP_ARGS(jid, parse, '/');
if (jid.argc < 1 || jid.argc > 2 || strlen(args.jid) > AJI_MAX_JIDLEN) {
ast_log(LOG_WARNING, "Invalid JID : %s\n", parse);
- ASTOBJ_UNREF(client, aji_client_destroy);
return -1;
}
sscanf(args.timeout, "%d", &timeout);
if (timeout <= 0) {
ast_log(LOG_WARNING, "Invalid timeout specified: '%s'\n", args.timeout);
- ASTOBJ_UNREF(client, aji_client_destroy);
return -1;
}
}
jidlen = strlen(jid.screenname);
resourcelen = ast_strlen_zero(jid.resource) ? 0 : strlen(jid.resource);
+ client = ast_aji_get_client(args.account);
+ if (!client) {
+ ast_log(LOG_WARNING, "Could not find client %s, exiting\n", args.account);
+ return -1;
+ }
+
ast_debug(3, "Waiting for an XMPP message from %s\n", args.jid);
start = ast_tvnow();
if (ast_autoservice_start(chan) < 0) {
ast_log(LOG_WARNING, "Cannot start autoservice for channel %s\n", chan->name);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return -1;
}
diff = ast_tvdiff_ms(ast_tvnow(), start);
}
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
if (ast_autoservice_stop(chan) < 0) {
ast_log(LOG_WARNING, "Cannot stop autoservice for channel %s\n", chan->name);
}
return -1;
}
- if (!(client = ast_aji_get_client(args.sender))) {
- ast_log(LOG_ERROR, "Could not find sender connection: '%s'\n", args.sender);
+ if (strchr(args.jid, '/')) {
+ ast_log(LOG_ERROR, "Invalid room name : resource must not be appended\n");
return -1;
}
- if (strchr(args.jid, '/')) {
- ast_log(LOG_ERROR, "Invalid room name : resource must not be appended\n");
- ASTOBJ_UNREF(client, aji_client_destroy);
+ if (!(client = ast_aji_get_client(args.sender))) {
+ ast_log(LOG_ERROR, "Could not find sender connection: '%s'\n", args.sender);
return -1;
}
ast_log(LOG_ERROR, "Problem with specified jid of '%s'\n", args.jid);
}
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return 0;
}
return -1;
}
- if (!(client = ast_aji_get_client(args.sender))) {
- ast_log(LOG_ERROR, "Could not find sender connection: '%s'\n", args.sender);
+ if (strchr(args.jid, '/')) {
+ ast_log(LOG_ERROR, "Invalid room name, resource must not be appended\n");
return -1;
}
- if (strchr(args.jid, '/')) {
- ast_log(LOG_ERROR, "Invalid room name, resource must not be appended\n");
- ASTOBJ_UNREF(client, aji_client_destroy);
+ if (!(client = ast_aji_get_client(args.sender))) {
+ ast_log(LOG_ERROR, "Could not find sender connection: '%s'\n", args.sender);
return -1;
}
+
if (!ast_strlen_zero(args.nick)) {
snprintf(nick, AJI_MAX_RESJIDLEN, "%s", args.nick);
} else {
if (!ast_strlen_zero(args.jid) && strchr(args.jid, '@')) {
ast_aji_leave_chat(client, args.jid, nick);
}
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return 0;
}
if (strchr(args.recipient, '@') && !ast_strlen_zero(args.message)) {
ast_aji_send_chat(client, args.recipient, args.message);
}
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return 0;
}
return -1;
}
-
ast_debug(1, "Sending message to '%s' from '%s'\n", dest, client->name);
res = ast_aji_send_chat(client, dest, ast_msg_get_body(msg));
ast_log(LOG_WARNING, "Failed to send xmpp message (%d).\n", res);
}
- /*
- * XXX Reference leak here. See note with ast_aji_get_client() about the problems
- * with that function.
- */
-
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return res == IKS_OK ? 0 : -1;
}
res = ast_aji_send_groupchat(client, nick, args.groupchat, args.message);
}
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
if (res != IKS_OK) {
return -1;
}
}
}
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
}
/*!
if (!node) {
ast_log(LOG_ERROR, "aji_act_hook was called with out a packet\n"); /* most likely cause type is IKS_NODE_ERROR lost connection */
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_HOOK;
}
if (client->state == AJI_DISCONNECTING) {
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_HOOK;
}
if (client->usetls && !aji_is_secure(client)) {
#ifndef HAVE_OPENSSL
ast_log(LOG_ERROR, "TLS connection cannot be established. Please install OpenSSL and its development libraries on this system, or disable the TLS option in your configuration file\n");
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_HOOK;
#else
if (aji_start_tls(client) == IKS_NET_TLSFAIL) {
ast_log(LOG_ERROR, "Could not start TLS\n");
- ASTOBJ_UNREF(client, aji_client_destroy);
- return IKS_HOOK;
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
+ return IKS_HOOK;
}
#endif
break;
ret = aji_start_sasl(client, features, client->jid->user, client->password);
if (ret != IKS_OK) {
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_HOOK;
}
break;
break;
case IKS_NODE_ERROR:
ast_log(LOG_ERROR, "JABBER: Node Error\n");
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_HOOK;
break;
case IKS_NODE_STOP:
ast_log(LOG_WARNING, "JABBER: Disconnected\n");
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_HOOK;
break;
}
case IKS_NODE_ERROR:
ast_log(LOG_ERROR, "JABBER: Node Error\n");
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_HOOK;
case IKS_NODE_STOP:
ast_log(LOG_WARNING, "JABBER: Disconnected\n");
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_HOOK;
}
}
if (node)
iks_delete(node);
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_OK;
}
/*!
iks_delete(presence);
iks_delete(x);
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_FILTER_EAT;
}
/*!
}
iks_delete(iq);
iks_delete(query);
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(buddy, ast_aji_buddy_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_FILTER_EAT;
}
iks_delete(feature);
}
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_FILTER_EAT;
}
if (pak->subtype == IKS_TYPE_RESULT) {
if (!resource) {
ast_log(LOG_NOTICE, "JABBER: Received client info from %s when not requested.\n", pak->from->full);
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(buddy, ast_aji_buddy_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_FILTER_EAT;
}
if (iks_find_with_attrib(pak->query, "feature", "var", "http://www.google.com/xmpp/protocol/voice/v1")) {
} else if (pak->subtype == IKS_TYPE_ERROR) {
ast_log(LOG_NOTICE, "User %s does not support discovery.\n", pak->from->full);
}
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(buddy, ast_aji_buddy_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_FILTER_EAT;
}
struct aji_resource *resource = NULL;
struct aji_buddy *buddy = ASTOBJ_CONTAINER_FIND(&client->buddies, pak->from->partial);
- resource = aji_find_resource(buddy, pak->from->resource);
if (pak->subtype == IKS_TYPE_ERROR) {
ast_log(LOG_WARNING, "Received error from a client, turn on jabber debug!\n");
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_FILTER_EAT;
}
+ resource = aji_find_resource(buddy, pak->from->resource);
if (pak->subtype == IKS_TYPE_RESULT) {
if (!resource) {
ast_log(LOG_NOTICE, "JABBER: Received client info from %s when not requested.\n", pak->from->full);
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(buddy, ast_aji_buddy_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_FILTER_EAT;
}
if (iks_find_with_attrib(pak->query, "feature", "var", "http://www.google.com/xmpp/protocol/voice/v1")) {
iks_delete(feature);
}
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(buddy, ast_aji_buddy_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_FILTER_EAT;
}
if (!found) {
ast_log(LOG_ERROR, "Out of memory!\n");
+ ASTOBJ_UNLOCK(buddy);
+ ASTOBJ_UNREF(buddy, ast_aji_buddy_destroy);
return;
}
ast_copy_string(found->resource, pak->from->resource, sizeof(found->resource));
}
ASTOBJ_UNLOCK(buddy);
- ASTOBJ_UNREF(buddy, aji_buddy_destroy);
+ ASTOBJ_UNREF(buddy, ast_aji_buddy_destroy);
node = iks_find_attrib(iks_find(pak->x, "c"), "node");
ver = iks_find_attrib(iks_find(pak->x, "c"), "ver");
buddy = ASTOBJ_CONTAINER_FIND(&client->buddies, pak->from->partial);
if (!buddy && pak->from->partial) {
aji_create_buddy(pak->from->partial, client);
+ } else if (buddy) {
+ ASTOBJ_UNREF(buddy, ast_aji_buddy_destroy);
}
default:
if (option_verbose > 4) {
ast_log(LOG_WARNING, "JABBER: socket read error\n");
}
} while (client);
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return 0;
}
if (send)
iks_delete(send);
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_FILTER_EAT;
}
iks_delete(reguser);
if (regpass)
iks_delete(regpass);
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_FILTER_EAT;
}
#endif
iks_delete(removeitem);
iks_delete(send);
- ASTOBJ_CONTAINER_PRUNE_MARKED(&client->buddies, aji_buddy_destroy);
+ ASTOBJ_CONTAINER_PRUNE_MARKED(&client->buddies, ast_aji_buddy_destroy);
}
/*!
buddy = ast_calloc(1, sizeof(*buddy));
if (!buddy) {
ast_log(LOG_WARNING, "Out of memory\n");
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return 0;
}
ASTOBJ_INIT(buddy);
ASTOBJ_UNLOCK(buddy);
if (buddy) {
ASTOBJ_CONTAINER_LINK(&client->buddies, buddy);
- ASTOBJ_UNREF(buddy, aji_buddy_destroy);
+ ASTOBJ_UNREF(buddy, ast_aji_buddy_destroy);
}
}
x = iks_next(x);
iks_delete(x);
aji_pruneregister(client);
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_FILTER_EAT;
}
ast_log(LOG_ERROR, "Out of memory.\n");
}
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return res;
}
#endif
iks_disconnect(client->p);
iks_parser_delete(client->p);
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
}
return 1;
snprintf(newmsgs, sizeof(newmsgs), "%d",
ast_event_get_ie_uint(ast_event, AST_EVENT_IE_NEWMSGS));
aji_publish_mwi(client, mailbox, context, oldmsgs, newmsgs);
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
}
/*!
device = ast_event_get_ie_str(ast_event, AST_EVENT_IE_DEVICE);
device_state = ast_devstate_str(ast_event_get_ie_uint(ast_event, AST_EVENT_IE_STATE));
aji_publish_device_state(client, device, device_state);
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
}
/*!
iks_insert_node(request, orig_pubsub);
ast_aji_send(client, request);
iks_delete(request);
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_FILTER_EAT;
} else if (!strcasecmp(iks_name(orig_request), "subscribe")) {
if (ast_test_flag(&pubsubflags, AJI_XEP0248)) {
aji_create_pubsub_node(client, NULL, node_name, NULL);
}
}
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_FILTER_EAT;
}
if (item) {
iks_delete(item);
}
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_FILTER_EAT;
}
if (a->argc == 5) {
collection = a->argv[4];
}
- if (!(client = ASTOBJ_CONTAINER_FIND(&clients, name))) {
+ if (!(client = ASTOBJ_CONTAINER_FIND(&clients, name))) {
ast_cli(a->fd, "Unable to find client '%s'!\n", name);
return CLI_FAILURE;
}
ast_cli(a->fd, "Listing pubsub nodes.\n");
aji_request_pubsub_nodes(client, collection);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return CLI_SUCCESS;
}
} else {
aji_delete_pubsub_node(client, a->argv[4]);
}
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return CLI_SUCCESS;
}
return CLI_FAILURE;
}
aji_delete_pubsub_node(client, a->argv[4]);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return CLI_SUCCESS;
}
ast_cli(a->fd, "Creating test PubSub node collection.\n");
aji_create_pubsub_collection(client, collection_name);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return CLI_SUCCESS;
}
ast_cli(a->fd, "Creating test PubSub node collection.\n");
aji_create_pubsub_leaf(client, collection_name, leaf_name);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return CLI_SUCCESS;
}
//ast_verbose(" Message from: %s with id %s @ %s %s\n",tmp->from, S_OR(tmp->id,""), ctime(&tmp->arrived), S_OR(tmp->message, ""));
}
AST_LIST_UNLOCK(&client->messages);
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return CLI_SUCCESS;
}
}
if (!flag) {
ASTOBJ_UNLOCK(client);
- ASTOBJ_UNREF(client, aji_client_destroy);
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
return 1;
}
{
char *server = NULL, *buddyname = NULL, *user = NULL, *pass = NULL;
struct aji_buddy *buddy = NULL;
+ int needs_unref = 1;
buddy = ASTOBJ_CONTAINER_FIND(&client->buddies,label);
if (!buddy) {
+ needs_unref = 0;
buddy = ast_calloc(1, sizeof(*buddy));
if (!buddy) {
ast_log(LOG_WARNING, "Out of memory\n");
ast_copy_string(buddy->user, user, sizeof(buddy->user));
ast_copy_string(buddy->name, buddyname, sizeof(buddy->name));
ast_copy_string(buddy->server, server, sizeof(buddy->server));
+ if (needs_unref) {
+ ASTOBJ_UNMARK(buddy);
+ ASTOBJ_UNREF(buddy, ast_aji_buddy_destroy);
+ }
return 1;
}
}
}
}
ASTOBJ_UNLOCK(buddy);
- ASTOBJ_UNMARK(buddy);
- ASTOBJ_CONTAINER_LINK(&client->buddies, buddy);
+ if (needs_unref) {
+ ASTOBJ_UNMARK(buddy);
+ ASTOBJ_UNREF(buddy, ast_aji_buddy_destroy);
+ } else {
+ ASTOBJ_CONTAINER_LINK(&client->buddies, buddy);
+ }
return 0;
}
#endif
static int aji_create_buddy(char *label, struct aji_client *client)
{
struct aji_buddy *buddy = NULL;
- int flag = 0;
+ int needs_unref = 1;
buddy = ASTOBJ_CONTAINER_FIND(&client->buddies, label);
if (!buddy) {
- flag = 1;
+ needs_unref = 0;
buddy = ast_calloc(1, sizeof(*buddy));
if (!buddy) {
ast_log(LOG_WARNING, "Out of memory\n");
ASTOBJ_WRLOCK(buddy);
ast_copy_string(buddy->name, label, sizeof(buddy->name));
ASTOBJ_UNLOCK(buddy);
- if (flag) {
- ASTOBJ_CONTAINER_LINK(&client->buddies, buddy);
- } else {
+ if (needs_unref) {
ASTOBJ_UNMARK(buddy);
- ASTOBJ_UNREF(buddy, aji_buddy_destroy);
+ ASTOBJ_UNREF(buddy, ast_aji_buddy_destroy);
+ } else {
+ ASTOBJ_CONTAINER_LINK(&client->buddies, buddy);
}
return 1;
}
}
/*!
- * \brief grab a aji_client structure by label name or JID
+ * \brief grab a aji_client structure by label name or JID. Bumps the refcount.
* (without the resource string)
* \param name label or JID
* \return aji_client.
- *
- * XXX \bug This function leads to reference leaks all over the place.
- * ASTOBJ_CONTAINER_FIND() returns a reference, but if the
- * client is found via the traversal, no reference is returned.
- * None of the calling code releases references. This code needs
- * to be changed to always return a reference, and all of the users
- * need to be fixed to release them.
*/
struct aji_client *ast_aji_get_client(const char *name)
{
aux = strsep(&aux, "/");
}
if (!strncasecmp(aux, name, strlen(aux))) {
- client = iterator;
+ client = ASTOBJ_REF(iterator);
}
});
}
} else {
astman_append(s, "Response: Error\r\n");
}
+ ASTOBJ_UNREF(client, ast_aji_client_destroy);
if (!ast_strlen_zero(id)) {
astman_append(s, "ActionID: %s\r\n", id);
}
} else if (res == -1)
return 1;
- ASTOBJ_CONTAINER_PRUNE_MARKED(&clients, aji_client_destroy);
+ ASTOBJ_CONTAINER_PRUNE_MARKED(&clients, ast_aji_client_destroy);
ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
ASTOBJ_RDLOCK(iterator);
if (iterator->state == AJI_DISCONNECTED) {
ast_aji_disconnect(iterator);
});
- ASTOBJ_CONTAINER_DESTROYALL(&clients, aji_client_destroy);
+ ASTOBJ_CONTAINER_DESTROYALL(&clients, ast_aji_client_destroy);
ASTOBJ_CONTAINER_DESTROY(&clients);
ast_cond_destroy(&message_received_condition);