[asterisk-commits] [svn-commits] tilghman: trunk r111132 - in /trunk: include/asterisk/ main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 26 14:58:09 CDT 2008
Author: tilghman
Date: Wed Mar 26 14:58:09 2008
New Revision: 111132
URL: http://svn.digium.com/view/asterisk?view=rev&rev=111132
Log:
Simplify new macro, simplify configfile logic, now that list is sorted
Modified:
trunk/include/asterisk/linkedlists.h
trunk/main/config.c
Modified: trunk/include/asterisk/linkedlists.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/linkedlists.h?view=diff&rev=111132&r1=111131&r2=111132
==============================================================================
--- trunk/include/asterisk/linkedlists.h (original)
+++ trunk/include/asterisk/linkedlists.h Wed Mar 26 14:58:09 2008
@@ -712,15 +712,12 @@
prev = cur; \
cur = cur->field.next; \
} \
- if (!prev) { /* Same as INSERT_HEAD */ \
- (elm)->field.next = (head)->first; \
- (head)->first = (elm); \
- } else if (!cur) { /* Same as INSERT_TAIL */ \
- (head)->last->field.next = (elm); \
- (head)->last = (elm); \
+ if (!prev) { \
+ AST_LIST_INSERT_HEAD(head, elm, field); \
+ } else if (!cur) { \
+ AST_LIST_INSERT_TAIL(head, elm, field); \
} else { \
- (elm)->field.next = cur; \
- (prev)->field.next = (elm); \
+ AST_LIST_INSERT_AFTER(head, prev, elm, field); \
} \
} \
} while (0)
Modified: trunk/main/config.c
URL: http://svn.digium.com/view/asterisk/trunk/main/config.c?view=diff&rev=111132&r1=111131&r2=111132
==============================================================================
--- trunk/main/config.c (original)
+++ trunk/main/config.c Wed Mar 26 14:58:09 2008
@@ -2348,12 +2348,7 @@
static char *handle_cli_config_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct cache_file_mtime *cfmtime;
- struct seenlist {
- AST_LIST_ENTRY(seenlist) list;
- char filename[0];
- } *seenlist;
- AST_LIST_HEAD_NOLOCK(, seenlist) seenhead = AST_LIST_HEAD_NOLOCK_INIT_VALUE;
- char *completion_value = NULL;
+ char *prev = "", *completion_value = NULL;
int wordlen, which = 0;
switch (cmd) {
@@ -2372,15 +2367,13 @@
AST_LIST_LOCK(&cfmtime_head);
AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) {
- int seen = 0;
- AST_LIST_TRAVERSE(&seenhead, seenlist, list) {
- if (strcmp(seenlist->filename, cfmtime->filename) == 0) {
- seen = 1;
- break;
- }
- }
-
- if (seen) {
+ /* Skip duplicates - this only works because the list is sorted by filename */
+ if (strcmp(cfmtime->filename, prev) == 0) {
+ continue;
+ }
+
+ /* Core configs cannot be reloaded */
+ if (ast_strlen_zero(cfmtime->who_asked)) {
continue;
}
@@ -2390,18 +2383,9 @@
}
/* Otherwise save that we've seen this filename */
- if (!(seenlist = ast_malloc(sizeof(*seenlist) + strlen(cfmtime->filename) + 1))) {
- break;
- }
- strcpy(seenlist->filename, cfmtime->filename);
- AST_LIST_INSERT_HEAD(&seenhead, seenlist, list);
+ prev = cfmtime->filename;
}
AST_LIST_UNLOCK(&cfmtime_head);
-
- /* Remove seenlist */
- while ((seenlist = AST_LIST_REMOVE_HEAD(&seenhead, list))) {
- ast_free(seenlist);
- }
return completion_value;
}
@@ -2440,7 +2424,7 @@
AST_LIST_LOCK(&cfmtime_head);
AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) {
- ast_cli(a->fd, "%-20.20s %-50s\n", cfmtime->who_asked, cfmtime->filename);
+ ast_cli(a->fd, "%-20.20s %-50s\n", S_OR(cfmtime->who_asked, "core"), cfmtime->filename);
}
AST_LIST_UNLOCK(&cfmtime_head);
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
svn-commits mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/svn-commits
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the asterisk-commits
mailing list