aboutsummaryrefslogtreecommitdiff
path: root/src/IvyClient.java
diff options
context:
space:
mode:
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());