private void closeInbound() {
   try {
     _sslEngine.closeInbound();
   } catch (SSLException x) {
     LOG.ignore(x);
   }
 }
Exemple #2
0
 private static void safeCloseInputStream(InputStream in) {
   try {
     if (in != null) in.close();
   } catch (IOException e) {
     LOG.ignore(e);
   }
 }
 @Override
 public void close() {
   try {
     if (channel != null) channel.close();
   } catch (Exception x) {
     LOG.ignore(x);
   }
 }
 @Override
 public void close() {
   if (autoClose) {
     try {
       stream.close();
     } catch (IOException x) {
       LOG.ignore(x);
     }
   }
 }
Exemple #5
0
 @Override
 public void failed(Throwable x) {
   super.failed(x);
   _channel.getByteBufferPool().release(_buffer);
   try {
     _in.close();
   } catch (IOException e) {
     LOG.ignore(e);
   }
 }
Exemple #6
0
 @Override
 public void expired() {
   if (channel.isConnectionPending()) {
     LOG.debug("Channel {} timed out while connecting, closing it", channel);
     try {
       // This will unregister the channel from the selector
       channel.close();
     } catch (IOException x) {
       LOG.ignore(x);
     }
     destination.onConnectionFailed(new SocketTimeoutException());
   }
 }
 @Override
 public void shutdownOutput() {
   boolean ishut = isInputShutdown();
   if (DEBUG)
     LOG.debug(
         "{} shutdownOutput: oshut={}, ishut={}", SslConnection.this, isOutputShutdown(), ishut);
   if (ishut) {
     // Aggressively close, since inbound close alert has already been processed
     // and the TLS specification allows to close the connection directly, which
     // is what most other implementations expect: a FIN rather than a TLS close
     // reply. If a TLS close reply is sent, most implementation send a RST.
     getEndPoint().close();
   } else {
     try {
       _sslEngine.closeOutbound();
       flush(BufferUtil.EMPTY_BUFFER); // Send close handshake
       SslConnection.this.fillInterested(); // seek reply FIN or RST or close handshake
     } catch (Exception e) {
       LOG.ignore(e);
       getEndPoint().close();
     }
   }
 }
    public void handleResponse(SipResponse response) {
      _response = response;

      int status = response.getStatus();

      if (status == 100) return;

      if (_tx.isCompleted() && !response.is2xx()) {
        if (LOG.isDebugEnabled())
          LOG.debug("Dropping response " + response.getStatus() + " since proxy is completed");
        return;
      }

      if (LOG.isDebugEnabled()) LOG.debug("Got response {}", response, null);

      SipRequest request = _tx.getRequest();

      Session session = request.session();

      if (request.isInitial() && status < 300) {
        if (!session.isSameDialog(response)) {
          AppSession appSession = session.appSession();
          Session derived = appSession.getSession(response);
          if (derived == null) derived = appSession.createDerivedSession(session);
          session = derived;
        }
      }

      response.setSession(session);
      if (status < 300) session.updateState(response, false);

      response.removeTopVia();
      response.setProxyBranch(this);

      if (status < 200) {
        if (response.isInvite()) updateTimerC();

        invokeServlet(response);
        forward(response);
      } else {
        _actives--;

        stopTimerC();

        if ((300 <= status && status < 400) && _branchRecurse) {
          try {
            Iterator<Address> it = response.getAddressHeaders(SipHeaders.CONTACT);
            while (it.hasNext()) {
              Address contact = (Address) it.next();
              if (contact.getURI().isSipURI()) {
                Branch branch = addTarget(contact.getURI());
                if (branch != null) {
                  _recursedBranches = LazyList.add(_recursedBranches, branch);
                  branch.setRecurse(_branchRecurse);
                }
              }
            }
          } catch (ServletParseException e) {
            LOG.ignore(e);
          }
        }

        if (_best == null
            || (_best.getStatus() < 600 && (status < _best.getStatus() || status >= 600))) {
          _best = response;
        }

        if (status >= 600) {
          SipProxy.this.doCancel(null, null, null);
        }

        if (status < 300) {
          invokeServlet(response);
          forward(response);

          SipProxy.this.doCancel(null, null, null);
        } else {
          if (LazyList.size(_targets) > 0) startProxy();

          if (_actives > 0) {
            response.setBranchResponse(true);
            invokeServlet(response);
          } else {
            tryFinal();
          }
        }
      }
    }