Author: ron.sigal(a)jboss.com
Date: 2010-12-17 21:13:21 -0500 (Fri, 17 Dec 2010)
New Revision: 6175
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
Log:
JBREM-1261: Moved new socket processing in SecondaryServerSocketThread to separate
thread.
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
===================================================================
---
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2010-12-15
23:26:35 UTC (rev 6174)
+++
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2010-12-18
02:13:21 UTC (rev 6175)
@@ -1127,41 +1127,7 @@
}
if (log.isTraceEnabled()) log.trace("accepted: " + socket);
- DataInputStream dis = new DataInputStream(socket.getInputStream());
- int action = dis.read();
- String listenerId = dis.readUTF();
-
- switch (action)
- {
- case Bisocket.CREATE_CONTROL_SOCKET:
- BisocketClientInvoker.transferSocket(listenerId, socket, true);
- if (log.isTraceEnabled())
- log.trace("SecondaryServerSocketThread: created control
socket: (" + socket + ")"+ listenerId);
- break;
-
- case Bisocket.RECREATE_CONTROL_SOCKET:
- BisocketClientInvoker invoker =
BisocketClientInvoker.getBisocketCallbackClientInvoker(listenerId);
- if (invoker == null)
- {
- log.debug("received new control socket for unrecognized
listenerId: " + listenerId);
- }
- else
- {
- invoker.replaceControlSocket(socket);
- if (log.isTraceEnabled())
- log.trace("SecondaryServerSocketThread: recreated control
socket: " + listenerId);
- }
- break;
-
- case Bisocket.CREATE_ORDINARY_SOCKET:
- BisocketClientInvoker.transferSocket(listenerId, socket, false);
- if (log.isTraceEnabled())
- log.trace("SecondaryServerSocketThread: transferred socket:
" + listenerId);
- break;
-
- default:
- log.error("unrecognized action on SecondaryServerSocketThread:
" + action);
- }
+ processSocket(socket);
}
catch (IOException e)
{
@@ -1174,6 +1140,71 @@
}
}
+ void processSocket(final Socket socket) throws IOException
+ {
+ new Thread()
+ {
+ public void run()
+ {
+ setName("processSocketThread: " + socket);
+ if (log.isTraceEnabled()) log.trace(this + " processing socket:
" + socket);
+ try
+ {
+ DataInputStream dis = new DataInputStream(socket.getInputStream());
+ int action = dis.read();
+ String listenerId = dis.readUTF();
+
+ switch (action)
+ {
+ case Bisocket.CREATE_CONTROL_SOCKET:
+ BisocketClientInvoker.transferSocket(listenerId, socket, true);
+ if (log.isTraceEnabled())
+ log.trace("SecondaryServerSocketThread: created control
socket: (" + socket + ")"+ listenerId);
+ break;
+
+ case Bisocket.RECREATE_CONTROL_SOCKET:
+ BisocketClientInvoker invoker =
BisocketClientInvoker.getBisocketCallbackClientInvoker(listenerId);
+ if (invoker == null)
+ {
+ log.debug("received new control socket for unrecognized
listenerId: " + listenerId);
+ }
+ else
+ {
+ invoker.replaceControlSocket(socket);
+ if (log.isTraceEnabled())
+ log.trace("SecondaryServerSocketThread: recreated
control socket: " + listenerId);
+ }
+ break;
+
+ case Bisocket.CREATE_ORDINARY_SOCKET:
+ BisocketClientInvoker.transferSocket(listenerId, socket, false);
+ if (log.isTraceEnabled())
+ log.trace("SecondaryServerSocketThread: transferred
socket: " + listenerId);
+ break;
+
+ default:
+ log.error("unrecognized action on
SecondaryServerSocketThread: " + action);
+ }
+ }
+ catch (IOException e)
+ {
+ if (running)
+ {
+ log.error(this + " unable to process socket", e);
+ }
+ else
+ {
+ log.debug(this + " unable to process socket", e);
+ }
+ }
+ finally
+ {
+ if (log.isTraceEnabled()) log.trace(this + " processed socket:
" + socket);
+ }
+ }
+ }.start();
+ }
+
ServerSocket getServerSocket()
{
return secondaryServerSocket;
Show replies by date