Uploaded image for project: 'FreeSWITCH'
  1. FreeSWITCH
  2. FS-9810

ws write fail on slow network

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.8.0
    • Component/s: mod_verto
    • Labels:
      None
    • CPU Architecture:
      x86-64
    • Kernel:
      Linux
    • Userland:
      GNU/Linux
    • Distribution:
      Debian
    • Distribution Version:
      Debian 8 jessie
    • Compiler:
      gcc
    • FreeSWITCH GIT Revision:
      89063a1a4c396c8d00867423c0b353aa4a6ee020
    • GIT Master Revision hash::
      89063a1a4c396c8d00867423c0b353aa4a6ee020

      Description

      When working verto on a slow server ws_raw_writes fails constantly.

      Technically because we use socket in non-block mode but we write too quick and triggered EAGAIN, it is supposed to block forever in wsh->block mode, however, I made some improve to just wait a little longer. If the code looks ok, I can fix all ws.c in sofia and libks and push.

      diff pasted inline for easy review.

      diff --git a/src/mod/endpoints/mod_verto/ws.c b/src/mod/endpoints/mod_verto/ws.c
      index 087374c..20712a8 100644
      — a/src/mod/endpoints/mod_verto/ws.c
      +++ b/src/mod/endpoints/mod_verto/ws.c
      @@ -420,7 +420,16 @@ ssize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes)
      }

      if (sanity < 2000) {

      • ms_sleep(1);
        + int ms = 1;
        +
        + if (wsh->block)
        Unknown macro: {+ if (sanity < 1500) { + ms = 60; + } else if (sanity < 1000) { + ms = 10; + }+ }

        + ms_sleep(ms);
        }

      if (r == -1)

      { @@ -444,7 +453,16 @@ ssize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes) }

      if (sanity < 2000) {

      • ms_sleep(1);
        + int ms = 1;
        +
        + if (wsh->block)
        Unknown macro: {+ if (sanity < 1500) { + ms = 60; + } else if (sanity < 1000) { + ms = 10; + }+ }

        + ms_sleep(ms);
        }

      } while (-sanity > 0 && ((r == -1 && xp_is_blocking(xp_errno())) || (wsh>block && wrote < bytes)));
      @@ -453,7 +471,7 @@ ssize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes)
      //printf("wRITE FAIL: %s\n", strerror(errno));
      //}

      • return r;
        + return r < 0 ? r : wrote;
        }

      #ifdef _MSC_VER

        Attachments

          Activity

            People

            • Assignee:
              seven Seven Du
              Reporter:
              seven Seven Du
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: