Lots of clean-ups and simplifications
[invirt/third/libt4.git] / lock_smain.cc
1 #include "rpc/rpc.h"
2 #include <arpa/inet.h>
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <unistd.h>
6 #include "lock_server_cache_rsm.h"
7 #include "paxos.h"
8 #include "rsm.h"
9
10 // Main loop of lock_server
11
12 char tprintf_thread_prefix = 's';
13
14 int
15 main(int argc, char *argv[])
16 {
17     setvbuf(stdout, NULL, _IONBF, 0);
18     setvbuf(stderr, NULL, _IONBF, 0);
19
20     srandom(getpid());
21
22     if(argc != 3){
23         fprintf(stderr, "Usage: %s [master:]port [me:]port\n", argv[0]);
24         exit(1);
25     }
26
27     rsm rsm(argv[1], argv[2]);
28     lock_server_cache_rsm ls(&rsm);
29     rsm.set_state_transfer((rsm_state_transfer *)&ls);
30     rsm.reg(lock_protocol::acquire, &ls, &lock_server_cache_rsm::acquire);
31     rsm.reg(lock_protocol::release, &ls, &lock_server_cache_rsm::release);
32     rsm.reg(lock_protocol::stat, &ls, &lock_server_cache_rsm::stat);
33
34     while(1)
35         sleep(1000);
36 }