fix error on HTTP Proxy shutdown

This commit is contained in:
zzz
2011-07-05 12:47:19 +00:00
parent 476caf3f59
commit 98b14158e6

View File

@@ -15,11 +15,10 @@ import net.i2p.util.Log;
* @since 0.7.9 * @since 0.7.9
*/ */
class InternalSocketRunner implements Runnable { class InternalSocketRunner implements Runnable {
private I2PTunnelClientBase client; private final I2PTunnelClientBase client;
private int port; private final int port;
private ServerSocket ss; private ServerSocket ss;
private boolean open; private volatile boolean open;
private static final Log _log = new Log(InternalSocketRunner.class);
/** starts the runner */ /** starts the runner */
InternalSocketRunner(I2PTunnelClientBase client) { InternalSocketRunner(I2PTunnelClientBase client) {
@@ -33,13 +32,14 @@ class InternalSocketRunner implements Runnable {
try { try {
this.ss = new InternalServerSocket(this.port); this.ss = new InternalServerSocket(this.port);
this.open = true; this.open = true;
while (true) { while (this.open) {
Socket s = this.ss.accept(); Socket s = this.ss.accept();
this.client.manageConnection(s); this.client.manageConnection(s);
} }
} catch (IOException ex) { } catch (IOException ex) {
if (this.open) { if (this.open) {
_log.error("Error listening for internal connections on port " + this.port, ex); Log log = new Log(InternalSocketRunner.class);
log.error("Error listening for internal connections on port " + this.port, ex);
} }
this.open = false; this.open = false;
} }
@@ -47,10 +47,10 @@ class InternalSocketRunner implements Runnable {
void stopRunning() { void stopRunning() {
if (this.open) { if (this.open) {
this.open = false;
try { try {
this.ss.close(); this.ss.close();
} catch (IOException ex) {} } catch (IOException ex) {}
this.open = false;
} }
} }
} }