Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-1501

Wait-indefinitely hang bug in WebSocket session container shutdown code.

XMLWordPrintable

      There is a wait-indefinitely bug in the WebSocket session container where `wait(0)` may be called due to a split condition/use problem. This could cause a thread to hang indefinitely if `current time < end` is checked with 1 tick to go, and `wait` is called after the next clock tick. If the thread blocks between calls, it could also spuriously throw an IllegalArgumentException due to a negative argument.

      Current code:

                  long end = System.currentTimeMillis() + timeout;
                  try {
                      while (System.currentTimeMillis() < end && !openSessions.isEmpty()) {
                          wait(end - System.currentTimeMillis());
                      }
      

      Correct code:

                  long cur,end = System.currentTimeMillis() + timeout;
                  try {
                      while ((cur=System.currentTimeMillis()) < end && !openSessions.isEmpty()) {
                          wait(end - cur);
                      }
      

              rhn-cservice-bbaranow Bartosz Baranowski
              lawrence-dol L. Cornelius Dol
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: