mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-08 19:08:14 +00:00
Simplify new macro, simplify configfile logic, now that list is sorted
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@111132 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -712,15 +712,12 @@ struct { \
|
|||||||
prev = cur; \
|
prev = cur; \
|
||||||
cur = cur->field.next; \
|
cur = cur->field.next; \
|
||||||
} \
|
} \
|
||||||
if (!prev) { /* Same as INSERT_HEAD */ \
|
if (!prev) { \
|
||||||
(elm)->field.next = (head)->first; \
|
AST_LIST_INSERT_HEAD(head, elm, field); \
|
||||||
(head)->first = (elm); \
|
} else if (!cur) { \
|
||||||
} else if (!cur) { /* Same as INSERT_TAIL */ \
|
AST_LIST_INSERT_TAIL(head, elm, field); \
|
||||||
(head)->last->field.next = (elm); \
|
|
||||||
(head)->last = (elm); \
|
|
||||||
} else { \
|
} else { \
|
||||||
(elm)->field.next = cur; \
|
AST_LIST_INSERT_AFTER(head, prev, elm, field); \
|
||||||
(prev)->field.next = (elm); \
|
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|||||||
@@ -2348,12 +2348,7 @@ static char *handle_cli_core_show_config_mappings(struct ast_cli_entry *e, int c
|
|||||||
static char *handle_cli_config_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
static char *handle_cli_config_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
||||||
{
|
{
|
||||||
struct cache_file_mtime *cfmtime;
|
struct cache_file_mtime *cfmtime;
|
||||||
struct seenlist {
|
char *prev = "", *completion_value = NULL;
|
||||||
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;
|
|
||||||
int wordlen, which = 0;
|
int wordlen, which = 0;
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
@@ -2372,15 +2367,13 @@ static char *handle_cli_config_reload(struct ast_cli_entry *e, int cmd, struct a
|
|||||||
|
|
||||||
AST_LIST_LOCK(&cfmtime_head);
|
AST_LIST_LOCK(&cfmtime_head);
|
||||||
AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) {
|
AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) {
|
||||||
int seen = 0;
|
/* Skip duplicates - this only works because the list is sorted by filename */
|
||||||
AST_LIST_TRAVERSE(&seenhead, seenlist, list) {
|
if (strcmp(cfmtime->filename, prev) == 0) {
|
||||||
if (strcmp(seenlist->filename, cfmtime->filename) == 0) {
|
continue;
|
||||||
seen = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seen) {
|
/* Core configs cannot be reloaded */
|
||||||
|
if (ast_strlen_zero(cfmtime->who_asked)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2390,19 +2383,10 @@ static char *handle_cli_config_reload(struct ast_cli_entry *e, int cmd, struct a
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise save that we've seen this filename */
|
/* Otherwise save that we've seen this filename */
|
||||||
if (!(seenlist = ast_malloc(sizeof(*seenlist) + strlen(cfmtime->filename) + 1))) {
|
prev = cfmtime->filename;
|
||||||
break;
|
|
||||||
}
|
|
||||||
strcpy(seenlist->filename, cfmtime->filename);
|
|
||||||
AST_LIST_INSERT_HEAD(&seenhead, seenlist, list);
|
|
||||||
}
|
}
|
||||||
AST_LIST_UNLOCK(&cfmtime_head);
|
AST_LIST_UNLOCK(&cfmtime_head);
|
||||||
|
|
||||||
/* Remove seenlist */
|
|
||||||
while ((seenlist = AST_LIST_REMOVE_HEAD(&seenhead, list))) {
|
|
||||||
ast_free(seenlist);
|
|
||||||
}
|
|
||||||
|
|
||||||
return completion_value;
|
return completion_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2440,7 +2424,7 @@ static char *handle_cli_config_list(struct ast_cli_entry *e, int cmd, struct ast
|
|||||||
|
|
||||||
AST_LIST_LOCK(&cfmtime_head);
|
AST_LIST_LOCK(&cfmtime_head);
|
||||||
AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) {
|
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);
|
AST_LIST_UNLOCK(&cfmtime_head);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user