X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/61809b48ade4c21b1b01931d520aa2abc7507032..a4175b2e216a20b86cc872dea8a08005c60617a5:/lock_smain.cc?ds=inline diff --git a/lock_smain.cc b/lock_smain.cc index 4cc8136..c256cbe 100644 --- a/lock_smain.cc +++ b/lock_smain.cc @@ -1,4 +1,4 @@ -#include "rpc.h" +#include "rpc/rpc.h" #include #include #include @@ -7,8 +7,6 @@ #include "paxos.h" #include "rsm.h" -#include "jsl_log.h" - // Main loop of lock_server char tprintf_thread_prefix = 's'; @@ -16,57 +14,30 @@ char tprintf_thread_prefix = 's'; int main(int argc, char *argv[]) { - int count = 0; - - setvbuf(stdout, NULL, _IONBF, 0); - setvbuf(stderr, NULL, _IONBF, 0); - - srandom(getpid()); + int count = 0; - if(argc != 3){ - fprintf(stderr, "Usage: %s [master:]port [me:]port\n", argv[0]); - exit(1); - } + setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stderr, NULL, _IONBF, 0); - char *count_env = getenv("RPC_COUNT"); - if(count_env != NULL){ - count = atoi(count_env); - } + srandom(getpid()); - //jsl_set_debug(2); - // Comment out the next line to switch between the ordinary lock - // server and the RSM. In Lab 6, we disable the lock server and - // implement Paxos. In Lab 7, we will make the lock server use your - // RSM layer. -#define RSM -#ifdef RSM -// You must comment out the next line once you are done with Step One. -//#define STEP_ONE -#ifdef STEP_ONE - rpcs server(atoi(argv[1])); - lock_server_cache_rsm ls; - server.reg(lock_protocol::acquire, &ls, &lock_server_cache_rsm::acquire); - server.reg(lock_protocol::release, &ls, &lock_server_cache_rsm::release); - server.reg(lock_protocol::stat, &ls, &lock_server_cache_rsm::stat); -#else - rsm rsm(argv[1], argv[2]); - lock_server_cache_rsm ls(&rsm); - rsm.set_state_transfer((rsm_state_transfer *)&ls); - rsm.reg(lock_protocol::acquire, &ls, &lock_server_cache_rsm::acquire); - rsm.reg(lock_protocol::release, &ls, &lock_server_cache_rsm::release); - rsm.reg(lock_protocol::stat, &ls, &lock_server_cache_rsm::stat); -#endif // STEP_ONE -#endif // RSM + if(argc != 3){ + fprintf(stderr, "Usage: %s [master:]port [me:]port\n", argv[0]); + exit(1); + } -#ifndef RSM - lock_server_cache ls; - rpcs server(atoi(argv[1]), count); - server.reg(lock_protocol::stat, &ls, &lock_server_cache::stat); - server.reg(lock_protocol::acquire, &ls, &lock_server_cache::acquire); - server.reg(lock_protocol::release, &ls, &lock_server_cache::release); -#endif + char *count_env = getenv("RPC_COUNT"); + if(count_env != NULL){ + count = atoi(count_env); + } + rsm rsm(argv[1], argv[2]); + lock_server_cache_rsm ls(&rsm); + rsm.set_state_transfer((rsm_state_transfer *)&ls); + rsm.reg(lock_protocol::acquire, &ls, &lock_server_cache_rsm::acquire); + rsm.reg(lock_protocol::release, &ls, &lock_server_cache_rsm::release); + rsm.reg(lock_protocol::stat, &ls, &lock_server_cache_rsm::stat); - while(1) - sleep(1000); + while(1) + sleep(1000); }