Skip to content

Commit

Permalink
Fix reconnect
Browse files Browse the repository at this point in the history
Now one can reconnect a client that has been disconnected using `.end()`.
  • Loading branch information
felixge committed Oct 12, 2010
1 parent 4f0f096 commit 2db5bbd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/mysql/client.js
Expand Up @@ -187,6 +187,8 @@ Client.prototype.end = function(cb) {
if (cb) {
self._connection.on('end', cb);
}

self._dequeue();
});
};

Expand Down
2 changes: 2 additions & 0 deletions test/simple/test-client.js
Expand Up @@ -374,6 +374,8 @@ test(function end() {
assert.equal(event, 'end');
assert.strictEqual(fn, CB);
});

gently.expect(client, '_dequeue');
});
fn();
});
Expand Down
18 changes: 18 additions & 0 deletions test/system/test-client-reconnect.js
@@ -0,0 +1,18 @@
require('../common');
var Client = require('mysql').Client,
gently = new Gently(),
client = new Client(TEST_CONFIG);

client.connect(gently.expect(function connectCb(err, result) {
assert.ifError(err);
}));

client.end(gently.expect(function endCb() {
}));

client.connect(gently.expect(function connectCb2(err, result) {
assert.ifError(err);

client.end();
}));

0 comments on commit 2db5bbd

Please sign in to comment.