onepub-dev / dcli

An extensive library and tooling for building console/cli applications and scripts using the Dart programming language.
242 stars 28 forks source link

NamedLocks are allowing callers through when many locks taken. #81

Closed bsutton closed 4 years ago

bsutton commented 4 years ago

The following unit test will reproduce the error:

import 'dart:isolate';
import 'package:dshell/dshell.dart';
import 'package:test/test.dart';

void worker(int port) {
  print('starting $port');
  NamedLock(name: 'gshared-compile').withLock(() {
    print('acquired lock $port');
    sleep(5);
    print('finished $port');
  });
}

void main() {
  void locker(int name) {
    Isolate.spawn(worker, name);
  }

  test('named lock 1', () {
    for (var i = 0; i < 20; i++) {
      locker(i);
    }
    sleep(59);
  }, timeout: Timeout(Duration(minutes: 2)));
}
bsutton commented 4 years ago

Fixed in 1.10.13