forked from GitHub/dbot
fix race condition in getting flag stack
This commit is contained in:
parent
f7785c95a3
commit
024ee7913e
@ -17,12 +17,13 @@ var atheme = function(dbot) {
|
||||
} else {
|
||||
this.flagStack[server][channel] = {
|
||||
'flags': {},
|
||||
'callbacks': [ callback ]
|
||||
'callbacks': [ callback ],
|
||||
'timeout': null
|
||||
};
|
||||
}
|
||||
|
||||
dbot.say(server, 'chanserv', 'FLAGS ' + channel);
|
||||
setTimeout(function() { // Delete callback if no response
|
||||
this.flagStack[server][channel].timeout = setTimeout(function() { // Delete callback if no response
|
||||
if(_.has(this.flagStack[server], channel)) {
|
||||
_.each(this.flagStack[server][channel].callbacks, function(callback) {
|
||||
callback(true, null);
|
||||
@ -103,10 +104,10 @@ var atheme = function(dbot) {
|
||||
done();
|
||||
});
|
||||
}.bind(this), function() {
|
||||
console.log('DONE');
|
||||
_.each(this.flagStack[event.server][end[1]].callbacks, function(callback) {
|
||||
callback(null, this.flagStack[event.server][end[1]].flags);
|
||||
}.bind(this));
|
||||
clearTimeout(this.flagStack[event.server][end[1]].timeout);
|
||||
delete this.flagStack[event.server][end[1]];
|
||||
}.bind(this));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user