]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10634 [mod_spandsp]: txfax failing with 488 Not Acceptable Here race
authorBrian West <brian@freeswitch.org>
Tue, 4 Jun 2019 22:12:47 +0000 (17:12 -0500)
committerAndrey Volk <andywolk@gmail.com>
Wed, 17 Jul 2019 20:32:53 +0000 (00:32 +0400)
src/include/switch_channel.h
src/switch_channel.c
src/switch_core_media.c

index ec066852c6db462d5dc8389ec34afd0571b44f4e..3786d4583c8f1907e85a69bbcceb50560f8143d7 100644 (file)
@@ -101,6 +101,9 @@ SWITCH_DECLARE(void) switch_channel_wait_for_state_timeout(switch_channel_t *oth
 SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *channel,
                                                                                                                         switch_channel_flag_t want_flag,
                                                                                                                         switch_bool_t pres, uint32_t to, switch_channel_t *super_channel);
+SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_app_flag(switch_channel_t *channel,
+                                                                                                                                uint32_t app_flag,
+                                                                                                                                const char *key, switch_bool_t pres, uint32_t to);
 
 SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_channel_t *channel,
                                                                                                                                                const char *file, const char *func, int line, switch_channel_state_t state);
index c638fbc6285c9ff925628177e94d706a4d8b4e72..934db1e0471f890c0189d255652335a03cf13d9b 100644 (file)
@@ -1748,6 +1748,39 @@ SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *c
        return SWITCH_STATUS_SUCCESS;
 }
 
+SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_app_flag(switch_channel_t *channel,
+                                                                                                                                uint32_t app_flag,
+                                                                                                                                const char *key, switch_bool_t pres, uint32_t to)
+{
+       if (to) {
+               to++;
+       }
+
+       for (;;) {
+               if (pres) {
+                       if (switch_channel_test_app_flag_key(key, channel, app_flag)) {
+                               break;
+                       }
+               } else {
+                       if (!switch_channel_test_app_flag_key(key, channel, app_flag)) {
+                               break;
+                       }
+               }
+
+               switch_cond_next();
+
+               if (switch_channel_down(channel)) {
+                       return SWITCH_STATUS_FALSE;
+               }
+
+               if (to && !--to) {
+                       return SWITCH_STATUS_FALSE;
+               }
+       }
+
+       return SWITCH_STATUS_SUCCESS;
+}
+
 
 SWITCH_DECLARE(void) switch_channel_set_cap_value(switch_channel_t *channel, switch_channel_cap_t cap, uint32_t value)
 {
index 4552ba8d9c3ea296f4fd812fb7fb2c3f487469d9..e7bce84b437ef6aa9fbab350b2a17df52a91dbc2 100644 (file)
@@ -5223,9 +5223,8 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
                                        }
                                }
 
-
                                /* do nothing here, mod_fax will trigger a response (if it's listening =/) */
-                               if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38_POSSIBLE)) {
+                               if (switch_channel_wait_for_app_flag(channel, CF_APP_T38_POSSIBLE, "T38", SWITCH_TRUE, 2000)) {
                                        fmatch = 1;
                                } else {