diff options
-rw-r--r-- | channels/chan_sip.c | 8 | ||||
-rw-r--r-- | include/asterisk/features.h | 5 | ||||
-rw-r--r-- | res/res_features.c | 15 |
3 files changed, 22 insertions, 6 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 41234b8e2..60e6ee577 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -11653,14 +11653,17 @@ static void handle_request_info(struct sip_pvt *p, struct sip_request *req) pbx. */ /* first, get the feature string, if it exists */ - struct ast_call_feature *feat = ast_find_call_feature("automon"); + struct ast_call_feature *feat; int j; struct ast_frame f = { AST_FRAME_DTMF, }; - + + ast_rdlock_call_features(); + feat = ast_find_call_feature("automon"); if (!feat || ast_strlen_zero(feat->exten)) { ast_log(LOG_WARNING,"Recording requested, but no One Touch Monitor registered. (See features.conf)\n"); /* 403 means that we don't support this feature, so don't request it again */ transmit_response(p, "403 Forbidden", req); + ast_unlock_call_features(); return; } /* OEJ: Why is the DTMF code included in the record section? */ @@ -11671,6 +11674,7 @@ static void handle_request_info(struct sip_pvt *p, struct sip_request *req) if (sipdebug) ast_verbose("* DTMF-relay event received: %c\n", f.subclass); } + ast_unlock_call_features(); #ifdef DISABLED_CODE /* And feat isn't used here - Is this code tested at all??? We just send a reply ... diff --git a/include/asterisk/features.h b/include/asterisk/features.h index 2174e99e1..1a5d760f3 100644 --- a/include/asterisk/features.h +++ b/include/asterisk/features.h @@ -96,6 +96,9 @@ void ast_unregister_feature(struct ast_call_feature *feature); /*! \brief look for a call feature entry by its sname \param name a string ptr, should match "automon", "blindxfer", "atxfer", etc. */ -struct ast_call_feature *ast_find_call_feature(char *name); +struct ast_call_feature *ast_find_call_feature(const char *name); + +void ast_rdlock_call_features(void); +void ast_unlock_call_features(void); #endif /* _AST_FEATURES_H */ diff --git a/res/res_features.c b/res/res_features.c index 7177df0d5..2ae98343c 100644 --- a/res/res_features.c +++ b/res/res_features.c @@ -1070,14 +1070,23 @@ static struct ast_call_feature *find_feature(const char *name) return tmp; } +void ast_rdlock_call_features(void) +{ + ast_rwlock_rdlock(&features_lock); +} + +void ast_unlock_call_features(void) +{ + ast_rwlock_unlock(&features_lock); +} + /*! \brief find a call feature by name */ -struct ast_call_feature *ast_find_call_feature(char *name) +struct ast_call_feature *ast_find_call_feature(const char *name) { int x; for (x = 0; x < FEATURES_COUNT; x++) { - if (!strcasecmp(name, builtin_features[x].sname)) { + if (!strcasecmp(name, builtin_features[x].sname)) return &builtin_features[x]; - } } return NULL; } |