Index: res/res_agi.c =================================================================== --- res/res_agi.c (revision 140603) +++ res/res_agi.c (working copy) @@ -2092,7 +2092,7 @@ return -1; } - return 0; + return res; } static int agi_exec(struct ast_channel *chan, void *data) Index: res/res_features.c =================================================================== --- res/res_features.c (revision 140603) +++ res/res_features.c (working copy) @@ -1083,8 +1083,13 @@ ast_autoservice_stop(idle); - if (res == AST_PBX_KEEPALIVE) - return FEATURE_RETURN_PBX_KEEPALIVE; + if (res == AST_PBX_KEEPALIVE) { + /* do not hangup peer if feature is to be activated on it */ + if ((ast_test_flag(feature, AST_FEATURE_FLAG_ONPEER) && sense == FEATURE_SENSE_CHAN) || (ast_test_flag(feature, AST_FEATURE_FLAG_ONSELF) && sense == FEATURE_SENSE_PEER)) + return FEATURE_RETURN_NO_HANGUP_PEER; + else + return FEATURE_RETURN_PBX_KEEPALIVE; + } else if (res == AST_PBX_NO_HANGUP_PEER) return FEATURE_RETURN_NO_HANGUP_PEER; else if (res) @@ -1125,10 +1130,11 @@ { int x; struct ast_flags features; - int res = FEATURE_RETURN_PASSDIGITS; struct ast_call_feature *feature; const char *dynamic_features; char *tmp, *tok; + int res = FEATURE_RETURN_PASSDIGITS; + int feature_detected = 0; if (sense == FEATURE_SENSE_CHAN) { ast_copy_flags(&features, &(config->features_caller), AST_FLAGS_ALL); @@ -1147,6 +1153,7 @@ /* Feature is up for consideration */ if (!strcmp(builtin_features[x].exten, code)) { res = builtin_features[x].operation(chan, peer, config, code, sense, NULL); + feature_detected = 1; break; } else if (!strncmp(builtin_features[x].exten, code, strlen(code))) { if (res == FEATURE_RETURN_PASSDIGITS) @@ -1156,7 +1163,7 @@ } ast_rwlock_unlock(&features_lock); - if (ast_strlen_zero(dynamic_features)) + if (ast_strlen_zero(dynamic_features) || feature_detected) return res; tmp = ast_strdupa(dynamic_features);