]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
context: all C_Gather to OR instead of AND subs.
authorSage Weil <sage@newdream.net>
Mon, 24 Nov 2008 22:06:49 +0000 (14:06 -0800)
committerSage Weil <sage@newdream.net>
Mon, 24 Nov 2008 22:06:49 +0000 (14:06 -0800)
That is, call completion when first sub completes.

src/include/Context.h

index ddacd3bc8c44d821e8d69ba407e48a709db17bfb..5a5cc72a6eca14c8d014e4640e6d9907ed33a23d 100644 (file)
@@ -107,6 +107,8 @@ public:
 };
 
 
+
+
 /*
  * C_Gather
  *
@@ -118,13 +120,22 @@ public:
     //cout << "C_Gather sub_finish " << this << " got " << r << " of " << waitfor << endl;
     assert(waitfor.count(r));
     waitfor.erase(r);
+
+    if (any && onfinish) {
+      onfinish->finish(0);
+      delete onfinish;
+      onfinish = 0;
+    }
+
     if (!waitfor.empty()) 
       return false;  // more subs left
 
     // last one
-    onfinish->finish(0);
-    delete onfinish;
-    onfinish = 0;
+    if (!any && onfinish) {
+      onfinish->finish(0);
+      delete onfinish;
+      onfinish = 0;
+    }
     return true;
   }
 
@@ -149,9 +160,10 @@ private:
   Context *onfinish;
   std::set<int> waitfor;
   int num;
+  bool any;  /* if true, OR, otherwise, AND */
 
 public:
-  C_Gather(Context *f=0) : onfinish(f), num(0) {
+  C_Gather(Context *f=0, bool an=false) : onfinish(f), num(0), any(an) {
     //cout << "C_Gather new " << this << endl;
   }
   ~C_Gather() {