Crash fix

This commit is contained in:
Calvin Montgomery 2014-06-15 16:34:32 -07:00
parent 0102b92730
commit 8152008466
2 changed files with 9 additions and 2 deletions

View file

@ -1039,6 +1039,7 @@ PlaylistModule.prototype.startPlayback = function (time) {
if (media.type === "gd") { if (media.type === "gd") {
this._gdRefreshTimer = setInterval(this.refreshGoogleDocs.bind(this), 3600000); this._gdRefreshTimer = setInterval(this.refreshGoogleDocs.bind(this), 3600000);
if (media.meta.expiration && media.meta.expiration < Date.now() + 3600000) { if (media.meta.expiration && media.meta.expiration < Date.now() + 3600000) {
var self = this;
setTimeout(this.refreshGoogleDocs.bind(this), media.meta.expiration - Date.now()); setTimeout(this.refreshGoogleDocs.bind(this), media.meta.expiration - Date.now());
} }
} }
@ -1086,6 +1087,11 @@ PlaylistModule.prototype._leadLoop = function() {
PlaylistModule.prototype.refreshGoogleDocs = function (cb) { PlaylistModule.prototype.refreshGoogleDocs = function (cb) {
var self = this; var self = this;
if (self.dead || !self.channel || self.channel.dead) {
return;
}
var abort = function () { var abort = function () {
clearInterval(self._gdRefreshTimer); clearInterval(self._gdRefreshTimer);
self._gdRefreshTimer = false; self._gdRefreshTimer = false;
@ -1111,7 +1117,9 @@ PlaylistModule.prototype.refreshGoogleDocs = function (cb) {
self.current.media.meta.object = self.current.media.meta.object || null; self.current.media.meta.object = self.current.media.meta.object || null;
self.current.media.meta.failed = true; self.current.media.meta.failed = true;
} }
cb && cb(); if (cb) {
cb();
}
self.channel.activeLock.release(); self.channel.activeLock.release();
} else { } else {
if (!self.current || self.current.media.type !== "gd") { if (!self.current || self.current.media.type !== "gd") {

View file

@ -27,7 +27,6 @@ var urlRetrieve = function (transport, options, callback) {
Logger.errlog.log(err.stack); Logger.errlog.log(err.stack);
Logger.errlog.log("urlRetrieve failed: " + err); Logger.errlog.log("urlRetrieve failed: " + err);
Logger.errlog.log("Request was: " + options.host + options.path); Logger.errlog.log("Request was: " + options.host + options.path);
callback(503, err);
}); });
d.run(function () { d.run(function () {
var req = transport.request(options, function (res) { var req = transport.request(options, function (res) {