better logging
authoradam <adam@megacz.com>
Sat, 30 Oct 2004 08:47:45 +0000 (08:47 +0000)
committeradam <adam@megacz.com>
Sat, 30 Oct 2004 08:47:45 +0000 (08:47 +0000)
darcs-hash:20041030084745-5007d-f74341a4845a9964203ea4415c536afcff613f40.gz

src/org/ibex/jinetd/Port.java

index 8ac02a5..a55f7af 100644 (file)
@@ -87,15 +87,20 @@ public class Port extends Loader {
 
     void dispatch(final Connection conn) throws Exception {
         new Thread(tg, new Runnable() { public void run() {
 
     void dispatch(final Connection conn) throws Exception {
         new Thread(tg, new Runnable() { public void run() {
+            String local = conn.getLocalAddress() + ":" + conn.getLocalPort();
+            String remote = conn.getRemoteHostname() + ":" + conn.getRemotePort();
             try {
                 Class c = findListener();
                 if (c == null) throw new RuntimeException("couldn't find listener");
             try {
                 Class c = findListener();
                 if (c == null) throw new RuntimeException("couldn't find listener");
-                Log.info(this, "dispatching connection on port " + port + " to " + c.getName());
+                Log.info("["+local+"]", "connection from " + remote + " => " + c.getName());
                 Log.clearnotes();
                 final ClassLoader cl = getClassLoader();
                 Thread.currentThread().setContextClassLoader(cl);
                 Listener l = (Listener)c.newInstance();
                 l.accept(conn);
                 Log.clearnotes();
                 final ClassLoader cl = getClassLoader();
                 Thread.currentThread().setContextClassLoader(cl);
                 Listener l = (Listener)c.newInstance();
                 l.accept(conn);
+            } catch (org.ibex.io.Stream.EOF eof) {
+                Log.warn(this, "end of stream reached handling connection from " +
+                         conn.getRemoteHostname() + ":" + conn.getRemotePort());
             } catch (Exception e) {
                 Log.error(this, "Listener threw exception");
                 Log.error(this, e);
             } catch (Exception e) {
                 Log.error(this, "Listener threw exception");
                 Log.error(this, e);