|
@@ -16,12 +16,16 @@ package com.l2jserver;
|
|
|
|
|
|
import java.sql.Connection;
|
|
|
import java.sql.SQLException;
|
|
|
+import java.util.Map;
|
|
|
import java.util.concurrent.Executors;
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
|
+import java.util.concurrent.ScheduledFuture;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.logging.Level;
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
+import javolution.util.FastMap;
|
|
|
+
|
|
|
import com.l2jserver.gameserver.ThreadPoolManager;
|
|
|
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
|
|
|
|
@@ -43,6 +47,7 @@ public class L2DatabaseFactory
|
|
|
|
|
|
private static L2DatabaseFactory _instance;
|
|
|
private static volatile ScheduledExecutorService _executor;
|
|
|
+ private static Map<Integer, ScheduledFuture<?>> _connectionClosers = new FastMap<>();
|
|
|
private ProviderType _providerType;
|
|
|
private ComboPooledDataSource _source;
|
|
|
|
|
@@ -265,7 +270,7 @@ public class L2DatabaseFactory
|
|
|
con = _source.getConnection();
|
|
|
if (Server.serverMode == Server.MODE_GAMESERVER)
|
|
|
{
|
|
|
- ThreadPoolManager.getInstance().scheduleGeneral(new ConnectionCloser(con, new RuntimeException()), Config.CONNECTION_CLOSE_TIME);
|
|
|
+ _connectionClosers.put(con.hashCode(), ThreadPoolManager.getInstance().scheduleGeneral(new ConnectionCloser(con, new RuntimeException()), Config.CONNECTION_CLOSE_TIME));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -335,6 +340,12 @@ public class L2DatabaseFactory
|
|
|
try
|
|
|
{
|
|
|
con.close();
|
|
|
+ ScheduledFuture<?> conCloser = _connectionClosers.remove(con.hashCode());
|
|
|
+ if (conCloser != null)
|
|
|
+ {
|
|
|
+ conCloser.cancel(true);
|
|
|
+ conCloser = null;
|
|
|
+ }
|
|
|
}
|
|
|
catch (SQLException e)
|
|
|
{
|