dartist / redis_client

A high-performance async/non-blocking Redis client for Dart
BSD 2-Clause "Simplified" License
100 stars 29 forks source link

Fixes hang when a password or a db is used in the connection string #36

Closed brentalanmiller closed 10 years ago

brentalanmiller commented 10 years ago

Not sure if this is the best way to fix this issue, but I ran into a problem where calls to RedisCliient.connect() would hang anytime I passed in a db to the connection string using Dart SDK 1.0.0.7_r30338 and Redis 2.6.7

For example, doing something like:

void main() {
  var connectionString = "127.0.0.1:6379/1";

  RedisClient.connect(connectionString)
    .then((RedisClient client) {
      print("client connected");

      client.set("test", "value")
        .then((_) => client.close());
  });
}

would never print "client connected", but would work fine if I removed the /db part of the connection string or set it to /0

Seems that there's an issue calling select() (and thus rawSend which has a dependency on the 'connected' future) from the same code block that you use to set the 'connected' future. https://github.com/dartist/redis_client/blob/9311b2ce01634c0cdcdf0600925682cc00fd3fdf/lib/redis_client/redis_connection.dart#L228

The same issue seems to happen when you call _authenticate from: https://github.com/dartist/redis_client/blob/9311b2ce01634c0cdcdf0600925682cc00fd3fdf/lib/redis_client/redis_connection.dart#L225

bbss commented 10 years ago

Thanks for the PR, adding some tests to catch this.