Permalink
Browse files

replication sync just accepts continuations from the same logger. if …

…different logger the sync restarts from 0
  • Loading branch information...
1 parent 4ae503b commit 0080215256817d1bb551f8aaad1d3bbf871475e6 @pgte committed Jan 24, 2011
Showing with 10 additions and 2 deletions.
  1. +10 −2 lib/alfred/meta/commands/replicate_from.js
@@ -28,6 +28,7 @@ ReplicateFromCommand.prototype.do = function(meta, callback) {
var reconnect_tries;
var last_run_log_pos = 0;
var logger_id;
+ var reconnecting = false;
var command_queue = [];
@@ -88,6 +89,7 @@ ReplicateFromCommand.prototype.do = function(meta, callback) {
(function connect() {
connection = net.createConnection(self.options.source_port, self.source);
connection.on('connect', function() {
+ reconnecting = false;
sendCommand('sync', {from: last_run_log_pos});
carrier.carry(connection, function(line) {
var command;
@@ -102,8 +104,14 @@ ReplicateFromCommand.prototype.do = function(meta, callback) {
logger_id = command.__logger_id;
} else {
if (logger_id != command.__logger_id) {
- last_run_log_pos = 0;
- process.nextTick(connect);
+ if (!reconnecting) {
+ reconnecting = true;
+ logger_id = undefined;
+ last_run_log_pos = 0;
+ connection.end();
+ reconnecting = true;
+ process.setTimeout(connect, 1000);
+ }
return;
}
}

0 comments on commit 0080215

Please sign in to comment.