MINA
  1. MINA
  2. DIRMINA-241

Calling other session's write() in messageReceived() handler causes deadlock when a SSLFilter is used.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.0, 1.0.1, 1.0.2
    • Fix Version/s: 1.0.3
    • Component/s: Filter
    • Labels:
      None

      Description

      Hello,
      Could you advise for me about this problem.
      I attached server thread thumb.

      I run the server , There are many clients,

      When I use session.write , it happened deadlock.
      I don't know why~

      > this is some sample about multicast.
      public void multicast(String channelName, Object message) {
      if (!(message instanceof ByteBuffer))

      { return; }

      ByteBuffer rb = (ByteBuffer) message;
      // try{
      GameRoom channel = RoomManager.getRoom(channelName);
      List list = (List) channel.getUsers();
      Iterator it = list.iterator();
      while (it.hasNext())

      { ByteBuffer buf = rb.duplicate(); User user = (User) it.next(); WrteFuture future = users.getSession().write(buf); future.join(); }

      rb.release();
      // }catch(Throwable t)

      { // }

      }

        Activity

        ncanis created issue -
        Hide
        Trustin Lee added a comment -

        It seems like the deadlock occurred because you tried broadcasting messages to multiple sessions. Two sessions were broadcasting messages to each other and it caused the deadlock in SSLFilter. Please try to send messages in a dedicated background thread for now, or disable SSLFilter temporarilly. We need to find out the best solution for this issue.

        Show
        Trustin Lee added a comment - It seems like the deadlock occurred because you tried broadcasting messages to multiple sessions. Two sessions were broadcasting messages to each other and it caused the deadlock in SSLFilter. Please try to send messages in a dedicated background thread for now, or disable SSLFilter temporarilly. We need to find out the best solution for this issue.
        Trustin Lee made changes -
        Field Original Value New Value
        Fix Version/s 1.0.3 [ 12312290 ]
        Affects Version/s 1.0.0 [ 11070 ]
        Component/s Filter [ 12311385 ]
        Environment windows xp
        Assignee Trustin Lee [ trustin ]
        Affects Version/s 1.0.2 [ 12312210 ]
        Affects Version/s 1.0.1 [ 12312080 ]
        Summary When I used session.write(message), it was invoked deadlock. Calling other session's write() in messageReceived() handler causes deadlock when a SSLFilter is used.
        Hide
        Trustin Lee added a comment -

        The fix for this long-standing problem has been checked in. I used a queue to store the events to fire when a SSLFilter holds a lock, and fired them after the lock is released, and therefore, the events are forwarded with no hold lock, which fixed the deadlock.

        Sung jun, could you please test your application again and close this issue if my fix solves your problem?

        Show
        Trustin Lee added a comment - The fix for this long-standing problem has been checked in. I used a queue to store the events to fire when a SSLFilter holds a lock, and fired them after the lock is released, and therefore, the events are forwarded with no hold lock, which fixed the deadlock. Sung jun, could you please test your application again and close this issue if my fix solves your problem?
        Trustin Lee made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Emmanuel Lecharny made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Trustin Lee
            Reporter:
            ncanis
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development