@@ -31,7 +31,7 @@ class SqliteConnectionPool with SqliteQueries implements SqliteConnection {
3131
3232 final MutexImpl mutex;
3333
34- bool _runningWithAllConnections = false ;
34+ int _runningWithAllConnectionsCount = 0 ;
3535
3636 @override
3737 bool closed = false ;
@@ -90,7 +90,8 @@ class SqliteConnectionPool with SqliteQueries implements SqliteConnection {
9090 return ;
9191 }
9292
93- if (_availableReadConnections.isEmpty && _runningWithAllConnections) {
93+ if (_availableReadConnections.isEmpty &&
94+ _runningWithAllConnectionsCount > 0 ) {
9495 // Wait until withAllConnections is done
9596 return ;
9697 }
@@ -245,21 +246,21 @@ class SqliteConnectionPool with SqliteQueries implements SqliteConnection {
245246 SqliteWriteContext writer, List <SqliteReadContext > readers)
246247 block) async {
247248 try {
248- _runningWithAllConnections = true ;
249+ _runningWithAllConnectionsCount ++ ;
249250
250251 final blockCompleter = Completer <T >();
251252 final (write, reads) = await _lockAllConns <T >(blockCompleter);
252253
253- try {
254- final res = await block (write, reads);
255- blockCompleter.complete (res);
256- return res;
257- } catch (e, st) {
254+ try {
255+ final res = await block (write, reads);
256+ blockCompleter.complete (res);
257+ return res;
258+ } catch (e, st) {
258259 blockCompleter.completeError (e, st);
259260 rethrow ;
260261 }
261262 } finally {
262- _runningWithAllConnections = false ;
263+ _runningWithAllConnectionsCount -- ;
263264
264265 // Continue processing any pending read requests that may have been queued while
265266 // the block was running.
0 commit comments