2020using System . Collections . Concurrent ;
2121using System . Collections . Generic ;
2222using System . Linq ;
23- using System . Text ;
2423using System . Threading ;
2524using System . Threading . Tasks ;
2625using FirebirdSql . Data . Common ;
@@ -42,10 +41,10 @@ sealed class Item : IDisposable
4241 {
4342 bool _disposed ;
4443
45- public DateTimeOffset Created { get ; private set ; }
44+ public long Created { get ; private set ; }
4645 public FbConnectionInternal Connection { get ; private set ; }
4746
48- public Item ( DateTimeOffset created , FbConnectionInternal connection )
47+ public Item ( long created , FbConnectionInternal connection )
4948 {
5049 Created = created ;
5150 Connection = connection ;
@@ -56,7 +55,7 @@ public void Dispose()
5655 if ( _disposed )
5756 return ;
5857 _disposed = true ;
59- Created = default ( DateTimeOffset ) ;
58+ Created = default ( long ) ;
6059 Connection . Dispose ( ) ;
6160 Connection = null ;
6261 }
@@ -114,7 +113,7 @@ public void ReleaseConnection(FbConnectionInternal connection)
114113 var removed = _busy . Remove ( connection ) ;
115114 if ( removed )
116115 {
117- _available . Push ( new Item ( DateTimeOffset . UtcNow , connection ) ) ;
116+ _available . Push ( new Item ( GetTicks ( ) , connection ) ) ;
118117 }
119118 }
120119 }
@@ -125,7 +124,7 @@ public void CleanupPool()
125124 {
126125 CheckDisposedImpl ( ) ;
127126
128- var now = DateTimeOffset . UtcNow ;
127+ var now = GetTicks ( ) ;
129128 var available = _available . ToArray ( ) ;
130129 if ( available . Count ( ) <= _connectionString . MinPoolSize )
131130 return ;
@@ -160,11 +159,17 @@ static FbConnectionInternal CreateNewConnection(FbConnectionString connectionStr
160159 return result ;
161160 }
162161
163- static bool IsAlive ( long connectionLifeTime , DateTimeOffset created , DateTimeOffset now )
162+ static bool IsAlive ( long connectionLifeTime , long created , long now )
164163 {
165164 if ( connectionLifeTime == 0 )
166165 return true ;
167- return created . AddSeconds ( connectionLifeTime ) > now ;
166+ return ( now - created ) > ( connectionLifeTime * 1000 ) ;
167+ }
168+
169+ static long GetTicks ( )
170+ {
171+ var ticks = Environment . TickCount ;
172+ return ticks + - ( long ) int . MinValue ;
168173 }
169174
170175 void CleanConnectionsImpl ( )
0 commit comments