Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-994

The ConnectionRequest.cancel() method is inconsistent wrt concurrent access

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 2.0.9
    • 2.0.10
    • None
    • None

    Description

      When we call the ConnectionRequest.cancel() method, it does :

              public void cancel() {
                  if (!isDone()) {
                      super.cancel();
                      cancelQueue.add(this);
                      startupWorker();
                      wakeup();
                  }
      

      The problem is that the isDone() method is :

          public boolean isDone() {
              synchronized (lock) {
                  return ready;
              }
          }
      

      and the super.cancel() method is :

          public void cancel() {
              setValue(CANCELED);
          }
      

      with the setValue() method :

          public void setValue(Object newValue) {
              synchronized (lock) {
                  // Allowed only once.
                  if (ready) {
                      return;
                  }
      
                  result = newValue;
                  ready = true;
                  ...
      

      At this point, we may have the 'ready' flag set to false, enter into the super.cancel() method, and have the 'ready' flag set to true when we check it again, but still we will add the current connectRequest into the cancel queue, when we should not.

      Attachments

        Activity

          People

            Unassigned Unassigned
            elecharny Emmanuel L├ęcharny
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: