[gnote] Handle spurious wakeups in GVFS sync



commit c285e9ee022007a506829ccd3ad5cca98da0fbba
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sat Feb 1 22:18:08 2020 +0200

    Handle spurious wakeups in GVFS sync

 src/addins/gvfssyncservice/gvfssyncserviceaddin.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/src/addins/gvfssyncservice/gvfssyncserviceaddin.cpp 
b/src/addins/gvfssyncservice/gvfssyncserviceaddin.cpp
index c0ee5bad..2437ff58 100644
--- a/src/addins/gvfssyncservice/gvfssyncserviceaddin.cpp
+++ b/src/addins/gvfssyncservice/gvfssyncserviceaddin.cpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2019 Aurimas Cernius
+ * Copyright (C) 2019,2020 Aurimas Cernius
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -92,13 +92,14 @@ gnote::sync::SyncServer *GvfsSyncServiceAddin::create_sync_server()
 
 bool GvfsSyncServiceAddin::mount(const Glib::RefPtr<Gio::File> & path)
 {
-  bool ret = true;
+  bool ret = true, done = false;
   Glib::Mutex mutex;
   Glib::Cond cond;
   mutex.lock();
-  if(mount_async(path, [&ret, &mutex, &cond](bool result, const Glib::ustring&) {
+  if(mount_async(path, [&ret, &mutex, &cond, &done](bool result, const Glib::ustring&) {
        mutex.lock();
        ret = result;
+       done = true;
        cond.signal();
        mutex.unlock();
      })) {
@@ -106,7 +107,9 @@ bool GvfsSyncServiceAddin::mount(const Glib::RefPtr<Gio::File> & path)
     return true;
   }
 
-  cond.wait(mutex);
+  while(!done) {
+    cond.wait(mutex);
+  }
   mutex.unlock();
   return ret;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]