Merge branch 'storageareas' of github.com:connortechnology/ZoneMinder into storageareas
commit
ee8f371deb
|
@ -118,7 +118,7 @@ if ( $command eq 'version' ) {
|
|||
exit(0);
|
||||
}
|
||||
my $needs_daemon = $command !~ /(?:startup|shutdown|status|check|logrot|version)/;
|
||||
my $daemon = shift( @ARGV );
|
||||
my $daemon = shift @ARGV;
|
||||
if ( $needs_daemon && ! $daemon ) {
|
||||
print(STDERR "No daemon given\n");
|
||||
pod2usage(-exitstatus => -1);
|
||||
|
@ -209,7 +209,6 @@ if ( ($command eq 'check') && !$daemon ) {
|
|||
}
|
||||
|
||||
# The server is there, connect to it
|
||||
#print( "Writing commands\n" );
|
||||
CLIENT->autoflush();
|
||||
my $message = join(';', $command, ( $daemon ? $daemon : () ), @args );
|
||||
print(CLIENT $message);
|
||||
|
@ -218,9 +217,7 @@ while( my $line = <CLIENT> ) {
|
|||
chomp($line);
|
||||
print("$line\n");
|
||||
}
|
||||
# And we're done!
|
||||
close(CLIENT);
|
||||
#print( "Finished writing, bye\n" );
|
||||
|
||||
exit;
|
||||
|
||||
|
@ -319,7 +316,7 @@ sub run {
|
|||
|
||||
next if !$message;
|
||||
|
||||
my ( $command, $daemon, @args ) = split( /;/, $message );
|
||||
my ( $command, $daemon, @args ) = split(';', $message);
|
||||
|
||||
if ( $command eq 'start' ) {
|
||||
start($daemon, @args);
|
||||
|
@ -425,7 +422,7 @@ sub start {
|
|||
.strftime('%y/%m/%d %H:%M:%S', localtime($process->{started}))
|
||||
.", pid = $process->{pid}\n"
|
||||
);
|
||||
return();
|
||||
return;
|
||||
}
|
||||
|
||||
my $sigset = POSIX::SigSet->new;
|
||||
|
@ -436,7 +433,7 @@ sub start {
|
|||
|
||||
$process->{pid} = $cpid;
|
||||
$process->{started} = time();
|
||||
delete( $process->{pending} );
|
||||
delete $process->{pending};
|
||||
|
||||
dPrint(ZoneMinder::Logger::INFO, "'$command' starting at "
|
||||
.strftime('%y/%m/%d %H:%M:%S', localtime($process->{started}))
|
||||
|
@ -450,8 +447,7 @@ sub start {
|
|||
$dbh = zmDbConnect(1);
|
||||
logReinit();
|
||||
|
||||
dPrint( ZoneMinder::Logger::INFO, "'".join( ' ', ( $daemon, @args ) )
|
||||
."' started at "
|
||||
dPrint(ZoneMinder::Logger::INFO, "'$command' started at "
|
||||
.strftime('%y/%m/%d %H:%M:%S', localtime())
|
||||
."\n"
|
||||
);
|
||||
|
@ -466,7 +462,7 @@ sub start {
|
|||
foreach my $arg ( @args ) {
|
||||
# Detaint arguments, if they look ok
|
||||
if ( $arg =~ /^(-{0,2}[\w\/?&=.-]+)$/ ) {
|
||||
push( @good_args, $1 );
|
||||
push @good_args, $1;
|
||||
} else {
|
||||
Fatal("Bogus argument '$arg' found");
|
||||
}
|
||||
|
@ -490,7 +486,7 @@ sub start {
|
|||
} else {
|
||||
Fatal("Can't fork: $!");
|
||||
}
|
||||
}
|
||||
} # end sub start
|
||||
|
||||
# Sends the stop signal, without waiting around to see if the process died.
|
||||
sub send_stop {
|
||||
|
@ -499,7 +495,7 @@ sub send_stop {
|
|||
my $command = $process->{command};
|
||||
if ( $process->{pending} ) {
|
||||
|
||||
delete( $cmd_hash{$command} );
|
||||
delete $cmd_hash{$command};
|
||||
dPrint(ZoneMinder::Logger::INFO, "Command '$command' removed from pending list at "
|
||||
.strftime('%y/%m/%d %H:%M:%S', localtime())
|
||||
."\n"
|
||||
|
@ -522,7 +518,6 @@ sub send_stop {
|
|||
$process->{pending} = 0;
|
||||
$terminating_processes{$command} = $process;
|
||||
|
||||
|
||||
kill('TERM', $pid);
|
||||
return $pid;
|
||||
} # end sub send_stop
|
||||
|
@ -534,6 +529,7 @@ sub check_for_processes_to_kill {
|
|||
sigprocmask(SIG_BLOCK, $blockset, $sigset) or die "dying at block...\n";
|
||||
foreach my $command ( %terminating_processes ) {
|
||||
my $process = $cmd_hash{$command};
|
||||
Debug("Have process $command at pid $$process{pid} $$process{term_sent_at}");
|
||||
if ( $$process{term_sent_at} - time > KILL_DELAY ) {
|
||||
dPrint(ZoneMinder::Logger::WARNING, "'$$process{command}' has not stopped at "
|
||||
.strftime('%y/%m/%d %H:%M:%S', localtime())
|
||||
|
@ -591,7 +587,7 @@ sub reload {
|
|||
|
||||
sub logrot {
|
||||
logReinit();
|
||||
foreach my $process ( values(%pid_hash) ) {
|
||||
foreach my $process ( values %pid_hash ) {
|
||||
if ( $process->{pid} ) {
|
||||
# && $process->{command} =~ /^zm.*\.pl/ ) {
|
||||
kill('HUP', $process->{pid});
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "zm_rtsp_auth.h"
|
||||
|
||||
#include "zm_mem_utils.h"
|
||||
#include "zm_signal.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
@ -194,7 +195,7 @@ int RemoteCameraHttp::ReadData( Buffer &buffer, unsigned int bytes_expected ) {
|
|||
|
||||
int n_found = select(sd+1, &rfds, NULL, NULL, &temp_timeout);
|
||||
if( n_found == 0 ) {
|
||||
Debug( 4, "Select timed out timeout was %d secs %d usecs", temp_timeout.tv_sec, temp_timeout.tv_usec );
|
||||
Debug( 1, "Select timed out timeout was %d secs %d usecs", temp_timeout.tv_sec, temp_timeout.tv_usec );
|
||||
int error = 0;
|
||||
socklen_t len = sizeof (error);
|
||||
int retval = getsockopt (sd, SOL_SOCKET, SO_ERROR, &error, &len);
|
||||
|
@ -206,10 +207,10 @@ int RemoteCameraHttp::ReadData( Buffer &buffer, unsigned int bytes_expected ) {
|
|||
}
|
||||
// Why are we disconnecting? It's just a timeout, meaning that data wasn't available.
|
||||
//Disconnect();
|
||||
return( 0 );
|
||||
return 0;
|
||||
} else if ( n_found < 0) {
|
||||
Error("Select error: %s", strerror(errno));
|
||||
return( -1 );
|
||||
return -1;
|
||||
}
|
||||
|
||||
unsigned int total_bytes_to_read = 0;
|
||||
|
@ -309,13 +310,14 @@ int RemoteCameraHttp::GetResponse()
|
|||
static RegExpr *content_length_expr = 0;
|
||||
static RegExpr *content_type_expr = 0;
|
||||
|
||||
while ( ! ( buffer_len = ReadData( buffer ) ) ) {
|
||||
while ( !( buffer_len = ReadData(buffer) ) && !zm_terminate ) {
|
||||
Debug(4, "Timeout waiting for REGEXP HEADER");
|
||||
}
|
||||
if ( buffer_len < 0 ) {
|
||||
Error( "Unable to read header data" );
|
||||
return( -1 );
|
||||
}
|
||||
bytes += buffer_len;
|
||||
if ( !header_expr )
|
||||
header_expr = new RegExpr( "^(.+?\r?\n\r?\n)", PCRE_DOTALL );
|
||||
if ( header_expr->Match( (char*)buffer, buffer.size() ) == 2 )
|
||||
|
@ -483,13 +485,14 @@ int RemoteCameraHttp::GetResponse()
|
|||
else
|
||||
{
|
||||
Debug( 3, "Unable to extract subheader from stream, retrying" );
|
||||
while ( ! ( buffer_len = ReadData( buffer ) ) ) {
|
||||
while ( !( buffer_len = ReadData(buffer) ) && !zm_terminate ) {
|
||||
Debug(4, "Timeout waiting to extract subheader");
|
||||
}
|
||||
if ( buffer_len < 0 ) {
|
||||
Error( "Unable to extract subheader data" );
|
||||
return( -1 );
|
||||
}
|
||||
bytes += buffer_len;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -522,13 +525,16 @@ int RemoteCameraHttp::GetResponse()
|
|||
|
||||
if ( content_length )
|
||||
{
|
||||
while ( (long)buffer.size() < content_length )
|
||||
while ( ((long)buffer.size() < content_length ) && ! zm_terminate )
|
||||
{
|
||||
Debug(3, "Need more data buffer %d < content length %d", buffer.size(), content_length );
|
||||
if ( ReadData( buffer ) < 0 ) {
|
||||
int bytes_read = ReadData( buffer );
|
||||
|
||||
if ( bytes_read < 0 ) {
|
||||
Error( "Unable to read content" );
|
||||
return( -1 );
|
||||
}
|
||||
bytes += bytes_read;
|
||||
}
|
||||
Debug( 3, "Got end of image by length, content-length = %d", content_length );
|
||||
}
|
||||
|
@ -536,13 +542,14 @@ int RemoteCameraHttp::GetResponse()
|
|||
{
|
||||
while ( !content_length )
|
||||
{
|
||||
while ( ! ( buffer_len = ReadData( buffer ) ) ) {
|
||||
while ( !( buffer_len = ReadData(buffer) ) && !zm_terminate ) {
|
||||
Debug(4, "Timeout waiting for content");
|
||||
}
|
||||
if ( buffer_len < 0 ) {
|
||||
Error( "Unable to read content" );
|
||||
return( -1 );
|
||||
}
|
||||
bytes += buffer_len;
|
||||
static RegExpr *content_expr = 0;
|
||||
if ( mode == MULTI_IMAGE )
|
||||
{
|
||||
|
@ -656,13 +663,14 @@ int RemoteCameraHttp::GetResponse()
|
|||
}
|
||||
case HEADERCONT :
|
||||
{
|
||||
while ( ! ( buffer_len = ReadData( buffer ) ) ) {
|
||||
while ( !( buffer_len = ReadData(buffer) ) && !zm_terminate ) {
|
||||
Debug(4, "Timeout waiting for HEADERCONT");
|
||||
}
|
||||
if ( buffer_len < 0 ) {
|
||||
Error( "Unable to read header" );
|
||||
return( -1 );
|
||||
}
|
||||
bytes += buffer_len;
|
||||
|
||||
char *crlf = 0;
|
||||
char *header_ptr = (char *)buffer;
|
||||
|
@ -941,13 +949,14 @@ int RemoteCameraHttp::GetResponse()
|
|||
state = CONTENT;
|
||||
} else {
|
||||
Debug( 3, "Unable to extract subheader from stream, retrying" );
|
||||
while ( ! ( buffer_len = ReadData( buffer ) ) ) {
|
||||
while ( !( buffer_len = ReadData(buffer) ) &&!zm_terminate ) {
|
||||
Debug(1, "Timeout waiting to extra subheader non regexp");
|
||||
}
|
||||
if ( buffer_len < 0 ) {
|
||||
Error( "Unable to read subheader" );
|
||||
return( -1 );
|
||||
}
|
||||
bytes += buffer_len;
|
||||
state = SUBHEADERCONT;
|
||||
}
|
||||
break;
|
||||
|
@ -980,18 +989,19 @@ int RemoteCameraHttp::GetResponse()
|
|||
}
|
||||
|
||||
if ( content_length ) {
|
||||
while ( (long)buffer.size() < content_length ) {
|
||||
//int buffer_len = ReadData( buffer, content_length-buffer.size() );
|
||||
while ( ( (long)buffer.size() < content_length ) && ! zm_terminate ) {
|
||||
Debug(4, "getting more data");
|
||||
if ( ReadData( buffer ) < 0 ) {
|
||||
int bytes_read = ReadData(buffer);
|
||||
if ( bytes_read < 0 ) {
|
||||
Error("Unable to read content");
|
||||
return( -1 );
|
||||
return -1;
|
||||
}
|
||||
bytes += bytes_read;
|
||||
}
|
||||
Debug( 3, "Got end of image by length, content-length = %d", content_length );
|
||||
} else {
|
||||
// Read until we find the end of image or the stream closes.
|
||||
while ( !content_length ) {
|
||||
while ( !content_length && !zm_terminate ) {
|
||||
Debug(4, "!content_length, ReadData");
|
||||
buffer_len = ReadData( buffer );
|
||||
if ( buffer_len < 0 )
|
||||
|
@ -999,6 +1009,7 @@ int RemoteCameraHttp::GetResponse()
|
|||
Error( "Unable to read content" );
|
||||
return( -1 );
|
||||
}
|
||||
bytes += buffer_len;
|
||||
int buffer_size = buffer.size();
|
||||
if ( buffer_len ) {
|
||||
// Got some data
|
||||
|
|
|
@ -228,6 +228,7 @@ int main(int argc, char *argv[]) {
|
|||
sigset_t block_set;
|
||||
sigemptyset(&block_set);
|
||||
|
||||
sigaddset(&block_set, SIGHUP);
|
||||
sigaddset(&block_set, SIGUSR1);
|
||||
sigaddset(&block_set, SIGUSR2);
|
||||
|
||||
|
|
|
@ -133,10 +133,7 @@ function dbQuery( $sql, $params=NULL ) {
|
|||
}
|
||||
} else {
|
||||
if ( defined('ZM_DB_DEBUG') ) {
|
||||
if ( $params )
|
||||
Warning("SQL: $sql" . implode(',',$params) );
|
||||
else
|
||||
Warning("SQL: $sql:" );
|
||||
Logger::Debug("SQL: $sql values:" . $params?implode(',',$params):'' );
|
||||
}
|
||||
$result = $dbConn->query($sql);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue