Skip to content

Commit 0855239

Browse files
author
magiclu550
committed
[commit] #1061 zombie threads is killed
1 parent ad837fb commit 0855239

6 files changed

Lines changed: 118 additions & 6 deletions

File tree

JPLS/src/main/java/cn/jsmod2/Register.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ public void registerPacket(){
213213
/**
214214
* 运行jsmod2时的jvm参数,只有在启动启动器(rpc调用)时,才会生效
215215
*/
216-
public static final String JSMOD2_JVM_ARGS = "jsmod2.jvm.args";
216+
public static final String JSMOD2_JVM_ARGS = "jsmod2.option";
217+
218+
219+
217220

218221
/**
219222
* 当开启成功时的信息

JPLS/src/main/java/cn/jsmod2/core/Console.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import cn.jsmod2.core.ex.ServerRuntimeException;
1313
import cn.jsmod2.core.interapi.command.INativeCommand;
14+
import cn.jsmod2.core.log.ServerLogger;
1415
import cn.jsmod2.core.script.EmeraldScriptVM;
1516
import cn.jsmod2.core.script.EnvPage;
1617
import cn.jsmod2.core.script.Memory;
@@ -61,6 +62,10 @@ public void commandInput() throws IOException{
6162
}
6263
PrintWriter stream = new PrintWriter(new FileOutputStream(outFile,true));
6364
while (true){
65+
if(!Server.getSender().getServer().isConnected){
66+
ServerLogger.getLogger().multiInfo(getClass(),"Exit the command input thread...","","");
67+
break;
68+
}
6469
//@Deprecated
6570
String command;
6671
if(Server.getSender().getServer().serverProp.getProperty(FileSystem.CONSOLE_LINE,"false").equals("false")) {

JPLS/src/main/java/cn/jsmod2/core/Server.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ private void closeStream(){
560560
}
561561

562562
private void closeAll(){
563+
isConnected = false;
563564
scheduler.getPool().shutdownNow();
564565
disable();
565566
closeStream();
@@ -662,6 +663,9 @@ public void run() {
662663
//在未来版本可能会加入支持多个smod2连接一个服务器
663664
serverSocket = getSocket(Integer.parseInt(serverProp.getProperty(FileSystem.THIS_PORT)));
664665
while (true) {
666+
if(!Server.getSender().getServer().isConnected){
667+
ServerLogger.getLogger().multiInfo(getClass(),"the listener thread is closed","","");
668+
}
665669
DatagramPacket request = new DatagramPacket(new byte[MAX_LENGTH], MAX_LENGTH);
666670
((DatagramSocket)serverSocket).receive(request);
667671
//manageMessage(request);
@@ -689,6 +693,9 @@ public void run() {
689693
}
690694

691695
while (true) {
696+
if(!Server.getSender().getServer().isConnected){
697+
ServerLogger.getLogger().multiInfo(getClass(),"the listener thread is closed","","");
698+
}
692699
Socket socket = ((ServerSocket)serverSocket).accept();
693700
scheduler.executeRunnable(new SocketHandlerThread(socket));
694701
if (isDebug) {
@@ -792,6 +799,9 @@ public void run() {
792799
try {
793800
int count = 0;
794801
while (shouldIRun) {
802+
if(!Server.getSender().getServer().isConnected){
803+
ServerLogger.getLogger().multiInfo(getClass(),"the listener thread is closed","","");
804+
}
795805
Thread.sleep(crunchifyRunEveryNSeconds);
796806

797807
String log = logListener(timeFormat,max,fileProperty);

jsmod2/src/main/java/cn/jsmod2/api/event/admin/IAdminQueryEvent.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,39 @@
66
/**
77
*
88
*
9+
* 在管理员查询服务器时,会触发该事件
10+
* 如管理员在游戏中查询服务器玩家等,或者需要添加的过程
911
* Called when an cn.jsmod2.admin queries the cn.jsmod2.server.
10-
* @author YorokobiMaster #(doc)
1112
* @author magiclu550
13+
* @see cn.jsmod2.core.interapi.event.IEvent
14+
* @since smod2 3.4.0-3.5.0
1215
*
1316
*/
1417
public interface IAdminQueryEvent extends IEvent {
1518

1619
/**
20+
* 获得此时管理员的对象
1721
* @return The cn.jsmod2.player who queried the cn.jsmod2.server
1822
*/
1923
IPlayer getAdmin();
2024

2125
/**
26+
* 设置此时的管理员对象
2227
* Set the cn.jsmod2.player who queried the cn.jsmod2.server
2328
* @param admin cn.jsmod2.admin
2429
*/
2530
void setAdmin(IPlayer admin);
2631

2732

2833
/**
29-
*
34+
* 获得查询内容
3035
* @return The query
3136
*
3237
*/
3338
String getQuery();
3439

3540
/**
41+
* 设置查询内容
3642
* Set the query
3743
* @param query The query
3844
*/
@@ -41,22 +47,27 @@ public interface IAdminQueryEvent extends IEvent {
4147

4248

4349
/**
50+
* 获得查询后的输出内容
4451
* @return The output of the query
4552
*/
4653
String getOutput();
4754

4855
/**
49-
* Set the query
56+
* 设置输出内容
57+
* Set the output of the query
5058
* @param output the output of the query
5159
*/
5260
void setOutput(String output);
5361

5462
/**
63+
* 是否处理了查询内容,如果处理了,返回true,如果没有处理
64+
* 返回false
5565
* @return Was the query handled?
5666
*/
5767
boolean isHandled();
5868

5969
/**
70+
* 设置处理是否成功,如果想使得其不成功,则设置为false
6071
* Set the handled
6172
* @param handled Was the query handled?
6273
*/
@@ -65,12 +76,13 @@ public interface IAdminQueryEvent extends IEvent {
6576

6677

6778
/**
68-
*
79+
*获得查询是否成功,如果不成功,返回false
6980
* @return Was the query successful?
7081
*/
7182
boolean isSuccessful();
7283

7384
/**
85+
* 设置查询不成功,则设置false
7486
* Set the query successful;
7587
* @param successful set query successful
7688
*/

jsmod2/src/main/java/cn/jsmod2/api/event/admin/IAuthCheckEvent.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,59 @@
44
import cn.jsmod2.api.server.AuthType;
55
import cn.jsmod2.core.interapi.event.IEvent;
66

7+
/**
8+
* Called when authentication is checked for.
9+
* @author magiclu550
10+
* @see cn.jsmod2.core.interapi.event.IEvent
11+
* @since smod2 3.4.0 - 3.5.0
12+
*/
713
public interface IAuthCheckEvent extends IEvent {
814

15+
/**
16+
* @return The player who requests authentication
17+
*/
918
IPlayer getRequester();
1019

20+
/**
21+
* @return The type of authentication.
22+
*/
23+
1124
AuthType getType();
1225

26+
/**
27+
* Set the type of authentication.
28+
* @param type
29+
*/
1330
void setType(AuthType type);
1431

32+
/**
33+
* @return Was the authentication allowed?
34+
*/
1535
boolean isAllow();
1636

37+
/**
38+
* Set the authentication allowed.
39+
* @param allow the allowed
40+
*/
1741
void setAllow(boolean allow);
1842

43+
/**
44+
*
45+
* @return The message given if authentication was denied
46+
*/
1947
String getDeniedMessage();
2048

49+
50+
/**
51+
* The message given if authentication was denied
52+
* @param message the denied message
53+
*/
2154
void setDeniedMessage(String message);
2255

56+
/**
57+
* The player who requests authentication
58+
* @param requester the requester
59+
*/
2360
void setRequester(IPlayer requester);
2461

2562
}

jsmod2/src/main/java/cn/jsmod2/api/event/admin/IBanEvent.java

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,73 @@
33
import cn.jsmod2.api.player.IPlayer;
44
import cn.jsmod2.core.interapi.event.IEvent;
55

6+
/**
7+
*
8+
* Called when a player is banned
9+
* @author magiclu550
10+
* @see cn.jsmod2.core.interapi.event.IEvent
11+
* @since smod2 3.4.0 - 3.5.0
12+
*/
613
public interface IBanEvent extends IEvent {
714

8-
15+
/**
16+
* @return The player who is banned
17+
*/
918
IPlayer getPlayer();
1019

20+
/**
21+
* The object can be null if the event is not raised from the player, but from a plugin or console
22+
* @return The admin who bans the player
23+
*/
1124
IPlayer getAdmin();
1225

26+
/**
27+
* @return The duration of the ban
28+
*/
1329
int getDuration();
1430

31+
/**
32+
* Set the duration of the ban
33+
* @param duration the duration of the ban
34+
*/
1535
void setDuration(int duration);
1636

37+
/**
38+
* @return The reason of the ban
39+
*/
1740
String getReason();
1841

42+
/**
43+
* Set the reason of the ban
44+
* @param reason the reason the ban
45+
*/
1946
void setReason(String reason);
2047

48+
/**
49+
* @return The result of the ban
50+
*/
2151
String getResult();
2252

53+
/**
54+
* Set the result of the ban
55+
* @param result the result of the ban
56+
*/
2357
void setResult(String result);
2458

59+
/**
60+
* @return Was the ban allowed?
61+
*/
2562
boolean isAllowBan();
2663

64+
/**
65+
* Set the ban allowed
66+
* @param allowBan the ban is allowed or not
67+
*/
2768
void setAllowBan(boolean allowBan);
2869

70+
/**
71+
* Set the admin who bans the player
72+
* @param admin the admin
73+
*/
2974
void setAdmin(IPlayer admin);
3075
}

0 commit comments

Comments
 (0)