Fix bugs #4
This commit is contained in:
parent
c7e2912045
commit
627013e19c
5 changed files with 16 additions and 6 deletions
|
@ -17,7 +17,6 @@ public class BotStart {
|
|||
}
|
||||
if (cli.hasOption("c") || cli.hasOption("configuration")){
|
||||
final String[] arguments = cli.getOptionValues("configuration");
|
||||
for (String a: arguments)
|
||||
ConnectionsBuilder.buildConnections(arguments);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class ChanConsumer implements Runnable {
|
|||
parse();
|
||||
}
|
||||
} catch (InterruptedException e){
|
||||
System.out.println("ChanConsumer "+serverName+"/"+channelName+"Interrupted "+e.getMessage());
|
||||
System.out.println("ChanConsumer "+serverName+"/"+channelName+" Interrupted ");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -117,8 +117,10 @@ public class DataProvider implements Runnable {
|
|||
|
||||
private void close(){
|
||||
try {
|
||||
systemConsumerThread.interrupt();
|
||||
systemConsumerThread.join();
|
||||
if (systemConsumerThread != null) {
|
||||
systemConsumerThread.interrupt();
|
||||
systemConsumerThread.join();
|
||||
}
|
||||
StreamProvider.delStream(server);
|
||||
ReconnectControl.notify(server);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package InnaIrcBot;
|
||||
|
||||
import InnaIrcBot.linkstitles.LinksTitleManager;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -17,19 +19,22 @@ public class ReconnectControl {
|
|||
}
|
||||
|
||||
public static synchronized void notify(String server){
|
||||
if (! serversList.getOrDefault(server, false))
|
||||
if (! serversList.getOrDefault(server, false)) {
|
||||
LinksTitleManager.interrupt();
|
||||
return;
|
||||
}
|
||||
|
||||
int count = serversReconnects.get(server);
|
||||
|
||||
if (count > 5) {
|
||||
serversList.replace(server, false);
|
||||
LinksTitleManager.interrupt();
|
||||
return;
|
||||
}
|
||||
count++;
|
||||
serversReconnects.put(server, count);
|
||||
|
||||
System.out.println("Main thread \"" + server + "\" removed from observable list after unexpected finish.\n");
|
||||
System.out.println("Main thread \"" + server + "\" removed from observable list after unexpected finish ("+count+").\n");
|
||||
ConnectionsBuilder.getConnections().startNewConnection(server);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,4 +15,8 @@ public class LinksTitleManager {
|
|||
}
|
||||
return queue;
|
||||
}
|
||||
|
||||
public static void interrupt(){
|
||||
thread.interrupt();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue