pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

zoneminder: Address thread portability and type issues



Module Name:	pkgsrc-wip
Committed By:	Greg Troxel <gdt%lexort.com@localhost>
Pushed By:	gdt
Date:		Tue Jun 18 17:36:42 2019 -0400
Changeset:	b5f4eafacc71b6e278785441ed4c603e0169f12e

Modified Files:
	zoneminder/distinfo
	zoneminder/patches/patch-src_zm__thread.h
	zoneminder/patches/patch-src_zm_thread_cpp
	zoneminder/patches/patch-src_zmu.cpp

Log Message:
zoneminder: Address thread portability and type issues

zoneminder seems to on one hand assume pthreads and the other not.  On
NetBSD and Solaris, assume pthreads harder.

Cast tv_use to long, because the code uses %ld, and that's easier than
trying to change more.  (This update will be superceded anyway, and
the time type issues need to be fixed upstream.)

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=b5f4eafacc71b6e278785441ed4c603e0169f12e

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 zoneminder/distinfo                        |  6 +--
 zoneminder/patches/patch-src_zm__thread.h  | 77 ++++++++++++++++++++++--------
 zoneminder/patches/patch-src_zm_thread_cpp | 30 +++++++++++-
 zoneminder/patches/patch-src_zmu.cpp       | 23 ++++++---
 4 files changed, 105 insertions(+), 31 deletions(-)

diffs:
diff --git a/zoneminder/distinfo b/zoneminder/distinfo
index d9fab17e79..0d22e935cc 100644
--- a/zoneminder/distinfo
+++ b/zoneminder/distinfo
@@ -13,7 +13,7 @@ SHA1 (patch-src_zm__event.cpp) = 3e114b280c3a19e0520c24f148fb1b2e2400e709
 SHA1 (patch-src_zm__monitor.cpp) = 7139b1d0ea094afd99e96d30092f78c362c7b993
 SHA1 (patch-src_zm__rtp__source.cpp) = 5341938eefe5def49dc8f3e3b760d86cabd17772
 SHA1 (patch-src_zm__sdp.cpp) = ed89bc14ae557281bb43baca9c90b78d801d8eb1
-SHA1 (patch-src_zm__thread.h) = 417467a52ac04f92a48b7b25feacc2cdb011b718
+SHA1 (patch-src_zm__thread.h) = e537fa7e359a7b63dc557b12675ee7c6b8aa7f15
 SHA1 (patch-src_zm__timer.h) = 12048c839da9ba497b54d93100cc8ca7d537391e
 SHA1 (patch-src_zm__utils.cpp) = f6a109296146822014d57d39094390adcc5df760
 SHA1 (patch-src_zm__utils.h) = dbda8ba527f08b0337f6d2afa155ce4adc733e1e
@@ -22,9 +22,9 @@ SHA1 (patch-src_zm_comms_h) = 75ceba7e2c725c02a09cb2203a94142b1a987bce
 SHA1 (patch-src_zm_logger_cpp) = 67f2db12ecbdcfd4d90b6e8a2b9bcb6dab159044
 SHA1 (patch-src_zm_remote_camera_h) = 0d4bd7dae0188df7e463586250ac2ed530230f3d
 SHA1 (patch-src_zm_signal_cpp) = 0e53c30d408cf926d9a1f05a683e10cd8b9f2d8e
-SHA1 (patch-src_zm_thread_cpp) = c5f64697c3024c6c382f9ae2c5dbe9c21b529b6e
+SHA1 (patch-src_zm_thread_cpp) = 885fd7205815ec024a8ff5b2212404d4d0ef6b6b
 SHA1 (patch-src_zmc_cpp) = 9fee2df53603a26a086fc2d8a56b29e4059f3ed1
 SHA1 (patch-src_zmf.cpp) = a059b9ae068037c6f68c16dab861ed830dd1c7e2
-SHA1 (patch-src_zmu.cpp) = c83283c1ac38e7c39201f72099b9830d84566c41
+SHA1 (patch-src_zmu.cpp) = 9495fed676d67e5ba687e37564974f220d2ea4e7
 SHA1 (patch-web_Makefile.am) = ddb3815fa1b1799658034789302c8d3840f2b894
 SHA1 (patch-web_ajax_stream_php) = e8f811e63bedec03345b74db72c3d8014b3cc7f6
diff --git a/zoneminder/patches/patch-src_zm__thread.h b/zoneminder/patches/patch-src_zm__thread.h
index 942486e8e1..b88aef3396 100644
--- a/zoneminder/patches/patch-src_zm__thread.h
+++ b/zoneminder/patches/patch-src_zm__thread.h
@@ -8,7 +8,7 @@ portable than syscall(SYS_gettid).
 
 --- src/zm_thread.h.orig	2016-02-03 18:40:30.000000000 +0000
 +++ src/zm_thread.h
-@@ -22,10 +22,8 @@
+@@ -22,20 +22,21 @@
  
  #include <unistd.h>
  #include <pthread.h>
@@ -20,26 +20,21 @@ portable than syscall(SYS_gettid).
  #include "zm_exception.h"
  #include "zm_utils.h"
  #ifdef __FreeBSD__
-@@ -35,7 +33,7 @@
+ #include <sys/thr.h>
+ #endif
+ 
++/* Assume that because pthread.h was included, all systems have pthread.*/
++#define USE_PTHREAD
++
  class ThreadException : public Exception
  {
  private:
 -#ifndef SOLARIS
-+#if !defined(SOLARIS) && !defined(__NetBSD__)
++#ifndef USE_PTHREAD
  pid_t pid() {
      pid_t tid; 
  #ifdef __FreeBSD__ 
-@@ -46,7 +44,9 @@ pid_t pid() {
-     #ifdef __FreeBSD_kernel__
-         if ( (syscall(SYS_thr_self, &tid)) < 0 ) // Thread/Process id
-     # else
-+	#ifdef linux
-         tid=syscall(SYS_gettid); 
-+	#endif
-     #endif
- #endif
-     return tid;
-@@ -55,7 +55,8 @@ pid_t pid() {
+@@ -55,7 +56,8 @@ pid_t pid() {
  pthread_t pid() { return( pthread_self() ); }
  #endif
  public:
@@ -49,13 +44,57 @@ portable than syscall(SYS_gettid).
      }
  };
  
-@@ -242,7 +243,9 @@ protected:
-         if ( (syscall(SYS_thr_self, &tid)) < 0 ) // Thread/Process id
+@@ -217,7 +219,7 @@ protected:
  
+     Mutex mThreadMutex;
+     Condition mThreadCondition;
+-#ifndef SOLARIS
++#ifndef USE_PTHREAD
+     pid_t mPid;
+ #else
+     pthread_t mPid;
+@@ -229,7 +231,7 @@ protected:
+     Thread();
+     virtual ~Thread();
+ 
+-#ifndef SOLARIS
++#ifndef USE_PTHREAD
+     pid_t id() const
+     {
+         pid_t tid; 
+@@ -237,22 +239,21 @@ protected:
+         long lwpid; 
+         thr_self(&lwpid); 
+         tid = lwpid; 
+-#else 
++#else /* __FreeBSD__ */
+     #ifdef __FreeBSD_kernel__
+         if ( (syscall(SYS_thr_self, &tid)) < 0 ) // Thread/Process id
+-
      #else
-+	#ifdef linux
          tid=syscall(SYS_gettid); 
-+	#endif
      #endif
- #endif
+-#endif
++#endif /* __FreeBSD__ */
  return tid;
+     }
+-#else
++#else /* USE_PTHREAD */
+     pthread_t id() const
+     {
+         return( pthread_self() );
+     }
+-#endif
++#endif /* USE_PTHREAD */
+     void exit( int status = 0 )
+     {
+         //INFO( "Exiting" );
+@@ -268,7 +269,7 @@ public:
+     void kill( int signal );
+     bool isThread()
+     {
+-        return( mPid > -1 && pthread_equal( pthread_self(), mThread ) );
++        return( /* mPid > -1 && */ pthread_equal( pthread_self(), mThread ) );
+     }
+     bool isStarted() const { return( mStarted ); }
+     bool isRunning() const { return( mRunning ); }
diff --git a/zoneminder/patches/patch-src_zm_thread_cpp b/zoneminder/patches/patch-src_zm_thread_cpp
index b02a0a5288..0212a45f31 100644
--- a/zoneminder/patches/patch-src_zm_thread_cpp
+++ b/zoneminder/patches/patch-src_zm_thread_cpp
@@ -3,7 +3,7 @@ $NetBSD: patch-src_zm_thread_cpp,v 1.2 2013/03/24 16:47:47 joerg Exp $
 pthread_mutex_timedlock() is not available on NetBSD 5.0, and not required
 in ZoneMinder.
 
---- src/zm_thread.cpp.orig	2011-06-21 09:19:11.000000000 +0000
+--- src/zm_thread.cpp.orig	2016-02-03 18:40:30.000000000 +0000
 +++ src/zm_thread.cpp
 @@ -72,6 +72,7 @@ void Mutex::lock()
          throw ThreadException( stringtf( "Unable to lock pthread mutex: %s", strerror(errno) ) );
@@ -21,7 +21,33 @@ in ZoneMinder.
  
  void Mutex::unlock()
  {
-@@ -336,4 +338,5 @@ void Thread::kill( int signal )
+@@ -232,9 +234,15 @@ template <class T> void ThreadData<T>::u
+     Debug( 9, "Updated value, %p", this );
+ }
+ 
++#ifndef USE_PTHREAD
++#define MPID_UNDEFINED -1
++#else /* USE_PTHREAD */
++#define MPID_UNDEFINED NULL
++#endif /* USE_PTHREAD */
++
+ Thread::Thread() :
+     mThreadCondition( mThreadMutex ),
+-    mPid( -1 ),
++    mPid( MPID_UNDEFINED ),
+     mStarted( false ),
+     mRunning( false )
+ {
+@@ -308,7 +316,7 @@ void Thread::join()
+     if ( isThread() )
+         throw ThreadException( "Can't self join thread" );
+     mThreadMutex.lock();
+-    if ( mPid >= 0 )
++    if ( mPid != MPID_UNDEFINED )
+     {
+         if ( mStarted )
+         {
+@@ -337,4 +345,5 @@ void Thread::kill( int signal )
  }
  
  // Some explicit template instantiations
diff --git a/zoneminder/patches/patch-src_zmu.cpp b/zoneminder/patches/patch-src_zmu.cpp
index 1f8f6155b6..47f6a5c215 100644
--- a/zoneminder/patches/patch-src_zmu.cpp
+++ b/zoneminder/patches/patch-src_zmu.cpp
@@ -1,17 +1,26 @@
 $NetBSD: patch-src_zmu.cpp,v 1.2 2018/07/14 15:03:57 gdt Exp $
 
---- src/zmu.cpp.orig	2015-02-05 02:52:37.000000000 +0000
+--- src/zmu.cpp.orig	2016-02-03 18:40:30.000000000 +0000
 +++ src/zmu.cpp
-@@ -457,7 +457,7 @@ int main( int argc, char *argv[] )
+@@ -519,14 +519,14 @@ int main( int argc, char *argv[] )
+ 					if ( timestamp.tv_sec )
+ 						strftime( timestamp_str, sizeof(timestamp_str), "%Y-%m-%d %H:%M:%S", localtime( &timestamp.tv_sec ) );
+ 					if ( image_idx == -1 )
+-						printf( "Time of last image capture: %s.%02ld\n", timestamp_str, timestamp.tv_usec/10000 );
++						printf( "Time of last image capture: %s.%02ld\n", timestamp_str, (long) timestamp.tv_usec/10000 );
+ 					else
+-						printf( "Time of image %d capture: %s.%02ld\n", image_idx, timestamp_str, timestamp.tv_usec/10000 );
++						printf( "Time of image %d capture: %s.%02ld\n", image_idx, timestamp_str, (long) timestamp.tv_usec/10000 );
+ 				}
  				else
  				{
  					if ( have_output ) printf( "%c", separator );
 -					printf( "%ld.%02ld", timestamp.tv_sec, timestamp.tv_usec/10000 );
-+					printf( "%jd.%02ld", (intmax_t) timestamp.tv_sec, timestamp.tv_usec/10000 );
++					printf( "%jd.%02ld", (intmax_t) timestamp.tv_sec, (long) timestamp.tv_usec/10000 );
  					have_output = true;
  				}
  			}
-@@ -724,12 +724,12 @@ int main( int argc, char *argv[] )
+@@ -793,12 +793,12 @@ int main( int argc, char *argv[] )
  						if ( monitor && monitor->connect() )
  						{
  							struct timeval tv = monitor->GetTimestamp();
@@ -22,11 +31,11 @@ $NetBSD: patch-src_zmu.cpp,v 1.2 2018/07/14 15:03:57 gdt Exp $
  								monitor->GetState(),
  								monitor->GetTriggerState(),
 -								tv.tv_sec, tv.tv_usec/10000,
-+								(intmax_t) tv.tv_sec, tv.tv_usec/10000,
++								(intmax_t) tv.tv_sec, (long) tv.tv_usec/10000,
  								monitor->GetLastReadIndex(),
  								monitor->GetLastWriteIndex(),
  								monitor->GetLastEvent(),
-@@ -741,12 +741,12 @@ int main( int argc, char *argv[] )
+@@ -810,12 +810,12 @@ int main( int argc, char *argv[] )
  					else
  					{
  						struct timeval tv = { 0, 0 };
@@ -37,7 +46,7 @@ $NetBSD: patch-src_zmu.cpp,v 1.2 2018/07/14 15:03:57 gdt Exp $
  							0,
  							0,
 -							tv.tv_sec, tv.tv_usec/10000,
-+							(intmax_t) tv.tv_sec, tv.tv_usec/10000,
++							(intmax_t) tv.tv_sec, (long) tv.tv_usec/10000,
  							0,
  							0,
  							0,


Home | Main Index | Thread Index | Old Index