Destroy Job threads at the start of the subclass destructors,
authorCarl Hetherington <cth@carlh.net>
Fri, 6 Mar 2020 20:59:58 +0000 (20:59 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 6 Mar 2020 20:59:58 +0000 (20:59 +0000)
so that the thread is gone before the object is torn down.

21 files changed:
src/lib/analyse_audio_job.cc
src/lib/check_content_change_job.cc
src/lib/check_content_change_job.h
src/lib/examine_content_job.cc
src/lib/examine_content_job.h
src/lib/examine_ffmpeg_subtitles_job.cc
src/lib/examine_ffmpeg_subtitles_job.h
src/lib/job.cc
src/lib/job.h
src/lib/send_kdm_email_job.cc
src/lib/send_kdm_email_job.h
src/lib/send_notification_email_job.cc
src/lib/send_notification_email_job.h
src/lib/send_problem_report_job.cc
src/lib/send_problem_report_job.h
src/lib/transcode_job.cc
src/lib/transcode_job.h
src/lib/upload_job.cc
src/lib/upload_job.h
src/lib/verify_dcp_job.cc
src/lib/verify_dcp_job.h

index e4a100c4a3fd92265635448538ec4b2f3f894551..611a57f5b49a205e6c77736e3339784baaf363b5 100644 (file)
@@ -82,6 +82,7 @@ AnalyseAudioJob::AnalyseAudioJob (shared_ptr<const Film> film, shared_ptr<const
 
 AnalyseAudioJob::~AnalyseAudioJob ()
 {
+       destroy_thread ();
        BOOST_FOREACH (Filter const * i, _filters) {
                delete const_cast<Filter*> (i);
        }
index 3d5e4e979fe7745c2837599e7e838471756ac53b..fbeb695df1304256e0b7d60c5db4c1c8c2bf7bb1 100644 (file)
@@ -41,6 +41,11 @@ CheckContentChangeJob::CheckContentChangeJob (shared_ptr<const Film> film, share
 
 }
 
+CheckContentChangeJob::~CheckContentChangeJob()
+{
+       destroy_thread ();
+}
+
 string
 CheckContentChangeJob::name () const
 {
index da9c5cb20be0d0aa71186956621fb8fd7fbeba82..963d09b59277c128e4c2506a1f4508c81e54b644 100644 (file)
@@ -28,6 +28,7 @@ class CheckContentChangeJob : public Job
 {
 public:
        CheckContentChangeJob (boost::shared_ptr<const Film>, boost::shared_ptr<Job> following = boost::shared_ptr<Job>());
+       ~CheckContentChangeJob ();
 
        std::string name () const;
        std::string json_name () const;
index 86e0a107e1eec1d6351ded90b132e1a24a3a16e3..5c854a99b49b33e44ad1058121542b4fc5051a9a 100644 (file)
@@ -38,6 +38,11 @@ ExamineContentJob::ExamineContentJob (shared_ptr<const Film> film, shared_ptr<Co
 
 }
 
+ExamineContentJob::~ExamineContentJob ()
+{
+       destroy_thread ();
+}
+
 string
 ExamineContentJob::name () const
 {
index 42496372638878773e61f962524d78848b89057d..0105035ffe1c175521680f1fc059869836e5bdc2 100644 (file)
@@ -27,6 +27,7 @@ class ExamineContentJob : public Job
 {
 public:
        ExamineContentJob (boost::shared_ptr<const Film>, boost::shared_ptr<Content>);
+       ~ExamineContentJob ();
 
        std::string name () const;
        std::string json_name () const;
index b9d5f54e5d09385f21406a52683dd4cfbe60abd7..eb2cbcd1f1da2b0866c99085e08e1cc463c48633 100644 (file)
@@ -43,6 +43,11 @@ ExamineFFmpegSubtitlesJob::ExamineFFmpegSubtitlesJob (shared_ptr<const Film> fil
 
 }
 
+ExamineFFmpegSubtitlesJob::~ExamineFFmpegSubtitlesJob ()
+{
+       destroy_thread ();
+}
+
 string
 ExamineFFmpegSubtitlesJob::name () const
 {
index 5960a9cc3bad241c403b4910bcf1852825d8c319..0a0101193c0067b34c9d25af15ae4c990962d37d 100644 (file)
@@ -28,6 +28,7 @@ class ExamineFFmpegSubtitlesJob : public Job, public FFmpeg
 {
 public:
        ExamineFFmpegSubtitlesJob (boost::shared_ptr<const Film>, boost::shared_ptr<FFmpegContent>);
+       ~ExamineFFmpegSubtitlesJob ();
 
        std::string name () const;
        std::string json_name () const;
index 4517765247075236bd702123852bc6125c27fc7e..d4023973cfb4fd9942032f99f793d4dee04e7627 100644 (file)
@@ -61,6 +61,15 @@ Job::Job (shared_ptr<const Film> film)
 }
 
 Job::~Job ()
+{
+#ifdef DCPOMATIC_DEBUG
+       /* Any subclass should have called destroy_thread in its destructor */
+       assert (!_thread);
+#endif
+}
+
+void
+Job::destroy_thread ()
 {
        if (_thread) {
                _thread->interrupt ();
@@ -75,6 +84,7 @@ Job::~Job ()
        }
 
        delete _thread;
+       _thread = 0;
 }
 
 /** Start the job in a separate thread, returning immediately */
index 0e57021e0c1cafbcc545c2502a94d7462f2c9834..7047a7ba3540f3368d020824d31bb36ab77502b2 100644 (file)
@@ -112,6 +112,7 @@ protected:
        void set_message (std::string m);
        int elapsed_sub_time () const;
        void check_for_interruption_or_pause ();
+       void destroy_thread ();
 
        boost::shared_ptr<const Film> _film;
 
index 38484b91e15500333184422541b45c77e763c396..a4b4b297f453287d81ae377c859a5aa99a28df6e 100644 (file)
@@ -53,6 +53,11 @@ SendKDMEmailJob::SendKDMEmailJob (
 
 }
 
+SendKDMEmailJob::~SendKDMEmailJob ()
+{
+       destroy_thread ();
+}
+
 string
 SendKDMEmailJob::name () const
 {
index b4e007e3ba51cac9d576c115b90e4bac20245070..fcb9a0b9e46a85d1f1b189df4362ab90985c6b62 100644 (file)
@@ -38,6 +38,8 @@ public:
                std::string cpl_name
                );
 
+       ~SendKDMEmailJob ();
+
        std::string name () const;
        std::string json_name () const;
        void run ();
index abbb844e2f5c2fe6b2a5b72ba3607d94dbd4f7ab..5986e5a166de74e34c07141d2c8747097e2d9b90 100644 (file)
@@ -40,6 +40,11 @@ SendNotificationEmailJob::SendNotificationEmailJob (string body)
 
 }
 
+SendNotificationEmailJob::~SendNotificationEmailJob ()
+{
+       destroy_thread ();
+}
+
 string
 SendNotificationEmailJob::name () const
 {
index 04f1d98ab82f62b77fe184b4cf9c3300e13b0fe4..5c116f2eefc2514d72052661dd3e0ae6187790c0 100644 (file)
@@ -24,6 +24,7 @@ class SendNotificationEmailJob : public Job
 {
 public:
        explicit SendNotificationEmailJob (std::string body);
+       ~SendNotificationEmailJob ();
 
        std::string name () const;
        std::string json_name () const;
index 11f700de077490751550913257e8991df05f4d8a..83092049f19be55746613a406ecea05f6f54a45f 100644 (file)
@@ -52,6 +52,11 @@ SendProblemReportJob::SendProblemReportJob (
 
 }
 
+SendProblemReportJob::~SendProblemReportJob ()
+{
+       destroy_thread ();
+}
+
 string
 SendProblemReportJob::name () const
 {
index c4371a54ed4b32014ed8e1a8afd6355ed692f806..af1a4b26901688efb7a164050d9de09a5acd9bca 100644 (file)
@@ -31,6 +31,8 @@ public:
                std::string summary
                );
 
+       ~SendProblemReportJob ();
+
        std::string name () const;
        std::string json_name () const;
        void run ();
index 1db37e3708b27748ada7455763a2c753e63e30f6..f2711bf1760e86e4fc837fff27d91ec2b2822290 100644 (file)
@@ -51,6 +51,11 @@ TranscodeJob::TranscodeJob (shared_ptr<const Film> film)
 
 }
 
+TranscodeJob::~TranscodeJob ()
+{
+       destroy_thread ();
+}
+
 string
 TranscodeJob::name () const
 {
index 9dd9e36846abf5036fc894c743eb717585dfece2..fccb1a44a90b746b94629ecc9d54b9f3a7751027 100644 (file)
@@ -34,6 +34,7 @@ class TranscodeJob : public Job
 {
 public:
        explicit TranscodeJob (boost::shared_ptr<const Film> film);
+       ~TranscodeJob ();
 
        std::string name () const;
        std::string json_name () const;
index b229fddbe217f8d5926a4e94633c33103753dee0..eca46838dd7eadd1e0af83e1e238ce07648ae716 100644 (file)
@@ -46,6 +46,11 @@ UploadJob::UploadJob (shared_ptr<const Film> film)
 
 }
 
+UploadJob::~UploadJob ()
+{
+       destroy_thread ();
+}
+
 string
 UploadJob::name () const
 {
index 407094ab839851fb1b49f0b3801bb4a5530a949c..3a613fd72e4c1c73daed418b33a0811b3d7a761f 100644 (file)
@@ -28,6 +28,7 @@ class UploadJob : public Job
 {
 public:
        explicit UploadJob (boost::shared_ptr<const Film>);
+       ~UploadJob ();
 
        std::string name () const;
        std::string json_name () const;
index 5fb2a59c1929d6caf9ac8cc5312dca84df901a7f..03d9c4c4cbfab3f608eab324f562e65e541297f0 100644 (file)
@@ -35,6 +35,11 @@ VerifyDCPJob::VerifyDCPJob (vector<boost::filesystem::path> directories)
 
 }
 
+VerifyDCPJob::~VerifyDCPJob ()
+{
+       destroy_thread ();
+}
+
 string
 VerifyDCPJob::name () const
 {
index a93a7adfa30ae83231097f619c97acb57f8c33a2..2cff5ab6cd1ffdd934efc030b79e7edff0e12c02 100644 (file)
@@ -28,6 +28,7 @@ class VerifyDCPJob : public Job
 {
 public:
        explicit VerifyDCPJob (std::vector<boost::filesystem::path> directories);
+       ~VerifyDCPJob ();
 
        std::string name () const;
        std::string json_name () const;