|
|
|
@ -109,11 +109,11 @@ public class ServerManagementTCP implements Runnable {
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
|
|
boolean end = false;
|
|
|
|
|
logger.writeTCP("[ " + addr + "] New connection", LogLevel.Action);
|
|
|
|
|
logger.writeTCP("[" + addr + "] New connection", LogLevel.Action);
|
|
|
|
|
do {
|
|
|
|
|
end = handleRequest();
|
|
|
|
|
} while(!end);
|
|
|
|
|
logger.writeTCP("[ " + addr + "] End of connection", LogLevel.Action);
|
|
|
|
|
logger.writeTCP("[" + addr + "] End of connection", LogLevel.Action);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Respond to next request incomming on socket s.
|
|
|
|
@ -354,12 +354,18 @@ public class ServerManagementTCP implements Runnable {
|
|
|
|
|
logger.writeTCP("Unregistering from tracker", LogLevel.Info);
|
|
|
|
|
ProtocolP2PPacket p = (ProtocolP2PPacket)new ProtocolP2PPacketTCP((Payload)new Unregister(server));
|
|
|
|
|
p.sendRequest((Object)tracker.getTCPSocket());
|
|
|
|
|
//tracker.closeTCPSocket();
|
|
|
|
|
// FIXME: this is a hack
|
|
|
|
|
// ProtocolP2PPacketTCP reads 1024 bytes but if 2 request comes at the same time InputStream is cleared fully
|
|
|
|
|
// and we keep waiting forever on the other side
|
|
|
|
|
// a fix could be to read only the header first, and read the required size after
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(100);
|
|
|
|
|
} catch (InterruptedException e) {}
|
|
|
|
|
logger.writeTCP("Registering into tracker", LogLevel.Info);
|
|
|
|
|
p = (ProtocolP2PPacket)new ProtocolP2PPacketTCP((Payload)new Register(server));
|
|
|
|
|
p.sendRequest((Object)tracker.getTCPSocket());
|
|
|
|
|
logger.writeTCP("Registering completed", LogLevel.Debug);
|
|
|
|
|
//tracker.closeTCPSocket();
|
|
|
|
|
tracker.closeTCPSocket();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|