Remove debugging. Treat can't get semaphore as a non-error

This commit is contained in:
Isaac Connor 2018-01-29 08:25:46 -08:00
parent 73d84c6b08
commit a76fcb331c
2 changed files with 82 additions and 81 deletions

View File

@ -166,10 +166,11 @@ if ( sem_acquire($semaphore,1) !== false ) {
}
sem_release($semaphore);
} else {
Error("Couldn't get semaphore");
Logger::Debug("Couldn't get semaphore");
ajaxResponse( array() );
}
ajaxError( 'Unrecognised action or insufficient permissions' );
ajaxError('Unrecognised action or insufficient permissions in ajax/stream');
function ajaxCleanup() {
global $socket, $localSocketFile;

View File

@ -106,7 +106,6 @@ function setAlarmState( currentAlarmState ) {
var streamCmdParms = "view=request&request=stream&connkey="+connKey;
if ( auth_hash )
streamCmdParms += '&auth='+auth_hash;
console.log("AJAX_TIMEOUT:"+AJAX_TIMEOUT + ' url:' + monitorUrl+thisUrl + ' parms: ' + streamCmdParms );
var streamCmdReq = new Request.JSON( {
url: monitorUrl+thisUrl,
method: 'get',
@ -123,95 +122,96 @@ function getStreamCmdFailure(xhr) {
console.log(xhr);
}
function getStreamCmdResponse( respObj, respText ) {
console.log(respText);
watchdogOk("stream");
if ( streamCmdTimer )
streamCmdTimer = clearTimeout( streamCmdTimer );
console.log(respText);
if ( respObj.result == 'Ok' ) {
streamStatus = respObj.status;
$('fpsValue').set( 'text', streamStatus.fps );
// The get status command can get backed up, in which case we won't be able to get the semaphore and will exit.
if ( respObj.status ) {
streamStatus = respObj.status;
$('fpsValue').set( 'text', streamStatus.fps );
setAlarmState( streamStatus.state );
setAlarmState( streamStatus.state );
$('levelValue').set( 'text', streamStatus.level );
if ( streamStatus.level > 95 )
$('levelValue').className = "alarm";
else if ( streamStatus.level > 80 )
$('levelValue').className = "alert";
else
$('levelValue').className = "ok";
$('levelValue').set( 'text', streamStatus.level );
if ( streamStatus.level > 95 )
$('levelValue').className = "alarm";
else if ( streamStatus.level > 80 )
$('levelValue').className = "alert";
else
$('levelValue').className = "ok";
var delayString = secsToTime( streamStatus.delay );
var delayString = secsToTime( streamStatus.delay );
if ( streamStatus.paused == true ) {
$('modeValue').set( 'text', "Paused" );
$('rate').addClass( 'hidden' );
$('delayValue').set( 'text', delayString );
$('delay').removeClass( 'hidden' );
$('level').removeClass( 'hidden' );
streamCmdPause( false );
} else if ( streamStatus.delayed == true ) {
$('modeValue').set( 'text', "Replay" );
$('rateValue').set( 'text', streamStatus.rate );
$('rate').removeClass( 'hidden' );
$('delayValue').set( 'text', delayString );
$('delay').removeClass( 'hidden' );
$('level').removeClass( 'hidden' );
if ( streamStatus.rate == 1 ) {
streamCmdPlay( false );
} else if ( streamStatus.rate > 0 ) {
if ( streamStatus.rate < 1 )
streamCmdSlowFwd( false );
else
streamCmdFastFwd( false );
} else {
if ( streamStatus.rate > -1 )
streamCmdSlowRev( false );
else
streamCmdFastRev( false );
} // rate
} else {
$('modeValue').set( 'text', "Live" );
$('rate').addClass( 'hidden' );
$('delay').addClass( 'hidden' );
$('level').addClass( 'hidden' );
streamCmdPlay( false );
} // end if paused or delayed
$('zoomValue').set( 'text', streamStatus.zoom );
if ( streamStatus.zoom == "1.0" )
setButtonState( $('zoomOutBtn'), 'unavail' );
else
setButtonState( $('zoomOutBtn'), 'inactive' );
if ( canEditMonitors ) {
if ( streamStatus.enabled ) {
$('enableAlarmsLink').addClass( 'hidden' );
$('disableAlarmsLink').removeClass( 'hidden' );
if ( streamStatus.forced ) {
$('forceAlarmLink').addClass( 'hidden' );
$('cancelAlarmLink').removeClass( 'hidden' );
if ( streamStatus.paused == true ) {
$('modeValue').set( 'text', "Paused" );
$('rate').addClass( 'hidden' );
$('delayValue').set( 'text', delayString );
$('delay').removeClass( 'hidden' );
$('level').removeClass( 'hidden' );
streamCmdPause( false );
} else if ( streamStatus.delayed == true ) {
$('modeValue').set( 'text', "Replay" );
$('rateValue').set( 'text', streamStatus.rate );
$('rate').removeClass( 'hidden' );
$('delayValue').set( 'text', delayString );
$('delay').removeClass( 'hidden' );
$('level').removeClass( 'hidden' );
if ( streamStatus.rate == 1 ) {
streamCmdPlay( false );
} else if ( streamStatus.rate > 0 ) {
if ( streamStatus.rate < 1 )
streamCmdSlowFwd( false );
else
streamCmdFastFwd( false );
} else {
$('forceAlarmLink').removeClass( 'hidden' );
$('cancelAlarmLink').addClass( 'hidden' );
}
$('forceCancelAlarm').removeClass( 'hidden' );
if ( streamStatus.rate > -1 )
streamCmdSlowRev( false );
else
streamCmdFastRev( false );
} // rate
} else {
$('enableAlarmsLink').removeClass( 'hidden' );
$('disableAlarmsLink').addClass( 'hidden' );
$('forceCancelAlarm').addClass( 'hidden' );
}
$('enableDisableAlarms').removeClass( 'hidden' );
} // end if canEditMonitors
$('modeValue').set( 'text', "Live" );
$('rate').addClass( 'hidden' );
$('delay').addClass( 'hidden' );
$('level').addClass( 'hidden' );
streamCmdPlay( false );
} // end if paused or delayed
if ( streamStatus.auth ) {
console.log("Haev a new auth hash" + streamStatus.auth);
// Try to reload the image stream.
var streamImg = $('liveStream');
if ( streamImg )
streamImg.src = streamImg.src.replace( /auth=\w+/i, 'auth='+streamStatus.auth );
} // end if haev a new auth hash
$('zoomValue').set( 'text', streamStatus.zoom );
if ( streamStatus.zoom == "1.0" )
setButtonState( $('zoomOutBtn'), 'unavail' );
else
setButtonState( $('zoomOutBtn'), 'inactive' );
if ( canEditMonitors ) {
if ( streamStatus.enabled ) {
$('enableAlarmsLink').addClass( 'hidden' );
$('disableAlarmsLink').removeClass( 'hidden' );
if ( streamStatus.forced ) {
$('forceAlarmLink').addClass( 'hidden' );
$('cancelAlarmLink').removeClass( 'hidden' );
} else {
$('forceAlarmLink').removeClass( 'hidden' );
$('cancelAlarmLink').addClass( 'hidden' );
}
$('forceCancelAlarm').removeClass( 'hidden' );
} else {
$('enableAlarmsLink').removeClass( 'hidden' );
$('disableAlarmsLink').addClass( 'hidden' );
$('forceCancelAlarm').addClass( 'hidden' );
}
$('enableDisableAlarms').removeClass( 'hidden' );
} // end if canEditMonitors
if ( streamStatus.auth ) {
console.log("Haev a new auth hash" + streamStatus.auth);
// Try to reload the image stream.
var streamImg = $('liveStream');
if ( streamImg )
streamImg.src = streamImg.src.replace( /auth=\w+/i, 'auth='+streamStatus.auth );
} // end if haev a new auth hash
} // end if respObj.status
} else {
checkStreamForErrors("getStreamCmdResponse",respObj);//log them
// Try to reload the image stream.