From 3f2d25b3145b032db6ca8949d2bb32b1d43a1ca6 Mon Sep 17 00:00:00 2001 From: 2881099 <2881099@qq.com> Date: Wed, 10 Aug 2022 10:05:16 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BC=98=E5=8C=96=20PrevReheatConnectionPo?= =?UTF-8?q?ol=20=E9=A2=84=E7=83=AD=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Examples/base_entity/Program.cs | 2 +- FreeSql/Internal/CommonUtils.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Examples/base_entity/Program.cs b/Examples/base_entity/Program.cs index 6db4cd6b..bb296c0b 100644 --- a/Examples/base_entity/Program.cs +++ b/Examples/base_entity/Program.cs @@ -333,7 +333,7 @@ namespace base_entity //.UseConnectionString(FreeSql.DataType.Firebird, @"database=localhost:D:\fbdata\EXAMPLES.fdb;user=sysdba;password=123456;max pool size=5") - //.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=2") + //.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;min pool size=1;Max pool size=2") //.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true") diff --git a/FreeSql/Internal/CommonUtils.cs b/FreeSql/Internal/CommonUtils.cs index f502a05f..a79abd7e 100644 --- a/FreeSql/Internal/CommonUtils.cs +++ b/FreeSql/Internal/CommonUtils.cs @@ -669,8 +669,9 @@ namespace FreeSql.Internal public static void PrevReheatConnectionPool(ObjectPool pool, int minPoolSize) { - if (minPoolSize <= 0) minPoolSize = Math.Min(5, pool.Policy.PoolSize); - if (minPoolSize > pool.Policy.PoolSize) minPoolSize = pool.Policy.PoolSize; + var maxPoolSize = pool.Policy.PoolSize - 1; + if (minPoolSize <= 0) minPoolSize = Math.Min(5, maxPoolSize); + if (minPoolSize > maxPoolSize) minPoolSize = maxPoolSize; var initTestOk = true; var initStartTime = DateTime.Now; var initConns = new ConcurrentBag>();