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 {
|
} else {
|
||||||
this.flagStack[server][channel] = {
|
this.flagStack[server][channel] = {
|
||||||
'flags': {},
|
'flags': {},
|
||||||
'callbacks': [ callback ]
|
'callbacks': [ callback ],
|
||||||
|
'timeout': null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
dbot.say(server, 'chanserv', 'FLAGS ' + channel);
|
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)) {
|
if(_.has(this.flagStack[server], channel)) {
|
||||||
_.each(this.flagStack[server][channel].callbacks, function(callback) {
|
_.each(this.flagStack[server][channel].callbacks, function(callback) {
|
||||||
callback(true, null);
|
callback(true, null);
|
||||||
@ -103,10 +104,10 @@ var atheme = function(dbot) {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}.bind(this), function() {
|
}.bind(this), function() {
|
||||||
console.log('DONE');
|
|
||||||
_.each(this.flagStack[event.server][end[1]].callbacks, function(callback) {
|
_.each(this.flagStack[event.server][end[1]].callbacks, function(callback) {
|
||||||
callback(null, this.flagStack[event.server][end[1]].flags);
|
callback(null, this.flagStack[event.server][end[1]].flags);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
clearTimeout(this.flagStack[event.server][end[1]].timeout);
|
||||||
delete this.flagStack[event.server][end[1]];
|
delete this.flagStack[event.server][end[1]];
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user