add mutex to prevent concurrent session state saves.
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 9 Jul 2014 14:18:28 +0000 (10:18 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 9 Jul 2014 14:18:28 +0000 (10:18 -0400)
Why wasn't this done 10 years ago?

libs/ardour/ardour/session.h
libs/ardour/session_state.cc

index 53215af2b6d14b1ce0a315a5e2baff99aa41ab58..595560a11942183250ca6449467239f6db6c6f9d 100644 (file)
@@ -1126,6 +1126,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        friend class    StateProtector;
        gint            _suspend_save; /* atomic */
        volatile bool   _save_queued;
+       Glib::Threads::Mutex save_state_lock;
 
        int      load_options (const XMLNode&);
        int      load_state (std::string snapshot_name);
index 4e99c663f0521cb931f25826fb6888f792e3a345..42344ea7fdd7f9bd2260745ba8668c5fe5350b9e 100644 (file)
@@ -665,6 +665,10 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot
        XMLTree tree;
        std::string xml_path(_session_dir->root_path());
 
+       /* prevent concurrent saves from different threads */
+
+       Glib::Threads::Mutex::Lock lm (save_state_lock);
+
        if (!_writable || (_state_of_the_state & CannotSave)) {
                return 1;
        }