commit
51703f5c37
|
@ -64,3 +64,14 @@ void zmDbConnect()
|
|||
zmDbConnected = true;
|
||||
}
|
||||
|
||||
void zmDbClose()
|
||||
{
|
||||
if ( zmDbConnected )
|
||||
{
|
||||
mysql_close( &dbconn );
|
||||
// mysql_init() call implicitly mysql_library_init() but
|
||||
// mysql_close() does not call mysql_library_end()
|
||||
mysql_library_end();
|
||||
zmDbConnected = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ extern MYSQL dbconn;
|
|||
extern int zmDbConnected;
|
||||
|
||||
void zmDbConnect();
|
||||
void zmDbClose();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
@ -239,6 +239,9 @@ void Logger::terminate()
|
|||
|
||||
if ( mSyslogLevel > NOLOG )
|
||||
closeSyslog();
|
||||
|
||||
if ( mDatabaseLevel > NOLOG )
|
||||
closeDatabase();
|
||||
}
|
||||
|
||||
bool Logger::boolEnv( const std::string &name, bool defaultValue )
|
||||
|
@ -468,6 +471,15 @@ void Logger::closeFile()
|
|||
}
|
||||
}
|
||||
|
||||
void Logger::closeDatabase()
|
||||
{
|
||||
if ( mDbConnected )
|
||||
{
|
||||
mysql_close( &mDbConnection );
|
||||
mDbConnected = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::openSyslog()
|
||||
{
|
||||
(void) openlog( mId.c_str(), LOG_PID|LOG_NDELAY, LOG_LOCAL1 );
|
||||
|
@ -604,5 +616,6 @@ void logInit( const char *name, const Logger::Options &options )
|
|||
|
||||
void logTerm()
|
||||
{
|
||||
Logger::fetch()->terminate();
|
||||
if ( Logger::smInstance )
|
||||
delete Logger::smInstance;
|
||||
}
|
||||
|
|
|
@ -115,6 +115,7 @@ private:
|
|||
|
||||
public:
|
||||
friend void logInit( const char *name, const Options &options );
|
||||
friend void logTerm();
|
||||
|
||||
static Logger *fetch()
|
||||
{
|
||||
|
@ -182,6 +183,7 @@ private:
|
|||
void closeFile();
|
||||
void openSyslog();
|
||||
void closeSyslog();
|
||||
void closeDatabase();
|
||||
|
||||
public:
|
||||
void logPrint( bool hex, const char * const file, const int line, const int level, const char *fstring, ... );
|
||||
|
|
|
@ -137,5 +137,7 @@ int main( int argc, char *argv[] )
|
|||
{
|
||||
fprintf( stderr, "Can't find monitor with id of %d\n", id );
|
||||
}
|
||||
logTerm();
|
||||
zmDbClose();
|
||||
return( 0 );
|
||||
}
|
||||
|
|
|
@ -302,5 +302,8 @@ int main( int argc, char *argv[] )
|
|||
delete [] next_delays;
|
||||
delete [] last_capture_times;
|
||||
|
||||
logTerm();
|
||||
zmDbClose();
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
|
|
@ -307,4 +307,6 @@ int main( int argc, char *argv[] )
|
|||
|
||||
sigprocmask( SIG_UNBLOCK, &block_set, 0 );
|
||||
}
|
||||
logTerm();
|
||||
zmDbClose();
|
||||
}
|
||||
|
|
10
src/zms.cpp
10
src/zms.cpp
|
@ -223,6 +223,8 @@ int main( int argc, const char *argv[] )
|
|||
if ( !user )
|
||||
{
|
||||
Error( "Unable to authenticate user" );
|
||||
logTerm();
|
||||
zmDbClose();
|
||||
return( -1 );
|
||||
}
|
||||
ValidateAccess( user, monitor_id );
|
||||
|
@ -286,6 +288,8 @@ int main( int argc, const char *argv[] )
|
|||
#else // HAVE_LIBAVCODEC
|
||||
Error( "MPEG streaming of '%s' attempted while disabled", query );
|
||||
fprintf( stderr, "MPEG streaming is disabled.\nYou should configure with the --with-ffmpeg option and rebuild to use this functionality.\n" );
|
||||
logTerm();
|
||||
zmDbClose();
|
||||
return( -1 );
|
||||
#endif // HAVE_LIBAVCODEC
|
||||
}
|
||||
|
@ -320,10 +324,16 @@ int main( int argc, const char *argv[] )
|
|||
#else // HAVE_LIBAVCODEC
|
||||
Error( "MPEG streaming of '%s' attempted while disabled", query );
|
||||
fprintf( stderr, "MPEG streaming is disabled.\nYou should ensure the ffmpeg libraries are installed and detected and rebuild to use this functionality.\n" );
|
||||
logTerm();
|
||||
zmDbClose();
|
||||
return( -1 );
|
||||
#endif // HAVE_LIBAVCODEC
|
||||
}
|
||||
stream.runStream();
|
||||
}
|
||||
|
||||
logTerm();
|
||||
zmDbClose();
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
|
|
@ -169,6 +169,8 @@ int main(int argc, char** argv) {
|
|||
stream.setStreamBitrate(bitrate); // default = 100000 (bitrate)
|
||||
#else
|
||||
fprintf(stderr, "MPEG streaming is disabled.\nYou should configure with the --with-ffmpeg option and rebuild to use this functionality.\n");
|
||||
logTerm();
|
||||
zmDbClose();
|
||||
return EXIT_FAILURE;
|
||||
#endif
|
||||
}
|
||||
|
@ -192,5 +194,8 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
if (debug) printf("Done.\n");
|
||||
|
||||
logTerm();
|
||||
zmDbClose();
|
||||
|
||||
return (EXIT_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -754,5 +754,8 @@ int main( int argc, char *argv[] )
|
|||
}
|
||||
delete user;
|
||||
|
||||
logTerm();
|
||||
zmDbClose();
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue