commit
d5e403b7e0
|
@ -32,8 +32,8 @@ install:
|
|||
- sudo make install-libs
|
||||
before_script:
|
||||
- cd $TRAVIS_BUILD_DIR
|
||||
- if [ "$ZM_BUILDMETHOD" = "autotools" ]; then libtoolize --force; fi
|
||||
- if [ "$ZM_BUILDMETHOD" = "autotools" ]; then aclocal; fi
|
||||
- if [ "$ZM_BUILDMETHOD" = "autotools" ]; then libtoolize -v --force; fi
|
||||
- if [ "$ZM_BUILDMETHOD" = "autotools" ]; then aclocal -I m4; fi
|
||||
- if [ "$ZM_BUILDMETHOD" = "autotools" ]; then autoheader; fi
|
||||
- if [ "$ZM_BUILDMETHOD" = "autotools" ]; then automake --force-missing --add-missing; fi
|
||||
- if [ "$ZM_BUILDMETHOD" = "autotools" ]; then autoconf; fi
|
||||
|
|
|
@ -42,6 +42,7 @@ include (CheckFunctionExists)
|
|||
include (CheckPrototypeDefinition_fixed)
|
||||
include (CheckTypeSize)
|
||||
include (CheckStructHasMember)
|
||||
include (CheckSendfile)
|
||||
|
||||
# Configuration options
|
||||
mark_as_advanced(FORCE ZM_EXTRA_LIBS ZM_MYSQL_ENGINE ZM_NO_MMAP CMAKE_INSTALL_FULL_BINDIR ZM_PERL_MM_PARMS ZM_PERL_SEARCH_PATH ZM_TARGET_DISTRO ZM_CONFIG_DIR)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
AUTOMAKE_OPTIONS = foreign
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
# And these to the user and group of your webserver
|
||||
webuser = @WEB_USER@
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
aclocal
|
||||
aclocal -I m4
|
||||
autoheader
|
||||
automake --add-missing
|
||||
autoconf
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
# Check whether sendfile() is supported and what prototype it has
|
||||
include(CheckCSourceCompiles)
|
||||
if (UNIX OR MINGW)
|
||||
SET(CMAKE_REQUIRED_DEFINITIONS -Werror-implicit-function-declaration)
|
||||
endif()
|
||||
check_c_source_compiles("#include <sys/sendfile.h>
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
sendfile(1, 1, NULL, 0);
|
||||
return 0;
|
||||
}" HAVE_SENDFILE4_SUPPORT)
|
||||
if(HAVE_SENDFILE4_SUPPORT)
|
||||
add_definitions(-DHAVE_SENDFILE4_SUPPORT=1)
|
||||
unset(CMAKE_REQUIRED_DEFINITIONS)
|
||||
message(STATUS "Sendfile support: Linux/Solaris sendfile()")
|
||||
return()
|
||||
endif()
|
||||
find_library(SENDFILE_LIBRARIES NAMES sendfile)
|
||||
if(SENDFILE_LIBRARIES)
|
||||
include(CheckLibraryExists)
|
||||
check_library_exists(sendfile sendfile ${SENDFILE_LIBRARIES} HAVE_SENDFILE4_SUPPORT)
|
||||
if(HAVE_SENDFILE4_SUPPORT)
|
||||
add_definitions(-DHAVE_SENDFILE4_SUPPORT=1)
|
||||
unset(CMAKE_REQUIRED_DEFINITIONS)
|
||||
message(STATUS "Sendfile support: Solaris sendfile()")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
set(SENDFILE_LIBRARIES "")
|
||||
check_c_source_compiles("#include <sys/socket.h>
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
sendfile(1, 1, 0, 0, NULL, NULL, 0);
|
||||
return 0;
|
||||
}" HAVE_SENDFILE7_SUPPORT)
|
||||
if(HAVE_SENDFILE7_SUPPORT)
|
||||
add_definitions(-DHAVE_SENDFILE7_SUPPORT=1)
|
||||
unset(CMAKE_REQUIRED_DEFINITIONS)
|
||||
message(STATUS "Sendfile support: FreeBSD sendfile()")
|
||||
return()
|
||||
endif()
|
||||
check_c_source_compiles("#include <sys/socket.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/uio.h>
|
||||
int main()
|
||||
{
|
||||
sendfile(1, 1, 0, NULL, NULL, 0);
|
||||
return 0;
|
||||
}" HAVE_SENDFILE6_SUPPORT)
|
||||
if(HAVE_SENDFILE6_SUPPORT)
|
||||
add_definitions(-DHAVE_SENDFILE6_SUPPORT=1)
|
||||
unset(CMAKE_REQUIRED_DEFINITIONS)
|
||||
message(STATUS "Sendfile support: MacOS sendfile()")
|
||||
return()
|
||||
endif()
|
||||
|
12
configure.ac
12
configure.ac
|
@ -3,6 +3,7 @@ AC_INIT(zm,1.28.1,[http://www.zoneminder.com/forums/ - Please check FAQ first],z
|
|||
AM_INIT_AUTOMAKE
|
||||
AC_CONFIG_SRCDIR(src/zm.h)
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AC_SUBST([AM_CXXFLAGS], [-D__STDC_CONSTANT_MACROS])
|
||||
|
||||
|
@ -26,6 +27,12 @@ case $host_os in
|
|||
*BSD*)
|
||||
# Do something specific for BSD
|
||||
HOST_OS='BSD'
|
||||
AC_DEFINE(BSD,1,"This is a BSD system")
|
||||
;;
|
||||
*bsd*)
|
||||
# Do something specific for BSD
|
||||
HOST_OS='BSD'
|
||||
AC_DEFINE(BSD,1,"This is a BSD system")
|
||||
;;
|
||||
*)
|
||||
#Default Case
|
||||
|
@ -315,7 +322,8 @@ AC_FUNC_STRTOD
|
|||
AC_FUNC_VPRINTF
|
||||
AC_CHECK_FUNCS([gethostbyname gethostname gettimeofday memmove memset mkdir munmap posix_memalign putenv select sendfile socket sqrt strcasecmp strchr strcspn strerror strncasecmp strrchr strspn strstr strtol strtoull])
|
||||
AC_CHECK_FUNCS([syscall sleep usleep ioctl ioctlsocket sigaction])
|
||||
|
||||
# this is required for freebsd to compile. Look for it in m4/ac_check_sendfile.m4
|
||||
AC_CHECK_SENDFILE
|
||||
# Other programs
|
||||
AC_CHECK_PROG(OPT_FFMPEG,ffmpeg,yes,no)
|
||||
AC_PATH_PROG(PATH_FFMPEG,ffmpeg)
|
||||
|
@ -325,7 +333,9 @@ AC_CHECK_LIB(rt,clock_gettime,,AC_MSG_ERROR(zm requires librt))
|
|||
AC_SEARCH_LIBS(mysql_init,[mysqlclient mariadbclient],,AC_MSG_ERROR(zm requires libmysqlclient.a or libmariadbclient.a))
|
||||
AC_CHECK_LIB(jpeg,jpeg_start_compress,,AC_MSG_ERROR(zm requires libjpeg.a))
|
||||
AC_CHECK_LIB(pthread,pthread_create,,AC_MSG_ERROR(zm requires libpthread.a))
|
||||
if test "$BSD" == "0"; then
|
||||
AC_CHECK_LIB(dl,dlsym,,AC_MSG_ERROR(zm requires libdl.a))
|
||||
fi
|
||||
if test "$ZM_SSL_LIB" == "openssl"; then
|
||||
AC_CHECK_HEADERS(openssl/md5.h,,AC_MSG_WARN(zm requires openssl/md5.h header to be installed for openssl),)
|
||||
AC_CHECK_LIB(crypto,MD5,,AC_MSG_WARN([libcrypto.a is required for authenticated streaming - use ZM_SSL_LIB option to select gnutls instead]))
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
AC_DEFUN([AC_CHECK_SENDFILE],[
|
||||
AC_MSG_CHECKING([whether sendfile() is supported and what prototype it has])
|
||||
|
||||
saved_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
|
||||
ac_sendfile_supported=no
|
||||
AC_TRY_LINK([#include <sys/sendfile.h>
|
||||
#include <stdio.h>],
|
||||
[sendfile(1, 1, NULL, 0);],
|
||||
[
|
||||
AC_DEFINE(HAVE_SENDFILE4_SUPPORT, 1,
|
||||
[Define this if Linux/Solaris sendfile() is supported])
|
||||
AC_MSG_RESULT([Linux sendfile()])
|
||||
ac_sendfile_supported=yes
|
||||
], [])
|
||||
|
||||
if test x$ac_sendfile_supported = xno; then
|
||||
dnl Checking wether we need libsendfile
|
||||
dnl Presumably on Solaris
|
||||
AC_CHECK_LIB(sendfile, sendfile,
|
||||
[
|
||||
AC_DEFINE(HAVE_SENDFILE4_SUPPORT, 1,
|
||||
[Define this if Linux/Solaris sendfile() is supported])
|
||||
SENDFILE_LIBS="-lsendfile"
|
||||
AC_SUBST(SENDFILE_LIBS)
|
||||
AC_MSG_RESULT([Solaris sendfile()])
|
||||
ac_sendfile_supported=yes
|
||||
], [])
|
||||
fi
|
||||
|
||||
if test x$ac_sendfile_supported = xno; then
|
||||
dnl Checking wether we have FreeBSD-like sendfile() support.
|
||||
AC_TRY_LINK([#include <sys/socket.h>
|
||||
#include <stdio.h>],
|
||||
[sendfile(1, 1, 0, 0, NULL, NULL, 0);],
|
||||
[
|
||||
AC_DEFINE(HAVE_SENDFILE7_SUPPORT, 1,
|
||||
[Define this if FreeBSD sendfile() is supported])
|
||||
AC_MSG_RESULT([FreeBSD sendfile()])
|
||||
ac_sendfile_supported=yes
|
||||
], [])
|
||||
fi
|
||||
|
||||
if test x$ac_sendfile_supported = xno; then
|
||||
dnl Checking wether we have MacOS-like sendfile() support.
|
||||
AC_TRY_LINK([#include <sys/socket.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/uio.h>],
|
||||
[sendfile(1, 1, 0, NULL, NULL, 0);],
|
||||
[
|
||||
AC_DEFINE(HAVE_SENDFILE6_SUPPORT, 1,
|
||||
[Define this if MacOS sendfile() is supported])
|
||||
AC_MSG_RESULT([MacOS sendfile()])
|
||||
ac_sendfile_supported=yes
|
||||
], [])
|
||||
fi
|
||||
|
||||
CFLAGS="$saved_CFLAGS"
|
||||
|
||||
if test x$ac_sendfile_supported = xno; then
|
||||
AC_MSG_RESULT([no sendfile() support, using read/send])
|
||||
fi
|
||||
])
|
|
@ -36,6 +36,12 @@
|
|||
#include "zm_event.h"
|
||||
#include "zm_monitor.h"
|
||||
|
||||
// sendfile tricks
|
||||
extern "C"
|
||||
{
|
||||
#include "zm_sendfile.h"
|
||||
}
|
||||
|
||||
#include "zmf.h"
|
||||
|
||||
#if HAVE_SYS_SENDFILE_H
|
||||
|
@ -1309,7 +1315,7 @@ bool EventStream::sendFrame( int delta_us )
|
|||
if(send_raw) {
|
||||
#if HAVE_SENDFILE
|
||||
fprintf( stdout, "Content-Length: %d\r\n\r\n", (int)filestat.st_size );
|
||||
if(sendfile(fileno(stdout), fileno(fdj), 0, (int)filestat.st_size) != (int)filestat.st_size) {
|
||||
if(zm_sendfile(fileno(stdout), fileno(fdj), 0, (int)filestat.st_size) != (int)filestat.st_size) {
|
||||
/* sendfile() failed, use standard way instead */
|
||||
img_buffer_size = fread( img_buffer, 1, sizeof(temp_img_buffer), fdj );
|
||||
if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) {
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/thr.h>
|
||||
#endif
|
||||
|
||||
bool Logger::smInitialised = false;
|
||||
Logger *Logger::smInstance = 0;
|
||||
|
@ -527,9 +530,17 @@ void Logger::logPrint( bool hex, const char * const file, const int line, const
|
|||
#endif
|
||||
|
||||
pid_t tid;
|
||||
#ifdef __FreeBSD__
|
||||
long lwpid;
|
||||
thr_self(&lwpid);
|
||||
tid = lwpid;
|
||||
|
||||
if (tid < 0 ) // Thread/Process id
|
||||
#else
|
||||
#ifdef HAVE_SYSCALL
|
||||
if ( (tid = syscall(SYS_gettid)) < 0 ) // Thread/Process id
|
||||
#endif // HAVE_SYSCALL
|
||||
#endif
|
||||
tid = getpid(); // Process id
|
||||
|
||||
char *logPtr = logString;
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#ifdef HAVE_SENDFILE4_SUPPORT
|
||||
#include <sys/sendfile.h>
|
||||
int zm_sendfile(int out_fd, int in_fd, off_t *offset, size_t size) {
|
||||
int err;
|
||||
|
||||
err = sendfile(out_fd, in_fd, offset, size);
|
||||
if (err < 0)
|
||||
return -errno;
|
||||
|
||||
return err;
|
||||
}
|
||||
#elif HAVE_SENDFILE7_SUPPORT
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/uio.h>
|
||||
int zm_sendfile(int out_fd, int in_fd, off_t *offset, off_t size) {
|
||||
int err;
|
||||
err = sendfile(in_fd, out_fd, *offset, size, NULL, &size, 0);
|
||||
if (err && errno != EAGAIN)
|
||||
return -errno;
|
||||
|
||||
if (size) {
|
||||
*offset += size;
|
||||
return size;
|
||||
}
|
||||
|
||||
return -EAGAIN;
|
||||
}
|
||||
#else
|
||||
#error "Your platform does not support sendfile. Sorry."
|
||||
#endif
|
|
@ -28,12 +28,26 @@
|
|||
#endif // HAVE_SYS_SYSCALL_H
|
||||
#include "zm_exception.h"
|
||||
#include "zm_utils.h"
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/thr.h>
|
||||
#endif
|
||||
|
||||
class ThreadException : public Exception
|
||||
{
|
||||
private:
|
||||
pid_t pid() {
|
||||
pid_t tid;
|
||||
#ifdef __FreeBSD__
|
||||
long lwpid;
|
||||
thr_self(&lwpid);
|
||||
tid = lwpid;
|
||||
#else
|
||||
tid=syscall(SYS_gettid);
|
||||
#endif
|
||||
return tid;
|
||||
}
|
||||
public:
|
||||
ThreadException( const std::string &message ) : Exception( stringtf( "(%d) "+message, (long int)syscall(SYS_gettid) ) )
|
||||
{
|
||||
ThreadException( const std::string &message ) : Exception( stringtf( "(%d) "+message, (long int)pid() ) ) {
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -205,7 +219,15 @@ protected:
|
|||
|
||||
pid_t id() const
|
||||
{
|
||||
return( (pid_t)syscall(SYS_gettid) );
|
||||
pid_t tid;
|
||||
#ifdef __FreeBSD__
|
||||
long lwpid;
|
||||
thr_self(&lwpid);
|
||||
tid = lwpid;
|
||||
#else
|
||||
tid=syscall(SYS_gettid);
|
||||
#endif
|
||||
return tid;
|
||||
}
|
||||
void exit( int status = 0 )
|
||||
{
|
||||
|
|
|
@ -32,8 +32,20 @@ class Timer
|
|||
private:
|
||||
class TimerException : public Exception
|
||||
{
|
||||
private:
|
||||
pid_t pid() {
|
||||
pid_t tid;
|
||||
#ifdef __FreeBSD__
|
||||
long lwpid;
|
||||
thr_self(&lwpid);
|
||||
tid = lwpid;
|
||||
#else
|
||||
tid=syscall(SYS_gettid);
|
||||
#endif
|
||||
return tid;
|
||||
}
|
||||
public:
|
||||
TimerException( const std::string &message ) : Exception( stringtf( "(%d) "+message, (long int)syscall(SYS_gettid) ) )
|
||||
TimerException( const std::string &message ) : Exception( stringtf( "(%d) "+message, (long int)pid() ) )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,12 +19,16 @@
|
|||
|
||||
#include <getopt.h>
|
||||
#include <signal.h>
|
||||
#if defined(BSD)
|
||||
#if defined(__FreeBSD__)
|
||||
#include <limits.h>
|
||||
#else
|
||||
#include <values.h>
|
||||
#endif
|
||||
|
||||
#if !defined(MAXINT)
|
||||
#define MAXINT INT_MAX
|
||||
#endif
|
||||
|
||||
#include "zm.h"
|
||||
#include "zm_db.h"
|
||||
#include "zm_time.h"
|
||||
|
|
Loading…
Reference in New Issue