Cosmetic improvements.
[invirt/third/libt4.git] / rsm.h
diff --git a/rsm.h b/rsm.h
index 14dc011..ca03473 100644 (file)
--- a/rsm.h
+++ b/rsm.h
@@ -17,8 +17,6 @@ class rsm_state_transfer {
 };
 
 class rsm : public config_view_change {
-    private:
-        void reg1(rpc_protocol::proc_id_t proc, handler *);
     protected:
         map<rpc_protocol::proc_id_t, handler *> procs;
         unique_ptr<config> cfg;
@@ -29,27 +27,26 @@ class rsm : public config_view_change {
         viewstamp last_myvs{0, 0};   // Viewstamp of the last executed request
         viewstamp myvs{0, 1};
         string primary;
-        bool insync;
-        bool inviewchange;
-        unsigned vid_commit;  // Latest view id that is known to rsm layer
+        bool insync = false;
+        bool inviewchange = true;
+        unsigned vid_commit = 0;  // Latest view id that is known to rsm layer
         unsigned vid_insync;  // The view id that this node is synchronizing for
         vector<string> backups;   // A list of unsynchronized backups
 
         // For testing purposes
         unique_ptr<rpcs> testsvr;
-        bool partitioned;
-        bool dopartition;
-        bool break1;
-        bool break2;
+        bool partitioned = false;
+        bool dopartition = false;
+        bool breakpoints[2] = {};
 
-        rsm_client_protocol::status client_members(vector<string> &r, int i);
+        rsm_client_protocol::status client_members(vector<string> & r, int i);
         rsm_protocol::status invoke(int &, rpc_protocol::proc_id_t proc, viewstamp vs, const string & mreq);
-        rsm_protocol::status transferreq(rsm_protocol::transferres &r, const string & src,
+        rsm_protocol::status transferreq(rsm_protocol::transferres & r, const string & src,
                 viewstamp last, unsigned vid);
         rsm_protocol::status transferdonereq(int &, const string & m, unsigned vid);
         rsm_protocol::status joinreq(string & log, const string & src, viewstamp last);
-        rsm_test_protocol::status test_net_repairreq(rsm_test_protocol::status &r, int heal);
-        rsm_test_protocol::status breakpointreq(rsm_test_protocol::status &r, int b);
+        rsm_test_protocol::status test_net_repairreq(rsm_test_protocol::status & r, int heal);
+        rsm_test_protocol::status breakpointreq(rsm_test_protocol::status & r, int b);
 
         mutex rsm_mutex, invoke_mutex;
         cond recovery_cond, sync_cond;
@@ -63,24 +60,24 @@ class rsm : public config_view_change {
         bool sync_with_backups(lock & rsm_mutex_lock);
         bool sync_with_primary(lock & rsm_mutex_lock);
         void net_repair(bool heal, lock & rsm_mutex_lock);
-        void breakpoint1();
-        void breakpoint2();
+        void breakpoint(int b);
         void partition1(lock & rsm_mutex_lock);
         void commit_change(unsigned vid, lock & rsm_mutex_lock);
+        void recovery NORETURN ();
     public:
         rsm (const string & _first, const string & _me);
 
         bool amiprimary();
         void set_state_transfer(rsm_state_transfer *_stf) { stf = _stf; }
-        void recovery NORETURN ();
         void commit_change(unsigned vid);
 
         template<class P, class F, class C=void> void reg(rpc_protocol::proc_t<P> proc, F f, C *c=nullptr) {
             static_assert(is_valid_registration<P, F>::value, "RSM handler registered with incorrect argument types");
-            reg1(proc.id, marshalled_func<F>::wrap(f, c));
+            lock ml(rsm_mutex);
+            procs[proc.id] = marshalled_func<F>::wrap(f, c);
         }
 
         void start();
 };
 
-#endif /* rsm_h */
+#endif