Fix activeLock bug

This commit is contained in:
Calvin Montgomery 2014-07-09 22:37:11 -07:00
parent f92d4bc5d4
commit 1c77a24839
1 changed files with 5 additions and 1 deletions

View File

@ -282,9 +282,11 @@ Channel.prototype.notifyModules = function (fn, args) {
Channel.prototype.joinUser = function (user, data) {
var self = this;
self.activeLock.lock();
self.waitFlag(Flags.C_READY, function () {
/* User closed the connection before the channel finished loading */
if (user.socket.disconnected) {
self.activeLock.release();
return;
}
@ -293,6 +295,7 @@ Channel.prototype.joinUser = function (user, data) {
if (err) {
Logger.errlog.log("user.refreshAccount failed at Channel.joinUser");
Logger.errlog.log(err.stack);
self.activeLock.release();
return;
}
@ -304,6 +307,7 @@ Channel.prototype.joinUser = function (user, data) {
function afterAccount() {
if (self.dead || user.socket.disconnected) {
if (self.activeLock) self.activeLock.release();
return;
}
@ -312,11 +316,11 @@ Channel.prototype.joinUser = function (user, data) {
if (user.account.channelRank !== user.account.globalRank) {
user.socket.emit("rank", user.account.effectiveRank);
}
self.activeLock.lock();
self.acceptUser(user);
} else {
user.account.channelRank = 0;
user.account.effectiveRank = user.account.globalRank;
self.activeLock.release();
}
});
}