Parcourir la 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 il y a 6 mois
Parent
commit
9dfcf124ae
3 fichiers modifiés avec 12 ajouts et 2 suppressions
  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.
     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) {
         RegAS k2) {
     CDPF cdpf = tio.cdpf(yield);
     CDPF cdpf = tio.cdpf(yield);
     auto [lt, eq, gt] = cdpf.compare(tio, yield, k2 - k1, tio.aes_ops());
     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.
     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).
     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)
 // 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);
     static void dump_memusage(std::ostream &os);
 
 
     void dump_stats(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
 // A class to represent all of a computation peer's IO, either to other
@@ -363,6 +368,11 @@ class MPCTIO {
     size_t remaining_nodesselecttriples;
     size_t remaining_nodesselecttriples;
 
 
 public:
 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);
     MPCTIO(MPCIO &mpcio, int thread_num, int num_threads = 1);
 
 
     // Sync our per-thread lamport clock with the master one in the
     // Sync our per-thread lamport clock with the master one in the