Uploaded image for project: 'Geode'
  1. Geode
  2. GEODE-3076

Simplify connection count logic in AcceptorImpl

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • client/server
    • None

    Description

      It looks like AcceptorImpl gets the number of connections, then creates a connection, then increments the count, then handles errors.

      This logic is a bit confusing. It could cause real problems if {{AcceptorImpl}}s were running in multiple threads.

      This code would be much cleaner if it did an incrementAndGet() on the server count, checked the value, and incremented if it had gotten a valid number in the count.

           if (communicationMode != CLIENT_TO_SERVER_FOR_QUEUE) {
              int curCnt = this.getClientServerCnxCount();
              if (curCnt >= this.maxConnections) {
      <snip -- error handling, early exit>
              }
            }
            ServerConnection serverConn = new ServerConnection(s, this.cache, this.crHelper, this.stats,
                AcceptorImpl.handShakeTimeout, this.socketBufferSize, communicationModeStr,
                communicationMode, this, this.securityService);
            synchronized (this.allSCsLock) {
              this.allSCs.add(serverConn);
              ServerConnection snap[] = this.allSCList; // avoid volatile read
              this.allSCList = (ServerConnection[]) ArrayUtils.insert(snap, snap.length, serverConn);
            }
            if (communicationMode != CLIENT_TO_SERVER_FOR_QUEUE) {
              incClientServerCnxCount();
            }
            if (isSelector()) {
              serverConn.registerWithSelector();
            } else {
              try {
                pool.execute(serverConn);
              } catch (RejectedExecutionException rejected) {
        <snip -- error handling, cleanup and exit>
            }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              gosullivan Galen O'Sullivan
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: