aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu/java/rmi/server/UnicastConnection.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/gnu/java/rmi/server/UnicastConnection.java')
-rw-r--r--libjava/gnu/java/rmi/server/UnicastConnection.java33
1 files changed, 28 insertions, 5 deletions
diff --git a/libjava/gnu/java/rmi/server/UnicastConnection.java b/libjava/gnu/java/rmi/server/UnicastConnection.java
index e13bb68..14d28f2 100644
--- a/libjava/gnu/java/rmi/server/UnicastConnection.java
+++ b/libjava/gnu/java/rmi/server/UnicastConnection.java
@@ -1,5 +1,5 @@
/*
- Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -61,6 +61,10 @@ DataOutputStream dout;
ObjectInputStream oin;
ObjectOutputStream oout;
+// reviveTime and expireTime make UnicastConnection pool-able
+long reviveTime = 0;
+long expireTime = Long.MAX_VALUE;
+
UnicastConnection(UnicastConnectionManager man, Socket sock) {
this.manager = man;
this.sock = sock;
@@ -137,7 +141,7 @@ DataOutputStream getDataOutputStream() throws IOException {
ObjectInputStream getObjectInputStream() throws IOException {
if (oin == null) {
- oin = new RMIObjectInputStream(din, manager);
+ oin = new RMIObjectInputStream(din);
}
return (oin);
}
@@ -153,6 +157,7 @@ void disconnect() {
try {
if(oout != null)
oout.close();
+ sock.close();
}
catch (IOException _) {
}
@@ -164,17 +169,35 @@ void disconnect() {
sock = null;
}
+public static final long CONNECTION_TIMEOUT = 10000L;
+
+static boolean isExpired(UnicastConnection conn, long l){
+ if (l <= conn.expireTime )
+ return false;
+ return true;
+}
+
+static void resetTime(UnicastConnection conn){
+ long l = System.currentTimeMillis();
+ conn.reviveTime = l;
+ conn.expireTime = l + CONNECTION_TIMEOUT;
+}
+
/**
* We run connects on the server. Dispatch it then discard it.
*/
public void run() {
+ do{
try {
UnicastServer.dispatch(this);
+ //don't discardConnection explicitly, only when
+ // exception happens or the connection's expireTime
+ // comes
+ } catch (Exception e ){
manager.discardConnection(this);
+ break;
}
- catch (Exception e) {
- e.printStackTrace();
- }
+ }while(true);
}
}