Exemplo n.º 1
0
 private static void processGoAwayWriteResult(
     final ChannelHandlerContext ctx,
     final int lastStreamId,
     final long errorCode,
     final ByteBuf debugData,
     ChannelFuture future) {
   try {
     if (future.isSuccess()) {
       if (errorCode != NO_ERROR.code()) {
         if (logger.isDebugEnabled()) {
           logger.debug(
               format(
                   "Sent GOAWAY: lastStreamId '%d', errorCode '%d', "
                       + "debugData '%s'. Forcing shutdown of the connection.",
                   lastStreamId, errorCode, debugData.toString(UTF_8)),
               future.cause());
         }
         ctx.close();
       }
     } else {
       if (logger.isErrorEnabled()) {
         logger.error(
             format(
                 "Sending GOAWAY failed: lastStreamId '%d', errorCode '%d', "
                     + "debugData '%s'. Forcing shutdown of the connection.",
                 lastStreamId, errorCode, debugData.toString(UTF_8)),
             future.cause());
       }
       ctx.close();
     }
   } finally {
     // We're done with the debug data now.
     debugData.release();
   }
 }
Exemplo n.º 2
0
 static {
   boolean disabled;
   if (SystemPropertyUtil.get("io.netty.noResourceLeakDetection") != null) {
     boolean disabled = SystemPropertyUtil.getBoolean("io.netty.noResourceLeakDetection", false);
     logger.debug("-Dio.netty.noResourceLeakDetection: {}", Boolean.valueOf(disabled));
     logger.warn(
         "-Dio.netty.noResourceLeakDetection is deprecated. Use '-D{}={}' instead.",
         "io.netty.leakDetectionLevel",
         DEFAULT_LEVEL.name().toLowerCase());
   } else {
     disabled = false;
   }
   Level defaultLevel = disabled ? Level.DISABLED : DEFAULT_LEVEL;
   String levelStr =
       SystemPropertyUtil.get("io.netty.leakDetectionLevel", defaultLevel.name())
           .trim()
           .toUpperCase();
   Level level = DEFAULT_LEVEL;
   for (Level l : EnumSet.allOf(Level.class)) {
     if ((levelStr.equals(l.name())) || (levelStr.equals(String.valueOf(l.ordinal())))) {
       level = l;
     }
   }
   level = level;
   if (logger.isDebugEnabled()) {
     logger.debug("-D{}: {}", "io.netty.leakDetectionLevel", level.name().toLowerCase());
   }
 }
  static {
    DEFAULT_EVENT_LOOP_THREADS =
        Math.max(
            1,
            SystemPropertyUtil.getInt(
                "io.netty.eventLoopThreads", Runtime.getRuntime().availableProcessors() * 2));

    if (logger.isDebugEnabled()) {
      logger.debug("-Dio.netty.eventLoopThreads: {}", DEFAULT_EVENT_LOOP_THREADS);
    }
  }
Exemplo n.º 4
0
  /** Notify all the handshake futures about the successfully handshake */
  private void setHandshakeSuccess() {
    // Work around the JVM crash which occurs when a cipher suite with GCM enabled.
    final String cipherSuite = String.valueOf(engine.getSession().getCipherSuite());
    if (!wantsDirectBuffer && (cipherSuite.contains("_GCM_") || cipherSuite.contains("-GCM-"))) {
      wantsInboundHeapBuffer = true;
    }

    handshakePromise.trySuccess(ctx.channel());

    if (logger.isDebugEnabled()) {
      logger.debug("{} HANDSHAKEN: {}", ctx.channel(), engine.getSession().getCipherSuite());
    }
    ctx.fireUserEventTriggered(SslHandshakeCompletionEvent.SUCCESS);

    if (readDuringHandshake && !ctx.channel().config().isAutoRead()) {
      readDuringHandshake = false;
      ctx.read();
    }
  }
Exemplo n.º 5
0
  @Override
  public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
    if (ignoreException(cause)) {
      // It is safe to ignore the 'connection reset by peer' or
      // 'broken pipe' error after sending close_notify.
      if (logger.isDebugEnabled()) {
        logger.debug(
            "Swallowing a harmless 'connection reset by peer / broken pipe' error that occurred "
                + "while writing close_notify in response to the peer's close_notify",
            cause);
      }

      // Close the connection explicitly just in case the transport
      // did not close the connection automatically.
      if (ctx.channel().isActive()) {
        ctx.close();
      }
    } else {
      ctx.fireExceptionCaught(cause);
    }
  }
Exemplo n.º 6
0
 public boolean isTraceEnabled() {
   return _log.isDebugEnabled();
 }