Browse Source

Make MPCIO and MPCTIO objects non-copyable

Otherwise the Lamport clock gets duplicated and not kept in sync.

Also fix one more place where an MPCTIO was being passed by copy.
Ian Goldberg 5 months ago
parent
commit
9dfcf124ae
3 changed files with 12 additions and 2 deletions
  1. 1 1
      bst.cpp
  2. 1 1
      bst.hpp
  3. 10 0
      mpcio.hpp

+ 1 - 1
bst.cpp

@@ -54,7 +54,7 @@ static void randomize_node(Node &a) {
     left), and keeps the gt flag as is (flag to go right) during traversal.
 
 */
-std::tuple<RegBS, RegBS> compare_keys(MPCTIO tio, yield_t &yield, RegAS k1,
+std::tuple<RegBS, RegBS> compare_keys(MPCTIO &tio, yield_t &yield, RegAS k1,
         RegAS k2) {
     CDPF cdpf = tio.cdpf(yield);
     auto [lt, eq, gt] = cdpf.compare(tio, yield, k2 - k1, tio.aes_ops());

+ 1 - 1
bst.hpp

@@ -126,7 +126,7 @@ struct Node {
     left), and keeps the gt flag as is (flag to go right) during traversal.
     Returns the shared bit flags lteq (go left) and gt (go right).
 */
-std::tuple<RegBS, RegBS> compare_keys(MPCTIO tio, yield_t &yield, RegAS k1, RegAS k2);
+std::tuple<RegBS, RegBS> compare_keys(MPCTIO &tio, yield_t &yield, RegAS k1, RegAS k2);
 
 // I/O operations (for sending over the network)
 

+ 10 - 0
mpcio.hpp

@@ -198,6 +198,11 @@ struct MPCIO {
     static void dump_memusage(std::ostream &os);
 
     void dump_stats(std::ostream &os);
+
+    // Make MPCIO objects non-copyable; otherwise the Lamport clock
+    // gets duplicated and not kept in sync.
+    MPCIO(const MPCIO&) = delete;
+    MPCIO& operator=(const MPCIO&) = delete;
 };
 
 // A class to represent all of a computation peer's IO, either to other
@@ -363,6 +368,11 @@ class MPCTIO {
     size_t remaining_nodesselecttriples;
 
 public:
+    // Make MPCTIO objects non-copyable; otherwise the Lamport clock
+    // gets duplicated and not kept in sync.
+    MPCTIO(const MPCTIO&) = delete;
+    MPCTIO& operator=(const MPCTIO&) = delete;
+
     MPCTIO(MPCIO &mpcio, int thread_num, int num_threads = 1);
 
     // Sync our per-thread lamport clock with the master one in the