diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-04-09 18:54:07 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-04-09 18:54:07 +0000 |
commit | 51619d3133bb07d5b183fc6686ed58ea10b27487 (patch) | |
tree | c2e518150fa08a553e1c2982f6f2b3d0fdc41f5d /main | |
parent | ec4e742c18ef17aa1ab4c324e42b8a10439461c1 (diff) |
Merged revisions 187483 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r187483 | tilghman | 2009-04-09 13:40:01 -0500 (Thu, 09 Apr 2009) | 15 lines
Merged revisions 187428 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r187428 | tilghman | 2009-04-09 13:08:20 -0500 (Thu, 09 Apr 2009) | 8 lines
Race condition between ast_cli_command() and 'module unload' could cause a deadlock.
Add lock timeouts to avoid this potential deadlock.
(closes issue #14705)
Reported by: jamessan
Patches:
20090320__bug14705.diff.txt uploaded by tilghman (license 14)
Tested by: jamessan
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@187486 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/manager.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/main/manager.c b/main/manager.c index 92cf462d7..eb7e43f5f 100644 --- a/main/manager.c +++ b/main/manager.c @@ -3338,8 +3338,12 @@ int __manager_event(int category, const char *event, int ast_manager_unregister(char *action) { struct manager_action *cur; + struct timespec tv = { 5, }; - AST_RWLIST_WRLOCK(&actions); + if (AST_RWLIST_TIMEDWRLOCK(&actions, &tv)) { + ast_log(LOG_ERROR, "Could not obtain lock on manager list\n"); + return -1; + } AST_RWLIST_TRAVERSE_SAFE_BEGIN(&actions, cur, list) { if (!strcasecmp(action, cur->action)) { AST_RWLIST_REMOVE_CURRENT(list); @@ -3348,7 +3352,7 @@ int ast_manager_unregister(char *action) break; } } - AST_RWLIST_TRAVERSE_SAFE_END; + AST_RWLIST_TRAVERSE_SAFE_END AST_RWLIST_UNLOCK(&actions); return 0; @@ -3367,8 +3371,12 @@ static int manager_state_cb(char *context, char *exten, int state, void *data) static int ast_manager_register_struct(struct manager_action *act) { struct manager_action *cur, *prev = NULL; + struct timespec tv = { 5, }; - AST_RWLIST_WRLOCK(&actions); + if (AST_RWLIST_TIMEDWRLOCK(&actions, &tv)) { + ast_log(LOG_ERROR, "Could not obtain lock on manager list\n"); + return -1; + } AST_RWLIST_TRAVERSE(&actions, cur, list) { int ret = strcasecmp(cur->action, act->action); if (ret == 0) { @@ -3381,8 +3389,8 @@ static int ast_manager_register_struct(struct manager_action *act) break; } } - - if (prev) + + if (prev) AST_RWLIST_INSERT_AFTER(&actions, prev, act, list); else AST_RWLIST_INSERT_HEAD(&actions, act, list); @@ -3409,7 +3417,10 @@ int ast_manager_register2(const char *action, int auth, int (*func)(struct manse cur->synopsis = synopsis; cur->description = description; - ast_manager_register_struct(cur); + if (ast_manager_register_struct(cur)) { + ast_free(cur); + return -1; + } return 0; } |