[asterisk-commits] dvossel: branch 1.6.1 r178769 - in /branches/1.6.1: ./ channels/chan_iax2.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Feb 26 10:07:11 CST 2009
Author: dvossel
Date: Thu Feb 26 10:07:08 2009
New Revision: 178769
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=178769
Log:
Merged revisions 178767 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r178767 | dvossel | 2009-02-26 09:50:22 -0600 (Thu, 26 Feb 2009) | 8 lines
IAX2 prune realtime fix
Iax2 prune realtime had issues. If "iax2 prune realtime all" was called, it would appear like the command was successful, but in reality nothing happened. This is because the reload that was supposed to take place checks the config files, sees no changes, and does nothing. If there had been a change in the the config file, the realtime users would have been marked for deletion and everything would have been fine. Now prune_users() and prune_peers() are called instead of reload_config() to prune all users/peers that are realtime. These functions remove all users/peers with the rtfriend and delme flags set. iax2_prune_realtime() also lacked the code to properly delete a single friend. For example. if iax2 prune realtime <friend> was called, only the peer instance would be removed. The user would still remain.
(closes issue #14479)
Reported by: mousepad99
Review: http://reviewboard.digium.com/r/176/
........
Modified:
branches/1.6.1/ (props changed)
branches/1.6.1/channels/chan_iax2.c
Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.
Modified: branches/1.6.1/channels/chan_iax2.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.1/channels/chan_iax2.c?view=diff&rev=178769&r1=178768&r2=178769
==============================================================================
--- branches/1.6.1/channels/chan_iax2.c (original)
+++ branches/1.6.1/channels/chan_iax2.c Thu Feb 26 10:07:08 2009
@@ -971,8 +971,9 @@
static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly);
static struct iax2_user *build_user(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly);
static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, time_t regtime);
+static void *iax2_dup_variable_datastore(void *);
static void prune_peers(void);
-static void *iax2_dup_variable_datastore(void *);
+static void prune_users(void);
static void iax2_free_variable_datastore(void *);
static int acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen);
@@ -1380,6 +1381,14 @@
return NULL;
}
+static struct iax2_user *find_user(const char *name)
+{
+ struct iax2_user tmp_user = {
+ .name = name,
+ };
+
+ return ao2_find(users, &tmp_user, OBJ_POINTER);
+}
static inline struct iax2_user *user_ref(struct iax2_user *user)
{
ao2_ref(user, +1);
@@ -2525,7 +2534,8 @@
static char *handle_cli_iax2_prune_realtime(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- struct iax2_peer *peer;
+ struct iax2_peer *peer = NULL;
+ struct iax2_user *user = NULL;
switch (cmd) {
case CLI_INIT:
@@ -2539,25 +2549,40 @@
return complete_iax2_peers(a->line, a->word, a->pos, a->n);
return NULL;
}
-
if (a->argc != 4)
return CLI_SHOWUSAGE;
if (!strcmp(a->argv[3], "all")) {
- reload_config();
+ prune_users();
+ prune_peers();
ast_cli(a->fd, "Cache flushed successfully.\n");
- } else if ((peer = find_peer(a->argv[3], 0))) {
- if(ast_test_flag(peer, IAX_RTCACHEFRIENDS)) {
- ast_set_flag(peer, IAX_RTAUTOCLEAR);
- expire_registry(peer_ref(peer));
- ast_cli(a->fd, "Peer %s was removed from the cache.\n", a->argv[3]);
- } else {
- ast_cli(a->fd, "Peer %s is not eligible for this operation.\n", a->argv[3]);
- }
- peer_unref(peer);
+ }
+ peer = find_peer(a->argv[3], 0);
+ user = find_user(a->argv[3]);
+ if (peer || user) {
+ if (peer) {
+ if (ast_test_flag(peer, IAX_RTCACHEFRIENDS)) {
+ ast_set_flag(peer, IAX_RTAUTOCLEAR);
+ expire_registry(peer_ref(peer));
+ ast_cli(a->fd, "Peer %s was removed from the cache.\n", a->argv[3]);
+ } else {
+ ast_cli(a->fd, "Peer %s is not eligible for this operation.\n", a->argv[3]);
+ }
+ peer_unref(peer);
+ }
+ if (user) {
+ if (ast_test_flag(user, IAX_RTCACHEFRIENDS)) {
+ ast_set_flag(user, IAX_RTAUTOCLEAR);
+ ast_cli(a->fd, "User %s was removed from the cache.\n", a->argv[3]);
+ } else {
+ ast_cli(a->fd, "User %s is not eligible for this operation.\n", a->argv[3]);
+ }
+ ao2_unlink(users,user);
+ user_unref(user);
+ }
} else {
- ast_cli(a->fd, "Peer %s was not found in the cache.\n", a->argv[3]);
- }
-
+ ast_cli(a->fd, "%s was not found in the cache.\n", a->argv[3]);
+ }
+
return CLI_SUCCESS;
}
@@ -11020,8 +11045,9 @@
i = ao2_iterator_init(users, 0);
while ((user = ao2_iterator_next(&i))) {
- if (ast_test_flag(user, IAX_DELME))
+ if (ast_test_flag(user, IAX_DELME) || ast_test_flag(user, IAX_RTCACHEFRIENDS)) {
ao2_unlink(users, user);
+ }
user_unref(user);
}
}
@@ -11034,8 +11060,9 @@
i = ao2_iterator_init(peers, 0);
while ((peer = ao2_iterator_next(&i))) {
- if (ast_test_flag(peer, IAX_DELME))
+ if (ast_test_flag(peer, IAX_DELME) || ast_test_flag(peer, IAX_RTCACHEFRIENDS)) {
unlink_peer(peer);
+ }
peer_unref(peer);
}
}
More information about the asterisk-commits
mailing list