From 29d9b07e6db976f40d797235d7c233ed8ecf15fa Mon Sep 17 00:00:00 2001 From: cah Date: Sat, 28 Mar 2020 00:35:16 +0100 Subject: [PATCH 1/1] Fix _writer process shutdown a little. --- src/lib/copy_to_drive_job.cc | 2 +- src/tools/dcpomatic_dist.cc | 9 +-------- src/tools/dcpomatic_dist_writer.cc | 23 ++++++++++++++--------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/lib/copy_to_drive_job.cc b/src/lib/copy_to_drive_job.cc index 68055f7e9..34bffe0e8 100644 --- a/src/lib/copy_to_drive_job.cc +++ b/src/lib/copy_to_drive_job.cc @@ -63,7 +63,7 @@ CopyToDriveJob::json_name () const void CopyToDriveJob::run () { - _nanomsg.send(String::compose("%1\n%2\n", _dcp.string(), _drive.internal_name())); + _nanomsg.send(String::compose("W\n%1\n%2\n", _dcp.string(), _drive.internal_name())); while (true) { string s = _nanomsg.blocking_get (); diff --git a/src/tools/dcpomatic_dist.cc b/src/tools/dcpomatic_dist.cc index c94062568..2098eb1a5 100644 --- a/src/tools/dcpomatic_dist.cc +++ b/src/tools/dcpomatic_dist.cc @@ -126,8 +126,7 @@ public: ~DOMFrame () { - _writer->terminate (); - delete _writer; + _nanomsg.send("Q\n"); } private: @@ -281,12 +280,6 @@ public: return true; } - int OnExit () - { - _frame->Destroy (); - return 0; - } - void config_failed_to_load () { message_dialog (_frame, _("The existing configuration failed to load. Default values will be used instead. These may take a short time to create.")); diff --git a/src/tools/dcpomatic_dist_writer.cc b/src/tools/dcpomatic_dist_writer.cc index 04325dd5b..c667f2f95 100644 --- a/src/tools/dcpomatic_dist_writer.cc +++ b/src/tools/dcpomatic_dist_writer.cc @@ -365,20 +365,25 @@ idle () return true; } - dcp_path = *s; - device = nanomsg->blocking_get(); + if (*s == "Q") { + exit (EXIT_SUCCESS); + } else if (*s == "W") { + dcp_path = nanomsg->blocking_get(); + device = nanomsg->blocking_get(); - LOG_DIST ("Here we go writing %1 to %2", dcp_path, device); + LOG_DIST ("Here we go writing %1 to %2", dcp_path, device); #ifdef DCPOMATIC_LINUX - polkit_authority = polkit_authority_get_sync (0, 0); - PolkitSubject* subject = polkit_unix_process_new (getppid()); - polkit_authority_check_authorization ( - polkit_authority, subject, "com.dcpomatic.write-drive", 0, POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, 0, polkit_callback, 0 - ); + polkit_authority = polkit_authority_get_sync (0, 0); + PolkitSubject* subject = polkit_unix_process_new (getppid()); + polkit_authority_check_authorization ( + polkit_authority, subject, "com.dcpomatic.write-drive", 0, POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, 0, polkit_callback, 0 + ); #else - write (); + write (); #endif + } + return true; } -- 2.30.2