aboutsummaryrefslogtreecommitdiff
path: root/src/IvyClient.java
diff options
context:
space:
mode:
authorjestin2002-06-04 17:02:02 +0000
committerjestin2002-06-04 17:02:02 +0000
commit6a0be62488b406149903a7368cea8df0f1f27d33 (patch)
treeec3073dae7e11b55b3badef001a39fcb5ec6a1e1 /src/IvyClient.java
parentba4e7756c028129dc0c22650b17ba52ee92c6056 (diff)
downloadivy-java-6a0be62488b406149903a7368cea8df0f1f27d33.zip
ivy-java-6a0be62488b406149903a7368cea8df0f1f27d33.tar.gz
ivy-java-6a0be62488b406149903a7368cea8df0f1f27d33.tar.bz2
ivy-java-6a0be62488b406149903a7368cea8df0f1f27d33.tar.xz
Many major corrections, see changelogs for details.
- Domain bug fix - die semantics OK - non CPU-eating socket listeners cVS: ----------------------------------------------------------------------
Diffstat (limited to 'src/IvyClient.java')
-rwxr-xr-xsrc/IvyClient.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/IvyClient.java b/src/IvyClient.java
index 08864f4..9555d8a 100755
--- a/src/IvyClient.java
+++ b/src/IvyClient.java
@@ -17,9 +17,13 @@ import gnu.regexp.*;
* once ready, a ready message is sent, and then we can send messages,
* die messages, direct messages, add or remove regexps, or quit. A thread is
* created for each remote client.
+ *
+ * CHANGELOG:
+ * 1.0.10:
+ * - removed the timeout bug eating all the CPU resources
*/
-public class IvyClient extends Thread {
+public class IvyClient implements Runnable {
/* the protocol magic numbers */
final static int Bye = 0; /* end of the peer */
@@ -46,6 +50,7 @@ public class IvyClient extends Thread {
private int appPort;
private boolean gardefou=true;
private boolean peerCalling;
+ private Thread client;
IvyClient(Ivy bus, Socket socket,boolean peerCalling) throws IOException {
appName = "Unknown";
@@ -53,7 +58,7 @@ public class IvyClient extends Thread {
this.bus = bus;
this.socket = socket;
this.peerCalling=peerCalling;
- socket.setSoTimeout(100);
+ // CHANGE: socket.setSoTimeout(100);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out = socket.getOutputStream();
Hashtable regexps=bus.regexp_out;
@@ -70,7 +75,8 @@ public class IvyClient extends Thread {
send( EndRegexp,0,"");
// spawns a thread to manage the incoming traffic on this
// socket. We should be ready to receive messages now.
- start();
+ client= new Thread(this);
+ client.start();
}
/**
@@ -116,9 +122,10 @@ public class IvyClient extends Thread {
* the thread managing the socket is stopped
*/
void close(String msg) throws IOException {
- traceDebug(msg);
+ traceDebug("(closing) "+msg);
gardefou=false;
- socket.close(); // should I ?
+ client.interrupt();
+ // socket.close(); // should I ?
}
/**
@@ -149,6 +156,8 @@ public class IvyClient extends Thread {
} catch (InterruptedIOException ioe) {
// okay, nothing on the line
// do nothing but loop. It might be a bit resource-eating ...
+ System.out.println("DEBUG IvyClient: I have been interrupted");
+ if (!gardefou) break;
}
}
traceDebug("normally Disconnected from "+ socket.getInetAddress().getHostName()+":"+socket.getPort());