Merge branch 'master' of github.com:ZoneMinder/zoneminder

This commit is contained in:
Isaac Connor 2019-08-14 16:18:31 -04:00
commit 81dadc17dc
2 changed files with 30 additions and 29 deletions

View File

@ -562,8 +562,8 @@ sub CopyTo {
return 'Old Storage path changed, Event has moved somewhere else.';
}
$$self{Storage} = $NewStorage;
( $NewPath ) = ( $self->Path(undef) =~ /^(.*)$/ ); # De-taint
$NewPath .= $self->Relative_Path();
$NewPath = ( $NewPath =~ /^(.*)$/ ); # De-taint
if ( $NewPath eq $OldPath ) {
$ZoneMinder::Database::dbh->commit();
return "New path and old path are the same! $NewPath";
@ -685,7 +685,7 @@ sub MoveTo {
# Succeeded in copying all files, so we may now update the Event.
$$self{StorageId} = $$NewStorage{Id};
$$self{Storage} = $NewStorage;
$self->Storage($NewStorage);
$error .= $self->save();
if ( $error ) {
$ZoneMinder::Database::dbh->commit();

View File

@ -21,38 +21,38 @@ if ( sem_acquire($semaphore,1) !== false ) {
}
$localSocketFile = ZM_PATH_SOCKS.'/zms-'.sprintf('%06d',$_REQUEST['connkey']).'w.sock';
if ( file_exists( $localSocketFile ) ) {
if ( file_exists($localSocketFile) ) {
ZM\Warning("sock file $localSocketFile already exists?! Is someone else talking to zms?");
// They could be. We can maybe have concurrent requests from a browser.
}
if ( !socket_bind( $socket, $localSocketFile ) ) {
ajaxError("socket_bind( $localSocketFile ) failed: ".socket_strerror(socket_last_error()) );
if ( !socket_bind($socket, $localSocketFile) ) {
ajaxError("socket_bind( $localSocketFile ) failed: ".socket_strerror(socket_last_error()));
}
switch ( $_REQUEST['command'] ) {
case CMD_VARPLAY :
ZM\Logger::Debug( 'Varplaying to '.$_REQUEST['rate'] );
$msg = pack( 'lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['rate']+32768 );
ZM\Logger::Debug('Varplaying to '.$_REQUEST['rate']);
$msg = pack('lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['rate']+32768);
break;
case CMD_ZOOMIN :
ZM\Logger::Debug( 'Zooming to '.$_REQUEST['x'].','.$_REQUEST['y'] );
$msg = pack( 'lcnn', MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y'] );
ZM\Logger::Debug('Zooming to '.$_REQUEST['x'].','.$_REQUEST['y']);
$msg = pack('lcnn', MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y']);
break;
case CMD_PAN :
ZM\Logger::Debug( 'Panning to '.$_REQUEST['x'].','.$_REQUEST['y'] );
$msg = pack( 'lcnn', MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y'] );
ZM\Logger::Debug('Panning to '.$_REQUEST['x'].','.$_REQUEST['y']);
$msg = pack('lcnn', MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y']);
break;
case CMD_SCALE :
ZM\Logger::Debug( 'Scaling to '.$_REQUEST['scale'] );
$msg = pack( 'lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['scale'] );
ZM\Logger::Debug('Scaling to '.$_REQUEST['scale']);
$msg = pack('lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['scale']);
break;
case CMD_SEEK :
ZM\Logger::Debug( 'Seeking to '.$_REQUEST['offset'] );
$msg = pack( 'lcN', MSG_CMD, $_REQUEST['command'], $_REQUEST['offset'] );
ZM\Logger::Debug('Seeking to '.$_REQUEST['offset']);
$msg = pack('lcN', MSG_CMD, $_REQUEST['command'], $_REQUEST['offset']);
break;
default :
ZM\Logger::Debug('Sending command ' . $_REQUEST['command']);
$msg = pack( 'lc', MSG_CMD, $_REQUEST['command'] );
$msg = pack('lc', MSG_CMD, $_REQUEST['command']);
break;
}
@ -60,7 +60,8 @@ if ( sem_acquire($semaphore,1) !== false ) {
// Pi can take up to 3 seconds for zms to start up.
$max_socket_tries = 1000;
// FIXME This should not exceed web_ajax_timeout
while ( !file_exists($remSockFile) && $max_socket_tries-- ) { //sometimes we are too fast for our own good, if it hasn't been setup yet give it a second.
while ( !file_exists($remSockFile) && $max_socket_tries-- ) {
//sometimes we are too fast for our own good, if it hasn't been setup yet give it a second.
// WHY? We will just send another one...
// ANSWER: Because otherwise we get a log of errors logged
@ -71,27 +72,27 @@ if ( sem_acquire($semaphore,1) !== false ) {
if ( !file_exists($remSockFile) ) {
ajaxError("Socket $remSockFile does not exist. This file is created by zms, and since it does not exist, either zms did not run, or zms exited early. Please check your zms logs and ensure that CGI is enabled in apache and check that the PATH_ZMS is set correctly. Make sure that ZM is actually recording. If you are trying to view a live stream and the capture process (zmc) is not running then zms will exit. Please go to http://zoneminder.readthedocs.io/en/latest/faq.html#why-can-t-i-see-streamed-images-when-i-can-see-stills-in-the-zone-window-etc for more information.");
} else {
if ( !@socket_sendto( $socket, $msg, strlen($msg), 0, $remSockFile ) ) {
ajaxError( "socket_sendto( $remSockFile ) failed: ".socket_strerror(socket_last_error()) );
if ( !@socket_sendto($socket, $msg, strlen($msg), 0, $remSockFile) ) {
ajaxError("socket_sendto( $remSockFile ) failed: ".socket_strerror(socket_last_error()));
}
}
$rSockets = array( $socket );
$rSockets = array($socket);
$wSockets = NULL;
$eSockets = NULL;
$timeout = MSG_TIMEOUT - ( time() - $start_time );
$numSockets = socket_select( $rSockets, $wSockets, $eSockets, intval($timeout/1000), ($timeout%1000)*1000 );
$numSockets = socket_select($rSockets, $wSockets, $eSockets, intval($timeout/1000), ($timeout%1000)*1000);
if ( $numSockets === false ) {
ZM\Error('socket_select failed: ' . socket_strerror(socket_last_error()) );
ajaxError( 'socket_select failed: '.socket_strerror(socket_last_error()) );
ZM\Error('socket_select failed: ' . socket_strerror(socket_last_error()));
ajaxError('socket_select failed: '.socket_strerror(socket_last_error()));
} else if ( $numSockets < 0 ) {
ZM\Error( "Socket closed $remSockFile" );
ajaxError( "Socket closed $remSockFile" );
ZM\Error("Socket closed $remSockFile");
ajaxError("Socket closed $remSockFile");
} else if ( $numSockets == 0 ) {
ZM\Error( "Timed out waiting for msg $remSockFile" );
ZM\Error("Timed out waiting for msg $remSockFile");
socket_set_nonblock($socket);
#ajaxError("Timed out waiting for msg $remSockFile");
} else if ( $numSockets > 0 ) {
@ -101,7 +102,7 @@ if ( sem_acquire($semaphore,1) !== false ) {
}
}
switch( $nbytes = @socket_recvfrom( $socket, $msg, MSG_DATA_SIZE, 0, $remSockFile ) ) {
switch( $nbytes = @socket_recvfrom($socket, $msg, MSG_DATA_SIZE, 0, $remSockFile) ) {
case -1 :
ajaxError("socket_recvfrom( $remSockFile ) failed: ".socket_strerror(socket_last_error()));
break;
@ -157,7 +158,7 @@ if ( sem_acquire($semaphore,1) !== false ) {
}
sem_release($semaphore);
} else {
ZM\Logger::Debug("Couldn't get semaphore");
ZM\Logger::Debug('Couldn\'t get semaphore');
ajaxResponse(array());
}