-
Notifications
You must be signed in to change notification settings - Fork 1
/
lock_smain.cc
45 lines (35 loc) · 889 Bytes
/
lock_smain.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "rpc.h"
#include <arpa/inet.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include "lock_server_cache.h"
#include "jsl_log.h"
// Main loop of lock_server
int
main(int argc, char *argv[])
{
int count = 0;
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
srandom(getpid());
if(argc != 2){
fprintf(stderr, "Usage: %s port\n", argv[0]);
exit(1);
}
char *count_env = getenv("RPC_COUNT");
if(count_env != NULL){
count = atoi(count_env);
}
jsl_set_debug(JSL_DBG_ME);
#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
while(1)
sleep(1000);
}