Esempio n. 1
0
 private void registerAcceptedChannel(SctpChannel acceptedSocket, Thread currentThread) {
   try {
     ChannelPipeline pipeline = channel.getConfig().getPipelineFactory().getPipeline();
     SctpWorker worker = nextWorker();
     worker.register(
         new SctpAcceptedChannel(
             channel.getFactory(),
             pipeline,
             channel,
             SctpServerPipelineSink.this,
             acceptedSocket,
             worker,
             currentThread),
         null);
   } catch (Exception e) {
     if (logger.isWarnEnabled()) {
       logger.warn("Failed to initialize an accepted socket.", e);
     }
     try {
       acceptedSocket.close();
     } catch (IOException e2) {
       if (logger.isWarnEnabled()) {
         logger.warn("Failed to close a partially accepted socket.", e2);
       }
     }
   }
 }
Esempio n. 2
0
  private void bind(
      SctpServerChannelImpl channel, ChannelFuture future, SocketAddress localAddress) {

    boolean bound = false;
    boolean bossStarted = false;
    try {
      channel.serverChannel.bind(localAddress, channel.getConfig().getBacklog());
      bound = true;
      channel.setBound();
      future.setSuccess();
      fireChannelBound(channel, channel.getLocalAddress());

      Executor bossExecutor = ((SctpServerSocketChannelFactory) channel.getFactory()).bossExecutor;
      DeadLockProofWorker.start(bossExecutor, new Boss(channel));
      bossStarted = true;
    } catch (Throwable t) {
      future.setFailure(t);
      fireExceptionCaught(channel, t);
    } finally {
      if (!bossStarted && bound) {
        close(channel, future);
      }
    }
  }