/[classpath]/classpath/gnu/java/rmi/server/UnicastConnection.java
ViewVC logotype

Diff of /classpath/gnu/java/rmi/server/UnicastConnection.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by cbj, Thu Mar 21 05:40:11 2002 UTC revision 1.4 by mark, Thu Oct 31 18:35:21 2002 UTC
# Line 1  Line 1 
1  /*  /*
2    Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.    Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 61  DataOutputStream dout; Line 61  DataOutputStream dout;
61  ObjectInputStream oin;  ObjectInputStream oin;
62  ObjectOutputStream oout;  ObjectOutputStream oout;
63    
64    // reviveTime and expireTime make UnicastConnection pool-able
65    long reviveTime = 0;
66    long expireTime = Long.MAX_VALUE;
67    
68  UnicastConnection(UnicastConnectionManager man, Socket sock) {  UnicastConnection(UnicastConnectionManager man, Socket sock) {
69          this.manager = man;          this.manager = man;
70          this.sock = sock;          this.sock = sock;
# Line 137  DataOutputStream getDataOutputStream() t Line 141  DataOutputStream getDataOutputStream() t
141    
142  ObjectInputStream getObjectInputStream() throws IOException {  ObjectInputStream getObjectInputStream() throws IOException {
143          if (oin == null) {          if (oin == null) {
144                  oin = new RMIObjectInputStream(din, manager);          oin = new RMIObjectInputStream(din);
145          }          }
146          return (oin);          return (oin);
147  }  }
# Line 153  void disconnect() { Line 157  void disconnect() {
157          try {          try {
158              if(oout != null)              if(oout != null)
159                  oout.close();                  oout.close();
160            sock.close();
161          }          }
162          catch (IOException _) {          catch (IOException _) {
163      }      }
# Line 164  void disconnect() { Line 169  void disconnect() {
169          sock = null;          sock = null;
170  }  }
171    
172    public static final long CONNECTION_TIMEOUT = 10000L;
173    
174    static boolean isExpired(UnicastConnection conn, long l){
175        if (l <= conn.expireTime )
176            return false;
177        return true;
178    }
179    
180    static void resetTime(UnicastConnection conn){
181        long l = System.currentTimeMillis();
182        conn.reviveTime = l;
183        conn.expireTime = l + CONNECTION_TIMEOUT;
184    }
185    
186  /**  /**
187   * We run connects on the server. Dispatch it then discard it.   * We run connects on the server. Dispatch it then discard it.
188   */   */
189  public void run() {  public void run() {
190        do{
191          try {          try {
192                  UnicastServer.dispatch(this);                  UnicastServer.dispatch(this);
193                //don't discardConnection explicitly, only when
194                //  exception happens or the connection's expireTime
195                //  comes
196            } catch (Exception e ){
197                  manager.discardConnection(this);                  manager.discardConnection(this);
198                break;
199          }          }
200          catch (Exception e) {      }while(true);
                 e.printStackTrace();  
         }  
201  }  }
202    
203  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26